$treeview $search $mathjax
Stratagus  2.2.6
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
           Stratagus - A free fantasy real time strategy game engine

src/ai/ai_local.h File Reference

#include <vector>
#include "upgrade_structs.h"
#include "unit.h"

Go to the source code of this file.


Classes

class  CAiType
class  AiRequestType
class  AiUnitType
class  AiForce
class  AiForceManager
class  AiBuildQueue
class  AiExplorationRequest
class  AiTransportRequest
class  PlayerAi
class  AiHelper

ai_local.h - The local AI header file.

#define AI_MAX_FORCES   10
enum  AiForceRole { AiForceRoleAttack = 0, AiForceRoleDefend }
enum  AiForceAttackingState {
  AiForceAttackingState_Free = -1, AiForceAttackingState_Waiting = 0, AiForceAttackingState_Boarding, AiForceAttackingState_AttackingWithTransporter,
  AiForceAttackingState_Attacking
}
std::vector< CAiType * > AiTypes
 Ai sleeps # cycles.
AiHelper AiHelpers
 List of all AI types.
int UnitTypeEquivs [UnitTypeMax+1]
 AI helper variables.
PlayerAiAiPlayer
 equivalence between unittypes
void AiAddUnitTypeRequest (CUnitType &type, int count)
 Current AI player.
void AiAddUpgradeToRequest (CUnitType &type)
 Add upgrade-to request to resource manager.
void AiAddResearchRequest (CUpgrade *upgrade)
 Add research request to resource manager.
void AiResourceManager ()
 Periodic called resource manager handler.
void AiExplore (const Vec2i &pos, int exploreMask)
 Ask the ai to explore around pos.
void AiNewUnitTypeEquiv (CUnitType *a, CUnitType *b)
 Make two unittypes be considered equals.
void AiResetUnitTypeEquiv ()
 Remove any equivalence between unittypes.
int AiFindUnitTypeEquiv (const CUnitType &type, int *result)
 Finds all equivalents units to a given one.
int AiFindAvailableUnitTypeEquiv (const CUnitType &type, int *result)
 Finds all available equivalents units to a given one, in the prefered order.
int AiGetBuildRequestsCount (PlayerAi *, int counter[UnitTypeMax])
void AiNewDepotRequest (CUnit &worker)
int AiFindBuildingPlace (const CUnit &worker, const CUnitType &type, int nx, int ny, Vec2i *dpos)
 Find nice building place.
void AiCleanForces ()
 Cleanup units in force.
bool AiAssignToForce (CUnit &unit)
 Assign a new unit to a force.
void AiAssignFreeUnitsToForce ()
 Assign a free units to a force.
void AiAttackWithForceAt (unsigned int force, int x, int y)
 Attack with force at position.
void AiAttackWithForce (unsigned int force)
 Attack with force.
void AiAttackWithForces (int *forces)
 Attack with forces in array.
void AiForceManager ()
 Periodic called force manager handler.
int AiFindWall (AiForce *force)
 Find a wall to attack.
void AiSendExplorers ()
int AiEnemyUnitsInDistance (const CPlayer *player, const CUnitType *type, const Vec2i &pos, unsigned range)
 Enemy units in distance.
void AiCheckMagic ()
 Check for magic.

Define Documentation

#define AI_MAX_FORCES   10


Enumeration Type Documentation

Enumerator:
AiForceAttackingState_Free 
AiForceAttackingState_Waiting 
AiForceAttackingState_Boarding 
AiForceAttackingState_AttackingWithTransporter 
AiForceAttackingState_Attacking 

Roles for forces

Enumerator:
AiForceRoleAttack 
AiForceRoleDefend  Force should attack.

Force should defend


Function Documentation

void AiAddResearchRequest ( CUpgrade upgrade  ) 

Add research request to resource manager.

Check if the research can be done.

Parameters:
upgrade Upgrade to research

void AiAddUnitTypeRequest ( CUnitType type,
int  count 
)

Current AI player.

Add unit-type request to resource manager

