0ad/source/simulation2/components
wraitii 4df03ed2d2 Run the AI in the same Compartment as the simulation. Let the AI access Sim data.
This is a paradigm change for AI computation.
Historically, the AI was intended to be run in a separate thread from
the simulation. The idea was that slow AI wouldn't stop the renderer
from being smooth.

In that original design, the AI received a copy of the game world and
used that to run its logic. This meant the simulation could safely do
whatever it wanted in the meantime. This copy was done via AIProxy &
AIInterface.

This design ended up having significant flaws:
- The copying impacts the simulation negatively, particularly because
AIProxy subscribes to a lot of messages (sometimes sent exclusively to
it). This time cannot be threaded, and impacts MP games without AIs.
- Copying the data is increasingly difficult. Modifiers are a headache,
LOS is not implemented. Lots of logic is duplicated.

The intended benefits of the design also failed to realise somewhat:
- The AI was never threaded, and in fact, it is probably better to try
and thread Sim + AI from the renderer than just the AI, at which point
threading the AI specifically brings little benefit.

The new design is much simpler and straighforward, but this has some
side-effects:
- The AI can now change the simulation. This can be used for cheating,
or possibly for a tutorial AI.
- The AI runs in the same GC zone as the simulation, which may lead to
more frequent Sim GCs (but overall we might expect a reduction in
temporary objects).
- The AI state was essentially cached, so replacing some functions with
Engine.QueryInterface might be slower. The tradeoff should be balanced
by lower AIProxy computation times.

Future work:
- Threading some specific AI tasks could still be worthwhile, but should
be done in specific worker threads, allowed to run over several turns if
needed.

Technical note: the AI 'global' is in its own Realm, which means name
collisions with the same are not possible.

Other notes:
- The RL Interface uses the AI Interface and thus will gradually lose
some data there. Given that the RL Interface can now request data
however, this should be dine.

Refs #5962, #2370

