Free and Open Source real time strategy game with a new take on micro-management

AINicowar

From Globulation2

Revision as of 03:22, 8 August 2007 by Genixpro (talk | contribs)
Jump to: navigation, search

Nicowar is the new powerhouse AI. AI's for Globulation 2 generally perform bad compared to the skilled player, but Nicowar is an attempt to close that gap. Nicowar is based upon the Echo AI system, which provides easy functionality that saves Nicowar from doing allot of the work. Nicowar has a bunch of groups of functions, each of which are called in sequence from tick.

The Phase System

Nicowars layout, code wise, is straightforward. First, There are a variety of phases. Nicowar phases are "fuzzy" in that they don't transition from one phase to the next. Instead, any number of phases can be active at any one time, and the effects of the phases are meant to stack. There are a large number of phases that activate any number of different behaviours. For example, the skilled work phase activates building schools, racetracks and swimmingpools, where as the war preperation phase causes swarms to build warriors, and workers to build barracks.

Building Queues and Orders

Nicowar bassically queues buildings to be constructed in the queue_* functions. Each of these are responsible for deciding how many of what buildings to be constructed. Buildings can also have different kinds of placements, in the BuildingPlacement enum they are listed. For now, Nicowar really has only one method of placement for most buildings, and a couple special methods for the starving recovery inns. One obvious flaw in this system is that buildings are queued based on the circumstances at point t, but between t and when the building is actually constructed circumstances might have changed, leaving one to conclude that Nicowar should build a different building. I have tried the other method, where the type of building to be constructed is done on the fly. While theorietically it should be better, in reality this method produced very poor performance, because most of the time Nicowar thinks it should be constructing Inns, leaving little room for other construction. Every once in a while, nicowar has to sacrifice building an Inn to build more important buildings for the greater good of the colony.

Queued buildings are picked up and constructed in the order_* methods. Only a certain number of buildings can be constructed at once. Every building has different parameters to its placement.

Building Management

Nicowar really only does post-construction management on two types of buildings: Swarms and Inns. The manage_buildings function goes through all buildings, and calls the respective manage_* functions for those buildings.

Managing Inns is fairly simple. If the Inn has less than a certain ammount of wheat for its level, then it will be given more workers, if it has more than anough wheat, it will be given less. These variables are hard coded in Beta1-rc and previous, however they are in the nicowar.txt and nicowar.default.txt files in later releases (and the Mercurial).

Managing Swarms is more complex. The variety of different phases activate different behaviours for the swarm. It also uses statistics to decide whether to assign more or less workers to the swarm, and, like the Inn, adjusts depending on the ammount of wheat in the swarm. Phases also change a swarms various ratios, for example, war_preperation turns on warrior production, and no_workers turns off worker production.

Building Upgrades

Buildings upgrades are mostly random. Bassically, Nicowar manages a maximum number of upgrades at one moment for each building level (and a special override for schools, which should not be upgraded in parrallell). When it decides it needs to upgrade its buildings, it looks at the options. Nicowar chooses a building type to upgrade randomly (although certain building types are weighted over others), then it chooses among the buildings that exist of the type. This means the number of buildings on the map is irrelevant, except when there are 0 buildings of a type. Barracks are weighted very highly, for example, as part of Nicowars strategy.

Misc