Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CAIWorker Class Reference

AI computation orchestator for CCmpAIManager. More...

Collaboration diagram for CAIWorker:

Classes

class  CAIPlayer
 
struct  SCommandSets
 

Public Member Functions

 CAIWorker ()
 
 ~CAIWorker ()
 
void Init (const ScriptInterface &simInterface)
 
bool HasLoadedEntityTemplates () const
 
bool LoadScripts (const std::wstring &moduleName)
 
void PostCommand (int playerid, JS::HandleValue cmd)
 
JS::Value ComputePathScript (JS::HandleValue position, JS::HandleValue goal, pass_class_t passClass)
 
void ComputePath (const CFixedVector2D &pos, const CFixedVector2D &goal, pass_class_t passClass, std::vector< CFixedVector2D > &waypoints)
 
CParamNode GetTemplate (const std::string &name)
 
void DumpImage (const std::wstring &name, const std::vector< u32 > &data, u32 w, u32 h, u32 max)
 Debug function for AI scripts to dump 2D array data (e.g. More...
 
void SetRNGSeed (u32 seed)
 
bool TryLoadSharedComponent ()
 
bool AddPlayer (const std::wstring &aiName, player_id_t player, u8 difficulty, const std::wstring &behavior)
 
bool RunGamestateInit (const Script::StructuredClone &gameState, const Grid< NavcellData > &passabilityMap, const Grid< u8 > &territoryMap, const std::map< std::string, pass_class_t > &nonPathfindingPassClassMasks, const std::map< std::string, pass_class_t > &pathfindingPassClassMasks)
 
void UpdateGameState (JS::HandleValue gameState)
 
void UpdatePathfinder (const Grid< NavcellData > &passabilityMap, bool globallyDirty, const Grid< u8 > &dirtinessGrid, bool justDeserialized, const std::map< std::string, pass_class_t > &nonPathfindingPassClassMasks, const std::map< std::string, pass_class_t > &pathfindingPassClassMasks)
 
void UpdateTerritoryMap (const Grid< u8 > &territoryMap)
 
void StartComputation ()
 
void WaitToFinishComputation ()
 
void GetCommands (std::vector< SCommandSets > &commands)
 
void LoadEntityTemplates (const std::vector< std::pair< std::string, const CParamNode * > > &templates)
 
void Serialize (std::ostream &stream, bool isDebug)
 
void SerializeState (ISerializer &serializer)
 
void Deserialize (std::istream &stream, u32 numAis)
 
int getPlayerSize ()
 

Private Member Functions

void TraceMember (JSTracer *trc)
 
void LoadMetadata (const VfsPath &path, JS::MutableHandleValue out)
 
void PerformComputation ()
 

Static Private Member Functions

static void Trace (JSTracer *trc, void *data)
 

Private Attributes

std::shared_ptr< ScriptInterfacem_ScriptInterface
 
boost::rand48 m_RNG
 
u32 m_TurnNum
 
JS::PersistentRootedValue m_EntityTemplates
 
bool m_HasLoadedEntityTemplates
 
std::map< VfsPath, JS::Heap< JS::Value > > m_PlayerMetadata
 
std::vector< std::shared_ptr< CAIPlayer > > m_Players
 
bool m_HasSharedComponent
 
JS::PersistentRootedValue m_SharedAIObj
 
std::vector< SCommandSetsm_Commands
 
std::set< std::wstring > m_LoadedModules
 
JS::PersistentRootedValue m_GameState
 
Grid< NavcellDatam_PassabilityMap
 
JS::PersistentRootedValue m_PassabilityMapVal
 
Grid< u8m_TerritoryMap
 
JS::PersistentRootedValue m_TerritoryMapVal
 
std::map< std::string, pass_class_tm_NonPathfindingPassClasses
 
std::map< std::string, pass_class_tm_PathfindingPassClasses
 
HierarchicalPathfinder m_HierarchicalPathfinder
 
LongPathfinder m_LongPathfinder
 
bool m_CommandsComputed
 
CTemplateLoader m_TemplateLoader
 

Detailed Description

AI computation orchestator for CCmpAIManager.

Constructor & Destructor Documentation

◆ CAIWorker()

CAIWorker::CAIWorker ( )
inline

◆ ~CAIWorker()

CAIWorker::~CAIWorker ( )
inline

Member Function Documentation

◆ AddPlayer()

bool CAIWorker::AddPlayer ( const std::wstring &  aiName,
player_id_t  player,
u8  difficulty,
const std::wstring &  behavior 
)
inline

◆ ComputePath()

void CAIWorker::ComputePath ( const CFixedVector2D pos,
const CFixedVector2D goal,
pass_class_t  passClass,
std::vector< CFixedVector2D > &  waypoints 
)
inline

◆ ComputePathScript()

JS::Value CAIWorker::ComputePathScript ( JS::HandleValue  position,
JS::HandleValue  goal,
pass_class_t  passClass 
)
inline

◆ Deserialize()

void CAIWorker::Deserialize ( std::istream &  stream,
u32  numAis 
)
inline

◆ DumpImage()

void CAIWorker::DumpImage ( const std::wstring &  name,
const std::vector< u32 > &  data,
u32  w,
u32  h,
u32  max 
)
inline

Debug function for AI scripts to dump 2D array data (e.g.

terrain tile weights).

◆ GetCommands()

void CAIWorker::GetCommands ( std::vector< SCommandSets > &  commands)
inline

◆ getPlayerSize()

int CAIWorker::getPlayerSize ( )
inline

◆ GetTemplate()

CParamNode CAIWorker::GetTemplate ( const std::string &  name)
inline

◆ HasLoadedEntityTemplates()

bool CAIWorker::HasLoadedEntityTemplates ( ) const
inline

◆ Init()

void CAIWorker::Init ( const ScriptInterface simInterface)
inline

◆ LoadEntityTemplates()

void CAIWorker::LoadEntityTemplates ( const std::vector< std::pair< std::string, const CParamNode * > > &  templates)
inline

◆ LoadMetadata()

void CAIWorker::LoadMetadata ( const VfsPath path,
JS::MutableHandleValue  out 
)
inlineprivate

◆ LoadScripts()

bool CAIWorker::LoadScripts ( const std::wstring &  moduleName)
inline

◆ PerformComputation()

void CAIWorker::PerformComputation ( )
inlineprivate

◆ PostCommand()

void CAIWorker::PostCommand ( int  playerid,
JS::HandleValue  cmd 
)
inline

◆ RunGamestateInit()

bool CAIWorker::RunGamestateInit ( const Script::StructuredClone gameState,
const Grid< NavcellData > &  passabilityMap,
const Grid< u8 > &  territoryMap,
const std::map< std::string, pass_class_t > &  nonPathfindingPassClassMasks,
const std::map< std::string, pass_class_t > &  pathfindingPassClassMasks 
)
inline

◆ Serialize()

void CAIWorker::Serialize ( std::ostream &  stream,
bool  isDebug 
)
inline

◆ SerializeState()

void CAIWorker::SerializeState ( ISerializer serializer)
inline

◆ SetRNGSeed()

void CAIWorker::SetRNGSeed ( u32  seed)
inline

◆ StartComputation()

void CAIWorker::StartComputation ( )
inline

◆ Trace()

static void CAIWorker::Trace ( JSTracer *  trc,
void *  data 
)
inlinestaticprivate

◆ TraceMember()

void CAIWorker::TraceMember ( JSTracer *  trc)
inlineprivate

◆ TryLoadSharedComponent()

bool CAIWorker::TryLoadSharedComponent ( )
inline

◆ UpdateGameState()

void CAIWorker::UpdateGameState ( JS::HandleValue  gameState)
inline

◆ UpdatePathfinder()

void CAIWorker::UpdatePathfinder ( const Grid< NavcellData > &  passabilityMap,
bool  globallyDirty,
const Grid< u8 > &  dirtinessGrid,
bool  justDeserialized,
const std::map< std::string, pass_class_t > &  nonPathfindingPassClassMasks,
const std::map< std::string, pass_class_t > &  pathfindingPassClassMasks 
)
inline

◆ UpdateTerritoryMap()

void CAIWorker::UpdateTerritoryMap ( const Grid< u8 > &  territoryMap)
inline

◆ WaitToFinishComputation()

void CAIWorker::WaitToFinishComputation ( )
inline

Member Data Documentation

◆ m_Commands

std::vector<SCommandSets> CAIWorker::m_Commands
private

◆ m_CommandsComputed

bool CAIWorker::m_CommandsComputed
private

◆ m_EntityTemplates

JS::PersistentRootedValue CAIWorker::m_EntityTemplates
private

◆ m_GameState

JS::PersistentRootedValue CAIWorker::m_GameState
private

◆ m_HasLoadedEntityTemplates

bool CAIWorker::m_HasLoadedEntityTemplates
private

◆ m_HasSharedComponent

bool CAIWorker::m_HasSharedComponent
private

◆ m_HierarchicalPathfinder

HierarchicalPathfinder CAIWorker::m_HierarchicalPathfinder
private

◆ m_LoadedModules

std::set<std::wstring> CAIWorker::m_LoadedModules
private

◆ m_LongPathfinder

LongPathfinder CAIWorker::m_LongPathfinder
private

◆ m_NonPathfindingPassClasses

std::map<std::string, pass_class_t> CAIWorker::m_NonPathfindingPassClasses
private

◆ m_PassabilityMap

Grid<NavcellData> CAIWorker::m_PassabilityMap
private

◆ m_PassabilityMapVal

JS::PersistentRootedValue CAIWorker::m_PassabilityMapVal
private

◆ m_PathfindingPassClasses

std::map<std::string, pass_class_t> CAIWorker::m_PathfindingPassClasses
private

◆ m_PlayerMetadata

std::map<VfsPath, JS::Heap<JS::Value> > CAIWorker::m_PlayerMetadata
private

◆ m_Players

std::vector<std::shared_ptr<CAIPlayer> > CAIWorker::m_Players
private

◆ m_RNG

boost::rand48 CAIWorker::m_RNG
private

◆ m_ScriptInterface

std::shared_ptr<ScriptInterface> CAIWorker::m_ScriptInterface
private

◆ m_SharedAIObj

JS::PersistentRootedValue CAIWorker::m_SharedAIObj
private

◆ m_TemplateLoader

CTemplateLoader CAIWorker::m_TemplateLoader
private

◆ m_TerritoryMap

Grid<u8> CAIWorker::m_TerritoryMap
private

◆ m_TerritoryMapVal

JS::PersistentRootedValue CAIWorker::m_TerritoryMapVal
private

◆ m_TurnNum

u32 CAIWorker::m_TurnNum
private

The documentation for this class was generated from the following file: