ai.h File Reference

Base functions for all AIs. More...

#include "../network/network.h"
#include "../command_type.h"
#include "../core/random_func.hpp"
#include "../settings_type.h"

Go to the source code of this file.

Data Structures

struct  AICommand
struct  AICompany
struct  AIStruct

Defines

#define AI_CHANCE16(a, b)   ((uint16) AI_Random() <= (uint16)((65536 * a) / b))
#define AI_CHANCE16R(a, b, r)   ((uint16)(r = AI_Random()) <= (uint16)((65536 * a) / b))

Functions

void AI_StartNewAI (CompanyID company)
 A new AI sees the day of light.
void AI_CompanyDied (CompanyID company)
 This AI company died.
void AI_RunGameLoop ()
 The gameloop for AIs.
void AI_Initialize ()
 Initialize some AI-related stuff.
void AI_Uninitialize ()
 Deinitializer for AI-related stuff.
CommandCost AI_DoCommand (TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, const char *text=NULL)
CommandCost AI_DoCommandCc (TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback *callback, const char *text=NULL)
 Executes a raw DoCommand for the AI.
static bool AI_AllowNewAI ()
 Is it allowed to start a new AI.
static uint AI_RandomRange (uint max)
 The random-function that should be used by ALL AIs.
static uint32 AI_Random ()
 The random-function that should be used by ALL AIs.

Variables

AIStruct _ai
AICompany _ai_company [MAX_COMPANIES]


Detailed Description

Base functions for all AIs.

Definition in file ai.h.


Function Documentation

static bool AI_AllowNewAI (  )  [inline, static]

Is it allowed to start a new AI.

This function checks some boundries to see if we should launch a new AI.

Returns:
True if we can start a new AI.

Definition at line 57 of file ai.h.

References _networking, _settings_game, GameSettings::ai, AISettings::ai_in_multiplayer, and AISettings::ainew_active.

void AI_CompanyDied ( CompanyID  company  ) 

This AI company died.

Give it some chance to make a final puf.

Definition at line 211 of file ai.cpp.

Referenced by AI_Uninitialize().

void AI_RunGameLoop (  ) 

The gameloop for AIs.

Handles one tick for all the AIs.

Definition at line 162 of file ai.cpp.

References _networking, _settings_game, GameSettings::ai, AI_DequeueCommands(), AISettings::ai_in_multiplayer, AI_RunTick(), DifficultySettings::competitor_speed, GameSettings::difficulty, and OWNER_NONE.

Referenced by StateGameLoop().

void AI_StartNewAI ( CompanyID  company  ) 

A new AI sees the day of light.

You can do here what ever you think is needed.

Definition at line 200 of file ai.cpp.

Referenced by DoStartupNewCompany().


Generated on Tue Jan 6 19:01:42 2009 for openttd by  doxygen 1.5.6