FreeCiv Red-Tape AI Guy Loren Smith guy@xxxxxxxxxxxxxxxx guy.smith10@xxxxxxxxxxx June 30, 2001 1 INTRODUCTION By its nature, FreeCiv is a game concerned with government. There are multiple nations striving with each other for economic, military, and technological goals. The game contains innumerable competitions; there is an arms race, a research race, an expansion race, a wonder race, a production race, a space race, a trade race, an exploration race, and an economics race. Managing these races is a matter of compromise, and of setting priorities. Because of the great variety of races involved, creating a strategy to win the game is a difficult task. It is made more difficult by the necessity to manage every detail of the empire, from city construction to shipping to trade routes to the specifics of warfare. All of these tasks consume thought and energy from the leader; that thought an energy can better be spent on the broader goal, which is winning the game. To this end, it seems reasonable to create a new kind of interface to FreeCiv, one which does not concern the player with the fine-grained details of the empire, but which allows him to explore options in the policy-space. In short, the game needs a government. By this, I suggest a government in the truest sense of the word: a fully-formed, virtual beauracracy. In this model, there are intelligent programs that are concerned with running different aspects of the empire. Mayors concern themselves with cities. The Production Minister is in charge of construction. The Finance Minister handles taxation. Ultimately, all of these officials receive their direction from the Commander in Chief. As in any beauracracy, there is paperwork to be done. Officials accomplish their jobs by filling out forms and sending them to other officials, who add them to their list of things to do, prioritize them, subject them to review, and ultimately reject, approve, or defer their execution. Some officials can enjoy a higher priority than other officials; priorities are set by the Commander in Chief. A task's priority can depend on circumstances; military tasks may be less important when there are no enemies at the gates, or could be of overriding importance under a full-scale invasion. Ultimately, the design is intended to increase the efficiency with which the CINC can accomplish his objectives, by allowing him to focus on the highest-level details that are relevant to running an empire. 2 OVERVIEW This is a work in progress. Many of the roles defined below may change or be transferred to other ministers. Some ministers might have sub-ministers, or lieutenants, added to assist them in their tasks. New ministers might be created. Some of the roles described are incomplete. In some situations, an official exists without a well-defined role at all; in these cases, there is merely an intuition in the author's mind that there is an important role to be filled there. Parts of this document may also be self-contradictory. This is because this is a living document. The author welcomes comments and suggestions for improvement. 2.1 CAST of CHARACTERS Mayors Governor Commander in Chief Production Minister Expansion Minister Engineering Minister Logistics Minister Research Minister War Minister Cartography Minister Finance Minister Trade Minister Space Minister Records Minister Foreign Minister 2.2 PAPERWORK (caveat emptor: this list is far from complete) FORM_REQ_BUILDING: requisition construction of a building FORM_REQ_ENGINEERING: requisition engineering FORM_REQ_UNIT: requisition construction of a unit FORM_REQ_WONDER: requisition a wonder FORM_REQ_RESEARCH: requisition a research goal FORM_REQ_GOVERNMENT: requisition a form of government FORM_REQ_CITY_OBJECTIVE: request that a city pursue an objective (production, research, trade, etc) FORM_REQ_MAYOR: request creation of a mayor FORM_REQ_LIBERATE: request liberation of a city FORM_REQ_PRESENCE: request the presence of a unit on a map square FORM_REQ_ALERT: request that a unit enter an alert state FORM_REQ_DESTROY_UNIT: request that an enemy unit be destroyed 2.3 RESPONSIBILITIES 2.3.1 MAYORS Mayors are responsible for maintaining peace in their cities, ensuring that their cities grow, and for maximizing the resource utilization of the countryside. To that end, they may requisition the construction of buildings or wonders consistent with growth or happiness, requistiion engineering improvements to the countryside, reallocate workers to different tasks, request different forms of government, and submit requests for research goals consistent with growth and happiness. They may also be ordered to gear themselves toward growth, production, trade, or research. In the short term this involves a reallocation of workers; in the long term, it affects their decisions regarding engineering requests and construction. Mayors are also responsible for requisitioning the construction of their cities if the city does not exist (mayors are assigned to map squares, not cities per-se), and for requesting liberation of their cities when they are occupied by enemy forces. A mayor might be assigned to a map square occupied by a foreign city; in this case, the mayor would assume that "his" city is being occupied by foreign forces, and will then issue a request for the city to be "liberated." 2.3.2 GOVERNOR The governor is responsible for setting general priorities and for recommending changes in the form of government. The governor will generate a plan and submit it to the CINC for approval. The roles of the governor are not yet well established. There might be some question as to why there would be both a governor and a commander-in-chief. The reason is that the model is intended to operate both as a player-assisted AI and as a standalone AI. In the standalone model, the CINC unit is simply a rubber-stamp that would approve all decision made by the governor. In the player-assisted role, the CINC is the user interface which allows the player to override and fine-tune the behavior of the governor. This allows a sophisticated leadership AI to be written in such a way that it can be used both by players seeking advice and as a competent player in its own right. However, until most of the other ministers are developed and the model is more fully fleshed out, the actual role the governor fills will remain murky. Imagine it as a placeholder for higher-level policy decisions that affect ALL ministers and mayors. 2.3.3 COMMANDER IN CHIEF The CINC is ultimately responsible for approving or modifying plans submitted by the governor. In a pure AI model, the CINC will merely approve any plan submitted by the governor. When a human is playing, the CINC is actually the GUI by which the player interacts with the game, and provides the ability for the player to manage (or supervise) all of the mayors and ministers in the game. The CINC has the ability to veto any order issued by any official or minister, and can insert his own orders at maximum priority, superceding any of the mayors or ministers. 2.3.4 PRODUCTION MINISTER The production minister is responsible for coordinating the production in all of the cities in the empire. All requests for new construction, be they for buildings, wonders, or units, are evaluated by the production minister and prioritized. The production minister generates a plan to minimize the delay in producing each specified item. In accordance with his goals, this minister might make production requests of his own. These production requests would be for the construction of buildings or wonders that are consistent with increases in production. He might also submit requests that cities gear themselves for more production. Finally, he will submit requests for research goals consistent with increasing production, and he may request a change of government. This minister might also perform unit upgrades or construct caravans or freight for stockpiling purposes. He might request the disbanding of a unit to add the production points to an urgent project. 2.3.5 EXPANSION MINISTER The expansion minister is responsible for growing the empire. This task consists primarily of creating new mayors and assigning them to map squares. The map squares may be empty, or they may have foreign cities occupying them. In the first case, the mayor will immediately requisition construction of a city. In the second case, the mayor will request an invasion of the city. The job of the expansion minister also involves providing requests for exploration to the cartography minister. 2.3.6 ENGINEERING MINISTER The engineering minister is responsible for prioritizing requests for countryside improvements and city construction, and for requisitioning the settlers and engineers that are required to fulfill this mission. The engineering minister might put in requests for research consistent with these goals. 2.3.7 LOGISTICS MINISTER This minister is responsible for the movements of all units. He will also requisition the construction of new units if there are inssuficient units to meet the current demands. The idea is that instead of the war minister requisitioning the constuction of ten archers, for example, he will instead request that the logistics minister place ten archers where the war minister desires. The logistics minister then realizes that those ten archers must be constructed in the first place, and submits the requests to the production minister with the priority assigned by the war minister. The logistics minister is interested in rapid movement of units throughout the empire, and hence will put in requests for transport ships and for roads and railroads consistent with optimizing movement. He will requisition airports and airbases, and will request research goals consistent with rapid mobilization. He will request wonders that are consistent with these goals (magellan's expedition, for example). 2.3.8 RESEARCH MINISTER The research minister recieves requests for research goals and must produce a research plan to satisfy those goals in a minimum amount of time, while accounting for the priorities of each goal. She also will put in requests for construction of buildings and wonders to improve research output, and will request that cities gear themselves toward research. She will suggest trading knowledge with other nations. She will request stealing knowledge from other nations. Finally, she will request knowledge of the research achievements of all other nations (implying embassies). 2.3.9 WAR MINISTER The war minister is responsible for ensuring the defensive integrity of the nation and for mounting offensive actions against other nations. He will requistion the placement of the most modern units available to achieve these ends. He will also put in requests for buildings and wonders consistent with national defense, and will request research goals leading to more advanced weaponry. 2.3.10 CARTOGRAPHY MINISTER The cartography minister is responsible for keeping the world map up-to-date. This involves exploration and surveillance. His task may be influenced by requests from other ministers (such as the expansion minister and the war minister). 2.3.11 FINANCE MINISTER The finance minister is responsible for setting the tax rates and for recommending city capitalization. He will requisition buildings consistent with higher tax revenues, and will request wonders consistent with finance (Adam Smith's Trading Co., for example). He must ensure that there is a minimum budget surplus to allow the production minister to buy or upgrade units when necessary. 2.3.12 TRADE MINISTER The trade minister is responsible for increasing the trade in the nation. He will requisition buildings, wonders, and research consistent with that goal. He will request that cities gear themselves toward trade, and he will requisition caravans to establish trade routes. 2.3.13 SPACE MINISTER The space minister will attempt to win the space race. He will encourage research leading to space travel, and will requisition the structural infrastructure for the spacecraft. He will recommend that cities gear themselves toward production, especially as space travel becomes a possibility. 2.3.14 RECORDS MINISTER Not sure about this one. This minister probably wouldn't have an active role; instead, he might serve as a repository of information. The idea is to do post-mortems on games, in an attempt to identify wrong decisions. 2.3.15 FOREIGN MINISTER The foreign minister is responsible for establishing embassies with all other nations, for handling espionage, for establishing peace treaties and strategic alliances, and for recommending war. He will requistion research, units, and wonders consistent with these goals. 3 IMPLEMENTATION Creating a wish list is real easy. So how do we actual build all of this? 3.1 GENERAL ARCHITECTURE Because of the tentative nature of many of the ministers, and the expectation that new ministers may be added or existing ministers modified, and in view of the fact that the software is intended to be used both as a player-assisted AI and in a standalone mode, it makes sense to pursue a design architecture based on dynamic shared objects. In this model, there will be a base program that has the job of communicating with the FreeCiv server. This program will also accept a configuration file that specifies a list of shared objects to load, as well as any special configuration directives that those shared objects might require. Once the objects are loaded, one of the objects (the CINC, for example) would inform the base software of the server to connect to, and would await the beginning of the game. It is tempting for me to require that this base platform include the fundamentals of beauracracy, since my AI model is based on that paradigm. However, this limits the software to a particular model. The ease with which it could be written compels me to write the client this way, without regard for other models. In fact, I expect that this is exactly the path I will pursue. It is possible, however, that I will build a beaurcracy shared object that can be loaded onto the base platform, and still maintain the base for general use. The next question (that I have not yet answered) involves the tasking capabilities of the software. Much of the game is event-driven, and of course there must be an ability to handle interruptions. But much of the AI is not event-driven. Exactly how I'm going to address this aspect remains an open question. In short, the specifics of the software design are far from complete. All I can say for now is that there will be a base platform responsibile for communicating with the server, and which loads the various AI modules for execution. Any user interface (be it GUI or CLI) will exist as a DSO, and will NOT be directly built into the base platform. Beyond that, the development of the software will be an evolutionary endeavour.