Add unit-type request to resource manager.

Parameters:
type Unit type requested.
count How many units.
Todo:
FIXME: should store the end of list and not search it.

void AiAddUpgradeToRequest ( CUnitType type  ) 

Add upgrade-to request to resource manager.

Check if the upgrade-to can be done.

Parameters:
type FIXME: docu

void AiAssignFreeUnitsToForce (  ) 

Assign a free units to a force.

Assign free units to force.

bool AiAssignToForce ( CUnit unit  ) 

Assign a new unit to a force.

Ai assign unit to force.

Parameters:
unit Unit to assign to force.

void AiAttackWithForce ( unsigned int  force  ) 

Attack with force.

Attack opponent with force.

Parameters:
force Force number to attack with.

void AiAttackWithForceAt ( unsigned int  force,
int  x,
int  y 
)

Attack with force at position.

Attack at position with force.

Parameters:
force Force number to attack with.
x X tile map position to be attacked.
y Y tile map position to be attacked.

void AiAttackWithForces ( int *  forces  ) 

Attack with forces in array.

Attack opponent with forces. Merge forces in array into one attack force and attack with it Merge is make because units in one force help each other during attack

Parameters:
forces Array with Force numbers to attack with (array should be finished with -1).

void AiCheckMagic (  ) 

Check for magic.

Check what computer units can do with magic. In fact, turn on autocast for AI.

void AiCleanForces (  ) 

Cleanup units in force.

Cleanup units in forces.

int AiEnemyUnitsInDistance ( const CPlayer player,
const CUnitType type,
const Vec2i pos,
unsigned  range 
)

Enemy units in distance.

void AiExplore ( const Vec2i pos,
int  exploreMask 
)

Ask the ai to explore around pos.

int AiFindAvailableUnitTypeEquiv ( const CUnitType unittype,
int *  usableTypes 
)

Finds all available equivalents units to a given one, in the prefered order.

Find All unittypes equivalent to a given one, and which are available UnitType are returned in the prefered order ( ie palladin >> knight... )

Parameters:
unittype The unittype to find equivalence for
usableTypes int array which will hold the result. (Size UnitTypeMax+1)
Returns:
the number of unittype found

int AiFindBuildingPlace ( const CUnit worker,
const CUnitType type,
int  nx,
int  ny,
Vec2i dpos 
)

Find nice building place.

int AiFindUnitTypeEquiv ( const CUnitType unittype,
int *  result 
)

Finds all equivalents units to a given one.

Find All unittypes equivalent to a given one

Parameters:
unittype the unittype to find equivalence for
result int array which will hold the result. (Size UnitTypeMax+1)
Returns:
the number of unittype found

int AiFindWall ( AiForce force  ) 

Find a wall to attack.

Find possible walls to target.

Parameters:
force Attack force.
Returns:
True if wall found.

void AiForceManager (  ) 

Periodic called force manager handler.

Entry point of force manager, periodic called.

Todo:
FIXME: is this really needed anymore

int AiGetBuildRequestsCount ( PlayerAi ,
int  counter[UnitTypeMax] 
)

void AiNewDepotRequest ( CUnit worker  ) 

void AiNewUnitTypeEquiv ( CUnitType a,
CUnitType b 
)

Make two unittypes be considered equals.

Make two unittypes equivalents from the AI's point of vue

Parameters:
a the first unittype
b the second unittype

void AiResetUnitTypeEquiv (  ) 

Remove any equivalence between unittypes.

Remove any equivalence between unittypes.

Remove any equivalence between unittypes

void AiResourceManager (  ) 

Periodic called resource manager handler.

Entry point of resource manager, periodically called.

void AiSendExplorers (  ) 

Plan the an attack Send explorers around the map

Respond to ExplorationRequests


Variable Documentation

List of all AI types.

equivalence between unittypes

std::vector<CAiType *> AiTypes

Ai sleeps # cycles.

int UnitTypeEquivs[UnitTypeMax+1]

AI helper variables.

(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.