Differential Revision: https://code.wildfiregames.com/D3769
This was SVN commit r26274.
2022-01-30 13:33:34 +00:00
..
tests Remove leftover terrain-based movement cost code. 2022-01-29 08:22:28 +00:00
CCmpAIManager.cpp Run the AI in the same Compartment as the simulation. Let the AI access Sim data. 2022-01-30 13:33:34 +00:00
CCmpCinemaManager.cpp Fix most Clang 10 Warnings 2020-12-31 14:25:37 +00:00
CCmpCommandQueue.cpp Split off JSON-related function from ScriptInterface, clean up headers. 2021-05-14 10:18:03 +00:00
CCmpDecay.cpp Actually remove trailing tabs from source/. 2016-11-23 14:09:58 +00:00
CCmpFootprint.cpp Fix compilation following 52fcee9c91 2021-02-27 11:12:21 +00:00
CCmpMinimap.cpp Revert 895182cbcb 2021-04-25 13:42:51 +00:00
CCmpMotionBall.cpp Avoid slightly-expensive QueryInterface() calls 2013-09-11 20:41:53 +00:00
CCmpObstruction.cpp Add a simple 'pushing' logic to unit motion to improve movement. 2021-04-02 16:30:59 +00:00
CCmpObstructionManager.cpp Further reduce usage of TERRAIN_TILE_SIZE in non-terrain components 2021-05-02 17:40:00 +00:00
CCmpOverlayRenderer.cpp Fix documentation of non system component. 2017-03-24 07:09:28 +00:00
CCmpOwnership.cpp Bump year number of files changed this year in the license headers. 2017-05-01 14:28:22 +00:00
CCmpParticleManager.cpp Splits CRenderer part about scene to CSceneRenderer. 2022-01-04 13:29:01 +00:00
CCmpPathfinder.cpp Thread the pathfinder computations using the task manager. 2021-06-03 16:21:28 +00:00
CCmpPathfinder_Common.h Thread the pathfinder computations using the task manager. 2021-06-03 16:21:28 +00:00
CCmpPosition.cpp ParamNode: switch to utf8, ToXML -> ToXMLString, test tweak, PCH tweak 2021-04-11 09:23:10 +00:00
CCmpProjectileManager.cpp Fix units changing appearance when switching animation. 2021-07-31 17:55:10 +00:00
CCmpRallyPointRenderer.cpp Removes unused and outdated includes, replaces some includes by forward declarations. 2021-05-15 17:27:01 +00:00
CCmpRallyPointRenderer.h Removes unused and outdated includes, replaces some includes by forward declarations. 2021-05-15 17:27:01 +00:00
CCmpRangeManager.cpp Further reduce usage of TERRAIN_TILE_SIZE in non-terrain components 2021-05-02 17:40:00 +00:00
CCmpRangeOverlayRenderer.cpp Refactors smart pointers creation, reduces code duplication and improves exception safety. 2021-02-13 23:53:40 +00:00
CCmpSelectable.cpp Adds line drawing to DebugRenderer. 2021-04-25 20:48:44 +00:00
CCmpSoundManager.cpp Notify players with a sound when a player is defeated 2020-11-18 09:14:08 +00:00
CCmpTemplateManager.cpp ParamNode: switch to utf8, ToXML -> ToXMLString, test tweak, PCH tweak 2021-04-11 09:23:10 +00:00
CCmpTerrain.cpp Splits CRenderer part about scene to CSceneRenderer. 2022-01-04 13:29:01 +00:00
CCmpTerritoryInfluence.cpp Allow boolean and u16 modifications for C++ 2020-12-11 14:07:48 +00:00
CCmpTerritoryManager.cpp Further reduce usage of TERRAIN_TILE_SIZE in non-terrain components 2021-05-02 17:40:00 +00:00
CCmpTest.cpp Remove some unused Profiler.h and CLogger.h includes. 2019-09-07 13:35:45 +00:00
CCmpUnitMotion.h Remove leftover terrain-based movement cost code. 2022-01-29 08:22:28 +00:00
CCmpUnitMotion_System.cpp UnitMotion pushing improvements 2022-01-24 15:36:13 +00:00
CCmpUnitMotionManager.h UnitMotion pushing improvements 2022-01-24 15:36:13 +00:00
CCmpUnitRenderer.cpp Moves Frustum from graphics to maths to more related geometric primitives like bounding ones. 2021-03-29 17:28:13 +00:00
CCmpVision.cpp Add support for const methods in components and make those that can be const const. 2017-01-20 02:25:19 +00:00
CCmpVisualActor.cpp Call SetTerrainDirty on CModelAbstract without going through CmpVisualActor 2022-01-29 08:28:04 +00:00
CCmpWaterManager.cpp Splits CRenderer part about scene to CSceneRenderer. 2022-01-04 13:29:01 +00:00
ICmpAIInterface.cpp Employ some variadic macros to make some of the C++ -> JS function calling code nicer. 2017-01-28 23:37:15 +00:00
ICmpAIInterface.h SpiderMonkey 31 upgrade 2015-01-24 14:46:52 +00:00
ICmpAIManager.cpp Split off JSON-related function from ScriptInterface, clean up headers. 2021-05-14 10:18:03 +00:00
ICmpAIManager.h Choose AI behavior in gamesetup 2017-12-20 22:02:15 +00:00
ICmpAttack.cpp Do not hardcode attacktypes in the engine/Atlas 2020-10-10 15:12:17 +00:00
ICmpAttack.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
ICmpCinemaManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpCinemaManager.h Draw paths only when cinematics isn't playing. Patch by Vladislav. 2017-05-08 04:02:33 +00:00
ICmpCommandQueue.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpCommandQueue.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
ICmpDecay.cpp # Add corpse decay and building collapse. 2010-08-01 17:38:01 +00:00
ICmpDecay.h # Add corpse decay and building collapse. 2010-08-01 17:38:01 +00:00
ICmpFogging.cpp Reduce drastically the number of mirages by making fogging conditional: entities will be miraged only if their health/resource amount is modified, or if they have a non-gaia owner. 2015-02-07 15:48:32 +00:00
ICmpFogging.h Reduce drastically the number of mirages by making fogging conditional: entities will be miraged only if their health/resource amount is modified, or if they have a non-gaia owner. 2015-02-07 15:48:32 +00:00
ICmpFootprint.cpp Split JS conversions from ScriptInterface. 2021-05-13 09:43:33 +00:00
ICmpFootprint.h Add support for const methods in components and make those that can be const const. 2017-01-20 02:25:19 +00:00
ICmpGarrisonHolder.cpp Fix some C++-style notes from b5df81af76. 2021-01-11 11:26:31 +00:00
ICmpGarrisonHolder.h Fix some C++-style notes from b5df81af76. 2021-01-11 11:26:31 +00:00
ICmpGuiInterface.cpp Employ some variadic macros to make some of the C++ -> JS function calling code nicer. 2017-01-28 23:37:15 +00:00
ICmpGuiInterface.h Removes unused forward declarations of class and struct. 2021-09-08 19:43:01 +00:00
ICmpIdentity.cpp Replace {gender} by {phenotype} and support this tag in VisualActor. 2019-08-01 19:14:40 +00:00
ICmpIdentity.h Replace {gender} by {phenotype} and support this tag in VisualActor. 2019-08-01 19:14:40 +00:00
ICmpMinimap.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpMinimap.h Revert 895182cbcb 2021-04-25 13:42:51 +00:00
ICmpMirage.cpp Hide changes to buildings in the fog-of-war. 2014-08-04 22:49:19 +00:00
ICmpMirage.h Hide changes to buildings in the fog-of-war. 2014-08-04 22:49:19 +00:00
ICmpMotion.cpp
ICmpMotion.h
ICmpObstruction.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpObstruction.h Add a simple 'pushing' logic to unit motion to improve movement. 2021-04-02 16:30:59 +00:00
ICmpObstructionManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpObstructionManager.h Add a simple 'pushing' logic to unit motion to improve movement. 2021-04-02 16:30:59 +00:00
ICmpOverlayRenderer.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpOverlayRenderer.h Use const T& for parameters of some types in script-exposed native functions 2016-01-23 15:17:56 +00:00
ICmpOwnership.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpOwnership.h Add support for const methods in components and make those that can be const const. 2017-01-20 02:25:19 +00:00
ICmpParticleManager.cpp Set svn:eol-style=native, fix some inconsistent line endings 2013-12-06 00:42:50 +00:00
ICmpParticleManager.h Set svn:eol-style=native, fix some inconsistent line endings 2013-12-06 00:42:50 +00:00
ICmpPathfinder.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpPathfinder.h Removes unused and outdated includes, replaces some includes by forward declarations. 2021-05-15 17:27:01 +00:00
ICmpPlayer.cpp Split CColor from Shapes. 2019-01-13 15:38:41 +00:00
ICmpPlayer.h Diplomacy Colors 2018-02-03 14:17:31 +00:00
ICmpPlayerManager.cpp # Add new renderer mode based on GL_ARB_fragment_program. 2011-03-26 20:17:21 +00:00
ICmpPlayerManager.h # Add new renderer mode based on GL_ARB_fragment_program. 2011-03-26 20:17:21 +00:00
ICmpPosition.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpPosition.h Fix target height computation when launching projectiles. 2021-01-22 18:16:13 +00:00
ICmpProjectileManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpProjectileManager.h Let the template define the actor used for the projectile. Also let projectiles have an impact animation (such as an explosion). 2017-12-23 09:27:19 +00:00
ICmpRallyPoint.cpp Spawn units in rally point direction 2018-02-07 20:58:07 +00:00
ICmpRallyPoint.h Spawn units in rally point direction 2018-02-07 20:58:07 +00:00
ICmpRallyPointRenderer.cpp Removes unused forward declarations of class and struct. 2021-09-08 19:43:01 +00:00
ICmpRallyPointRenderer.h Spawn units in rally point direction 2018-02-07 20:58:07 +00:00
ICmpRangeManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpRangeManager.h Fix no-pch build. Potentially fixes bb49fbe793, 0198942a79, 34b1920e7b, 8b08f4ae7a 0dbf417171, 3af1fc64d2, 5fbdbaa3bc, 6fbf036ae4. 2021-05-12 13:48:55 +00:00
ICmpRangeOverlayRenderer.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpRangeOverlayRenderer.h Diplomacy Colors 2018-02-03 14:17:31 +00:00
ICmpSelectable.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpSelectable.h Diplomacy Colors 2018-02-03 14:17:31 +00:00
ICmpSettlement.cpp # Initial support for territories 2011-07-20 19:48:06 +00:00
ICmpSettlement.h # Initial support for territories 2011-07-20 19:48:06 +00:00
ICmpSound.cpp Fix units not being able to play sounds when walking and running 2018-02-24 18:13:03 +00:00
ICmpSound.h Fix units not being able to play sounds when walking and running 2018-02-24 18:13:03 +00:00
ICmpSoundManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpSoundManager.h Fix building without precompiled headers. 2020-11-18 11:35:36 +00:00
ICmpTemplateManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpTemplateManager.h AIManager: loads only the used templates when starting (or deserializing) a game 2017-11-24 19:13:28 +00:00
ICmpTerrain.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpTerrain.h Replace hardcoded copies of a C++ simulation constant in JS used to compute the mapsize with a call to a new getter in the C++ interface. 2017-05-31 16:43:57 +00:00
ICmpTerritoryDecayManager.cpp Add a TerritoryDecayManager component to update territoryMap with the blinking state when territories are recomputed. That's needed by the AI which was up to now not aware of blinking cells. 2017-10-07 08:42:39 +00:00
ICmpTerritoryDecayManager.h Add a TerritoryDecayManager component to update territoryMap with the blinking state when territories are recomputed. That's needed by the AI which was up to now not aware of blinking cells. 2017-10-07 08:42:39 +00:00
ICmpTerritoryInfluence.cpp # Initial support for territories 2011-07-20 19:48:06 +00:00
ICmpTerritoryInfluence.h Add support for const methods in components and make those that can be const const. 2017-01-20 02:25:19 +00:00
ICmpTerritoryManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpTerritoryManager.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
ICmpTest.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpTest.h
ICmpTurretHolder.cpp Allow to specify subunits on creation. 2021-04-05 05:22:25 +00:00
ICmpTurretHolder.h Fix some C++-style notes from b5df81af76. 2021-01-11 11:26:31 +00:00
ICmpUnitMotion.cpp Add accelerations in unit movement. 2021-10-09 21:31:11 +00:00
ICmpUnitMotion.h Add accelerations in unit movement. 2021-10-09 21:31:11 +00:00
ICmpUnitMotionManager.cpp Implement a Motion Manager around UnitMotion. 2021-03-17 17:04:51 +00:00
ICmpUnitMotionManager.h Moddability for pushing: radius in XML, allow deactivating globally/some templates. 2021-06-02 17:36:32 +00:00
ICmpUnitRenderer.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpUnitRenderer.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
ICmpUnknownScript.cpp
ICmpUnknownScript.h
ICmpValueModificationManager.cpp Allow boolean and u16 modifications for C++ 2020-12-11 14:07:48 +00:00
ICmpValueModificationManager.h Allow boolean and u16 modifications for C++ 2020-12-11 14:07:48 +00:00
ICmpVisibility.cpp RangeManager: Grid for 2D array, enum cleanups. 2020-06-13 09:05:40 +00:00
ICmpVisibility.h RangeManager: Grid for 2D array, enum cleanups. 2020-06-13 09:05:40 +00:00
ICmpVision.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpVision.h Add support for const methods in components and make those that can be const const. 2017-01-20 02:25:19 +00:00
ICmpVisual.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpVisual.h Implement quality levels for actors & corresponding setting. 2021-04-08 07:22:24 +00:00
ICmpWaterManager.cpp Migrate DEFINE_INTERFACE_METHOD_* to the ScriptFunction wrappers. 2021-05-01 08:01:30 +00:00
ICmpWaterManager.h Replaces UNICODE characters in the code by consistent ASCII characters. 2021-01-15 10:07:36 +00:00