_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
Stratagus uses a very simple scripted AI. There are no optimizations yet. The complete AI was written on one weekend. Until no AI specialist joins, I keep this AI.
The AI script tells the engine build 4 workers, than build 3 footman, than attack the player, than sleep 100 frames.
Manage the inititialse and cleanup of the AI players.
Initialise all global varaibles and structures. Called before AiInit, or before game loading.
::AiInit(::Player)
Called for each player, to setup the AI structures Player::Aiin the player structure. It can use Player::AiName to select different AI's.
Called to release all the memory for all AI structures. Must handle self which players contains AI structures.
::SaveAi(::FILE *)
Save the AI structures of all players to file. Must handle self which players contains AI structures.
This functions are called regular for all AI players.
::AiEachCycle(::Player)
Called each game cycle, to handle quick checks, which needs less CPU.
::AiEachSecond(::Player)
Called each second, to handle more CPU intensive things.
This functions are called, when some special events happens.
Called if a unit owned by the AI is attacked.
Called if a unit owned by the AI is killed.
Called if an trained unit is ready, but not enough food is available for it.
Called if a unit has completed its work.
Called if the AI unit can't build the requested unit-type.
Called if the AI unit can't reach the building place.
Called if AI unit has completed training a new unit.
Called if AI unit has completed upgrade to new unit-type.
Called if AI unit has completed research of an upgrade or spell.