![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Player AI interface. More...
#include "precompiled.h"#include "ICmpAIManager.h"#include "graphics/HeightMipmap.h"#include "lib/alignment.h"#include "lib/allocators/shared_ptr.h"#include "lib/code_annotation.h"#include "lib/debug.h"#include "lib/file/vfs/vfs_path.h"#include "lib/file/vfs/vfs_util.h"#include "lib/os_path.h"#include "lib/path.h"#include "lib/tex/tex.h"#include "lib/utf8.h"#include "maths/FixedVector2D.h"#include "ps/CLogger.h"#include "ps/Filesystem.h"#include "ps/Profile.h"#include "ps/Profiler2.h"#include "ps/TemplateLoader.h"#include "ps/Util.h"#include "ps/scripting/JSInterface_VFS.h"#include "scriptinterface/FunctionWrapper.h"#include "scriptinterface/JSON.h"#include "scriptinterface/ModuleLoader.h"#include "scriptinterface/Object.h"#include "scriptinterface/Context.h"#include "scriptinterface/Conversions.h"#include "scriptinterface/Interface.h"#include "scriptinterface/Request.h"#include "scriptinterface/StructuredClone.h"#include "simulation2/components/ICmpAIInterface.h"#include "simulation2/components/ICmpCommandQueue.h"#include "simulation2/components/ICmpPathfinder.h"#include "simulation2/components/ICmpRangeManager.h"#include "simulation2/components/ICmpTemplateManager.h"#include "simulation2/components/ICmpTerritoryManager.h"#include "simulation2/helpers/Grid.h"#include "simulation2/helpers/HierarchicalPathfinder.h"#include "simulation2/helpers/LongPathfinder.h"#include "simulation2/helpers/PathGoal.h"#include "simulation2/helpers/Pathfinding.h"#include "simulation2/helpers/Player.h"#include "simulation2/serialization/DebugSerializer.h"#include "simulation2/serialization/SerializeTemplates.h"#include "simulation2/serialization/SerializedTypes.h"#include "simulation2/serialization/StdDeserializer.h"#include "simulation2/serialization/StdSerializer.h"#include "simulation2/system/Component.h"#include <boost/random/linear_congruential.hpp>#include <cstring>#include <js/Array.h>#include <js/GCAPI.h>#include <js/GCVector.h>#include <js/PropertyAndElement.h>#include <js/RootingAPI.h>#include <js/TracingAPI.h>#include <js/TypeDecls.h>#include <js/Value.h>#include <js/experimental/TypedData.h>#include <map>#include <memory>#include <set>#include <sstream>#include <string>#include <tuple>#include <utility>#include <vector>Classes | |
| class | CAIWorker |
| AI computation orchestator for CCmpAIManager. More... | |
| class | CAIWorker::CAIPlayer |
| struct | CAIWorker::SCommandSets |
| class | CCmpAIManager |
| Implementation of ICmpAIManager. More... | |
Macros | |
| #define | REGISTER_FUNC_NAME(func, name) Script::Function::Register<&CAIWorker::func, Script::Interface::ObjectFromCBData<CAIWorker>>(rq, name); |
Functions | |
| void | QuitEngine (int exitStatus) |
Player AI interface.
AI is primarily scripted, and the CCmpAIManager component defined here takes care of managing all the scripts.
The original idea was to run CAIWorker in a separate thread to prevent slow AIs from impacting framerate. However, copying the game-state every turn proved difficult and rather slow itself (and isn't threadable, obviously). For these reasons, the design was changed to a single-thread, same-compartment, different-realm design. The AI can therefore directly use the simulation data via the 'Sim' & 'SimEngine' globals. As a result, a lof of the code is still designed to be "thread-ready", but this no longer matters.
TODO: despite the above, it would still be useful to allow the AI to run tasks asynchronously (and off-thread). This could be implemented by having a separate JS runtime in a different thread, that runs tasks and returns after a distinct # of simulation turns (to maintain determinism).
Note also that the RL Interface, by default, uses the 'AI representation'. This representation, alimented by the JS AIInterface/AIProxy tandem, is likely to grow smaller over time as the AI uses more sim data directly.
| #define REGISTER_FUNC_NAME | ( | func, | |
| name | |||
| ) | Script::Function::Register<&CAIWorker::func, Script::Interface::ObjectFromCBData<CAIWorker>>(rq, name); |
| void QuitEngine | ( | int | exitStatus | ) |