Changes between Version 6 and Version 7 of PetraBot


Ignore:
Timestamp:
Jan 23, 2015, 6:56:36 PM (9 years ago)
Author:
mimo
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PetraBot

    v6 v7  
    33= General structure =
    44
    5 When starting a game, the 0AD AI API creates a !PetraBot object which inherits from the BaseAI. Then every game turn, !PetraBot's !OnUpdate() function is called. Then every n turn (presently n = 8 for performance reasons, but could be reduced in the near future), this function calls the update function of the modules constituting the AI.
     5When starting a game, the 0AD AI API creates a !PetraBot object which inherits from the BaseAI. Then every game turn, !PetraBot's !OnUpdate() function is called. Then every n turn (presently n = 8 for performance reasons, but could be reduced in the near future) with a shift for each AI player so that they are out of phase, this function calls the update function of the modules constituting the AI. These turns where the AI is updated are called "played turn" in the following.
    66
    77The Petra AI is currently based on two main modules which are the [#headquarter headquarter] and the [#queueManager queueManager].The first one is responsible for the choice of the different actions performed by the AI while the latter allocates the available resources to these choices by a system of queues with adequate priorities.
     
    1919Each new cc is the root of a new base, which is governed by its own baseManager. This manager handles workers assigned to that base (for gathering, hunting, fishing, ...) through the file worker.js. It is also responsible for checking base's resources levels, building new dropsites if necessary, repairing its hurt structures.
    2020
     21In addition, an "empty" base is created when starting a game. In principle, all units/buidings are assigned to an "active" base (i.e. a base with an undestroyed cc), and when this cc is destroyed, its units/buildings are assigned to the nearest active one. But when this is not possible (for example when starting a game without cc, or because all ccs have been destroyed), the units/buildings are assigned to the empty base, waiting for the next cc to be build.
     22This empty base has thus a very limited goal: build a new cc, and if the available resources are not enough, build a dock and accumulates the resources needed to build a cc. And when this is done, all units/buildings are assigned to this new base. The empty base is thus quite different from the inactive bases whose cc has been destroyed and which have then no more use in the game.
     23
     24The headquarter has an array of all available bases (this.baseManagers) and by convention the empty base is always the first one (this.baseManagers[0]).
     25
    2126 == !DefenseManager ==
    2227The defenseManager is responsible for the response to attacks (either directed towards the AI itself or towards its allies). It also deals with unit garrisoning (either garrisoning ranged units inside a "fighting" structures or garrisoning hurt units inside healing structures).
    2328
     29Each played turn, the defense manager looks for
     30  * enemy soldiers in range of one of its building
     31  * enemy units building a cc not far from its border
     32  * enemy soldiers in range of one allied cc depending on its [#VariabilityofAIstrategy cooperative trait]
     33Such enemy units found are then grouped inside armies, and the defense manager will try and find the most appropriate units to counter these attacks.
     34
     35It also deals with garrisoning support units in the nearest healing building when their health is below a certain value and to garrison soldiers in attacked buildings when such garrisoning can improve the building's fire power.
     36
    2437 == !DiplomacyManager ==
    25 Deals with tributes with allies.
     38Deals with tributes with allies. It also updates the AI's [#VariabilityofAIstrategy cooperative trait] following its allies actions.
    2639
    2740== !GarrisonManager ==