Remove AI interface and fallback stage
This removes the C++ common interface intended for creating new AIs. Anyone wishing to create a new AI written in C++ should now implement it as a custom stage instead. This commit also removes the C++ implementation of the Idle AI (but leaves the WML definition of it, which is based on the composite AI) and the fallback stage which was intended to fall back to other C++ AI algorithms.
This commit is contained in:
parent
5ac2ef62ce
commit
6c525a9d3f
23 changed files with 98 additions and 841 deletions
|
@ -154,8 +154,6 @@
|
|||
<Unit filename="../../src/ai/configuration.hpp" />
|
||||
<Unit filename="../../src/ai/contexts.cpp" />
|
||||
<Unit filename="../../src/ai/contexts.hpp" />
|
||||
<Unit filename="../../src/ai/default/ai.cpp" />
|
||||
<Unit filename="../../src/ai/default/ai.hpp" />
|
||||
<Unit filename="../../src/ai/default/attack.cpp" />
|
||||
<Unit filename="../../src/ai/default/contexts.cpp" />
|
||||
<Unit filename="../../src/ai/default/contexts.hpp" />
|
||||
|
@ -175,8 +173,6 @@
|
|||
<Unit filename="../../src/ai/game_info.hpp" />
|
||||
<Unit filename="../../src/ai/gamestate_observer.cpp" />
|
||||
<Unit filename="../../src/ai/gamestate_observer.hpp" />
|
||||
<Unit filename="../../src/ai/interface.cpp" />
|
||||
<Unit filename="../../src/ai/interface.hpp" />
|
||||
<Unit filename="../../src/ai/lua/core.cpp" />
|
||||
<Unit filename="../../src/ai/lua/core.hpp" />
|
||||
<Unit filename="../../src/ai/lua/lua_object.cpp" />
|
||||
|
@ -203,8 +199,6 @@
|
|||
<Unit filename="../../src/ai/testing/ca_testing_move_to_targets.hpp" />
|
||||
<Unit filename="../../src/ai/testing/ca_testing_recruitment.cpp" />
|
||||
<Unit filename="../../src/ai/testing/ca_testing_recruitment.hpp" />
|
||||
<Unit filename="../../src/ai/testing/stage_fallback.cpp" />
|
||||
<Unit filename="../../src/ai/testing/stage_fallback.hpp" />
|
||||
<Unit filename="../../src/ai/testing/stage_rca.cpp" />
|
||||
<Unit filename="../../src/ai/testing/stage_rca.hpp" />
|
||||
<Unit filename="../../src/ai/testing/stage_sf_with_rca.cpp" />
|
||||
|
|
|
@ -1156,62 +1156,6 @@
|
|||
RelativePath="..\..\src\ai\gamestate_observer.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\interface.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug_with_VLD|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Test_Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Test_Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="ReleaseDEBUG|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\interface.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\manager.cpp"
|
||||
>
|
||||
|
@ -2067,62 +2011,6 @@
|
|||
<Filter
|
||||
Name="default"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\default\ai.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\default\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\default\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug_with_VLD|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\default\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Test_Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\default\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Test_Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\default\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="ReleaseDEBUG|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\default\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\default\ai.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\default\attack.cpp"
|
||||
>
|
||||
|
@ -2515,62 +2403,6 @@
|
|||
RelativePath="..\..\src\ai\testing\ca_testing_recruitment.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\testing\stage_fallback.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\testing\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\testing\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug_with_VLD|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\testing\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Test_Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\testing\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Test_Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\testing\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="ReleaseDEBUG|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\ai\testing\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\testing\stage_fallback.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\ai\testing\stage_rca.cpp"
|
||||
>
|
||||
|
|
|
@ -236,12 +236,10 @@
|
|||
B54AC6850FEA9C4A006F6FBD /* room_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC67D0FEA9C4A006F6FBD /* room_manager.cpp */; };
|
||||
B54AC6970FEA9E8F006F6FBD /* actions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC68D0FEA9E8F006F6FBD /* actions.cpp */; };
|
||||
B54AC6980FEA9E8F006F6FBD /* configuration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC68F0FEA9E8F006F6FBD /* configuration.cpp */; };
|
||||
B54AC6990FEA9E8F006F6FBD /* interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6910FEA9E8F006F6FBD /* interface.cpp */; };
|
||||
B54AC69A0FEA9E8F006F6FBD /* manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6930FEA9E8F006F6FBD /* manager.cpp */; };
|
||||
B54AC69B0FEA9E8F006F6FBD /* registry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6950FEA9E8F006F6FBD /* registry.cpp */; };
|
||||
B54AC69C0FEA9E8F006F6FBD /* actions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC68D0FEA9E8F006F6FBD /* actions.cpp */; };
|
||||
B54AC69D0FEA9E8F006F6FBD /* configuration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC68F0FEA9E8F006F6FBD /* configuration.cpp */; };
|
||||
B54AC69E0FEA9E8F006F6FBD /* interface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6910FEA9E8F006F6FBD /* interface.cpp */; };
|
||||
B54AC69F0FEA9E8F006F6FBD /* manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6930FEA9E8F006F6FBD /* manager.cpp */; };
|
||||
B54AC6A00FEA9E8F006F6FBD /* registry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6950FEA9E8F006F6FBD /* registry.cpp */; };
|
||||
B54AC6C70FEA9EB5006F6FBD /* ai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6A40FEA9EB5006F6FBD /* ai.cpp */; };
|
||||
|
@ -250,13 +248,11 @@
|
|||
B54AC6CA0FEA9EB5006F6FBD /* engine_default.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6AA0FEA9EB5006F6FBD /* engine_default.cpp */; };
|
||||
B54AC6CB0FEA9EB5006F6FBD /* rca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6AC0FEA9EB5006F6FBD /* rca.cpp */; };
|
||||
B54AC6CC0FEA9EB5006F6FBD /* stage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6AE0FEA9EB5006F6FBD /* stage.cpp */; };
|
||||
B54AC6CD0FEA9EB5006F6FBD /* ai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6B10FEA9EB5006F6FBD /* ai.cpp */; };
|
||||
B54AC6CE0FEA9EB5006F6FBD /* attack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6B30FEA9EB5006F6FBD /* attack.cpp */; };
|
||||
B54AC6CF0FEA9EB5006F6FBD /* contexts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6B40FEA9EB5006F6FBD /* contexts.cpp */; };
|
||||
B54AC6D30FEA9EB5006F6FBD /* ai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6BC0FEA9EB5006F6FBD /* ai.cpp */; };
|
||||
B54AC6D40FEA9EB5006F6FBD /* candidates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6BE0FEA9EB5006F6FBD /* candidates.cpp */; };
|
||||
B54AC6D50FEA9EB5006F6FBD /* ca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6C10FEA9EB5006F6FBD /* ca.cpp */; };
|
||||
B54AC6D60FEA9EB5006F6FBD /* stage_fallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6C30FEA9EB5006F6FBD /* stage_fallback.cpp */; };
|
||||
B54AC6D70FEA9EB5006F6FBD /* stage_rca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6C50FEA9EB5006F6FBD /* stage_rca.cpp */; };
|
||||
B54AC6D80FEA9EB5006F6FBD /* ai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6A40FEA9EB5006F6FBD /* ai.cpp */; };
|
||||
B54AC6D90FEA9EB5006F6FBD /* contexts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6A60FEA9EB5006F6FBD /* contexts.cpp */; };
|
||||
|
@ -264,13 +260,11 @@
|
|||
B54AC6DB0FEA9EB5006F6FBD /* engine_default.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6AA0FEA9EB5006F6FBD /* engine_default.cpp */; };
|
||||
B54AC6DC0FEA9EB5006F6FBD /* rca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6AC0FEA9EB5006F6FBD /* rca.cpp */; };
|
||||
B54AC6DD0FEA9EB5006F6FBD /* stage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6AE0FEA9EB5006F6FBD /* stage.cpp */; };
|
||||
B54AC6DE0FEA9EB5006F6FBD /* ai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6B10FEA9EB5006F6FBD /* ai.cpp */; };
|
||||
B54AC6DF0FEA9EB5006F6FBD /* attack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6B30FEA9EB5006F6FBD /* attack.cpp */; };
|
||||
B54AC6E00FEA9EB5006F6FBD /* contexts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6B40FEA9EB5006F6FBD /* contexts.cpp */; };
|
||||
B54AC6E40FEA9EB5006F6FBD /* ai.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6BC0FEA9EB5006F6FBD /* ai.cpp */; };
|
||||
B54AC6E50FEA9EB5006F6FBD /* candidates.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6BE0FEA9EB5006F6FBD /* candidates.cpp */; };
|
||||
B54AC6E60FEA9EB5006F6FBD /* ca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6C10FEA9EB5006F6FBD /* ca.cpp */; };
|
||||
B54AC6E70FEA9EB5006F6FBD /* stage_fallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6C30FEA9EB5006F6FBD /* stage_fallback.cpp */; };
|
||||
B54AC6E80FEA9EB5006F6FBD /* stage_rca.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6C50FEA9EB5006F6FBD /* stage_rca.cpp */; };
|
||||
B54AC6F30FEA9F92006F6FBD /* lobby.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6EF0FEA9F92006F6FBD /* lobby.cpp */; };
|
||||
B54AC6F40FEA9F92006F6FBD /* transient_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B54AC6F10FEA9F92006F6FBD /* transient_message.cpp */; };
|
||||
|
@ -1486,8 +1480,6 @@
|
|||
B54AC68E0FEA9E8F006F6FBD /* actions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = actions.hpp; sourceTree = "<group>"; };
|
||||
B54AC68F0FEA9E8F006F6FBD /* configuration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = configuration.cpp; sourceTree = "<group>"; };
|
||||
B54AC6900FEA9E8F006F6FBD /* configuration.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = configuration.hpp; sourceTree = "<group>"; };
|
||||
B54AC6910FEA9E8F006F6FBD /* interface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = interface.cpp; sourceTree = "<group>"; };
|
||||
B54AC6920FEA9E8F006F6FBD /* interface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = interface.hpp; sourceTree = "<group>"; };
|
||||
B54AC6930FEA9E8F006F6FBD /* manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manager.cpp; sourceTree = "<group>"; };
|
||||
B54AC6940FEA9E8F006F6FBD /* manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = manager.hpp; sourceTree = "<group>"; };
|
||||
B54AC6950FEA9E8F006F6FBD /* registry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = registry.cpp; sourceTree = "<group>"; };
|
||||
|
@ -1504,8 +1496,6 @@
|
|||
B54AC6AD0FEA9EB5006F6FBD /* rca.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rca.hpp; sourceTree = "<group>"; };
|
||||
B54AC6AE0FEA9EB5006F6FBD /* stage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stage.cpp; sourceTree = "<group>"; };
|
||||
B54AC6AF0FEA9EB5006F6FBD /* stage.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stage.hpp; sourceTree = "<group>"; };
|
||||
B54AC6B10FEA9EB5006F6FBD /* ai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ai.cpp; sourceTree = "<group>"; };
|
||||
B54AC6B20FEA9EB5006F6FBD /* ai.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ai.hpp; sourceTree = "<group>"; };
|
||||
B54AC6B30FEA9EB5006F6FBD /* attack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = attack.cpp; sourceTree = "<group>"; };
|
||||
B54AC6B40FEA9EB5006F6FBD /* contexts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = contexts.cpp; sourceTree = "<group>"; };
|
||||
B54AC6B50FEA9EB5006F6FBD /* contexts.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = contexts.hpp; sourceTree = "<group>"; };
|
||||
|
@ -1515,8 +1505,6 @@
|
|||
B54AC6BF0FEA9EB5006F6FBD /* candidates.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = candidates.hpp; sourceTree = "<group>"; };
|
||||
B54AC6C10FEA9EB5006F6FBD /* ca.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ca.cpp; sourceTree = "<group>"; };
|
||||
B54AC6C20FEA9EB5006F6FBD /* ca.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ca.hpp; sourceTree = "<group>"; };
|
||||
B54AC6C30FEA9EB5006F6FBD /* stage_fallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stage_fallback.cpp; sourceTree = "<group>"; };
|
||||
B54AC6C40FEA9EB5006F6FBD /* stage_fallback.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stage_fallback.hpp; sourceTree = "<group>"; };
|
||||
B54AC6C50FEA9EB5006F6FBD /* stage_rca.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = stage_rca.cpp; sourceTree = "<group>"; };
|
||||
B54AC6C60FEA9EB5006F6FBD /* stage_rca.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = stage_rca.hpp; sourceTree = "<group>"; };
|
||||
B54AC6EF0FEA9F92006F6FBD /* lobby.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lobby.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3499,8 +3487,6 @@
|
|||
B54AC6B00FEA9EB5006F6FBD /* default */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B54AC6B10FEA9EB5006F6FBD /* ai.cpp */,
|
||||
B54AC6B20FEA9EB5006F6FBD /* ai.hpp */,
|
||||
B54AC6B30FEA9EB5006F6FBD /* attack.cpp */,
|
||||
B54AC6B40FEA9EB5006F6FBD /* contexts.cpp */,
|
||||
B54AC6B50FEA9EB5006F6FBD /* contexts.hpp */,
|
||||
|
@ -3540,8 +3526,6 @@
|
|||
B5CE46FC12A041CE00D665EE /* ca_testing_recruitment.hpp */,
|
||||
B54AC6C10FEA9EB5006F6FBD /* ca.cpp */,
|
||||
B54AC6C20FEA9EB5006F6FBD /* ca.hpp */,
|
||||
B54AC6C30FEA9EB5006F6FBD /* stage_fallback.cpp */,
|
||||
B54AC6C40FEA9EB5006F6FBD /* stage_fallback.hpp */,
|
||||
B54AC6C50FEA9EB5006F6FBD /* stage_rca.cpp */,
|
||||
B54AC6C60FEA9EB5006F6FBD /* stage_rca.hpp */,
|
||||
EC4E3B1E19B2D8480049CBD7 /* stage_sf_with_rca.cpp */,
|
||||
|
@ -3755,8 +3739,6 @@
|
|||
B597EBE20FC082AB00CE81F5 /* game_info.hpp */,
|
||||
B55BE03811234AC700154E6C /* gamestate_observer.cpp */,
|
||||
B55BE03911234AC700154E6C /* gamestate_observer.hpp */,
|
||||
B54AC6910FEA9E8F006F6FBD /* interface.cpp */,
|
||||
B54AC6920FEA9E8F006F6FBD /* interface.hpp */,
|
||||
B52EE9A3121363EB00CFBDAB /* lua */,
|
||||
B54AC6930FEA9E8F006F6FBD /* manager.cpp */,
|
||||
B54AC6940FEA9E8F006F6FBD /* manager.hpp */,
|
||||
|
@ -4369,7 +4351,6 @@
|
|||
B514C70B0F5450CC00E273F0 /* list.cpp in Sources */,
|
||||
EC2F601E1A0490970018C9D6 /* advanced_graphics_options.cpp in Sources */,
|
||||
B54AC6D80FEA9EB5006F6FBD /* ai.cpp in Sources */,
|
||||
B54AC6DE0FEA9EB5006F6FBD /* ai.cpp in Sources */,
|
||||
B54AC6E40FEA9EB5006F6FBD /* ai.cpp in Sources */,
|
||||
B5599B830EC62181008DD061 /* animated_game.cpp in Sources */,
|
||||
F40A13BC1A3A88BA00C4D071 /* apple_notification.mm in Sources */,
|
||||
|
@ -4550,7 +4531,6 @@
|
|||
F419A2C314F5BCFE002F9ADC /* info.cpp in Sources */,
|
||||
62579C7E1573E70C003089D5 /* instance.cpp in Sources */,
|
||||
B597EC150FC0835900CE81F5 /* interface.cpp in Sources */,
|
||||
B54AC69E0FEA9E8F006F6FBD /* interface.cpp in Sources */,
|
||||
B5599B350EC62181008DD061 /* intro.cpp in Sources */,
|
||||
62114CC91750B9AF00CA42C7 /* item_palette.cpp in Sources */,
|
||||
49DA0D2E13550E9B000AFEBD /* iterator.cpp in Sources */,
|
||||
|
@ -4769,7 +4749,6 @@
|
|||
F480CD4B14035038007175D6 /* sourceparser.cpp in Sources */,
|
||||
B5A9BD6D0ECA805A002BE442 /* spacer.cpp in Sources */,
|
||||
B508D2161001560100B12852 /* stacked_widget.cpp in Sources */,
|
||||
B54AC6E70FEA9EB5006F6FBD /* stage_fallback.cpp in Sources */,
|
||||
B54AC6E80FEA9EB5006F6FBD /* stage_rca.cpp in Sources */,
|
||||
EC4E3B2019B2D8480049CBD7 /* stage_sf_with_rca.cpp in Sources */,
|
||||
B59F96E0103478DE00A57C1A /* stage_side_formulas.cpp in Sources */,
|
||||
|
@ -4899,7 +4878,6 @@
|
|||
B597C5B70FACD6CA00CE81F5 /* connect.cpp in Sources */,
|
||||
B597C5C00FACD6CA00CE81F5 /* list.cpp in Sources */,
|
||||
B54AC6C70FEA9EB5006F6FBD /* ai.cpp in Sources */,
|
||||
B54AC6CD0FEA9EB5006F6FBD /* ai.cpp in Sources */,
|
||||
B54AC6D30FEA9EB5006F6FBD /* ai.cpp in Sources */,
|
||||
B597C5AD0FACD6CA00CE81F5 /* animated_game.cpp in Sources */,
|
||||
B52EE8DF121359A600CFBDAB /* arrow.cpp in Sources */,
|
||||
|
@ -4995,7 +4973,6 @@
|
|||
B597C5BC0FACD6CA00CE81F5 /* image.cpp in Sources */,
|
||||
B597C5BF0FACD6CA00CE81F5 /* image.cpp in Sources */,
|
||||
B597EC190FC0835900CE81F5 /* interface.cpp in Sources */,
|
||||
B54AC6990FEA9E8F006F6FBD /* interface.cpp in Sources */,
|
||||
B597C5830FACD6CA00CE81F5 /* intro.cpp in Sources */,
|
||||
B597C5E10FACD6CA00CE81F5 /* key.cpp in Sources */,
|
||||
B597C57E0FACD6CA00CE81F5 /* label.cpp in Sources */,
|
||||
|
@ -5095,7 +5072,6 @@
|
|||
B597C58C0FACD6CA00CE81F5 /* soundsource.cpp in Sources */,
|
||||
B597C54A0FACD6CA00CE81F5 /* spacer.cpp in Sources */,
|
||||
B508D2171001560100B12852 /* stacked_widget.cpp in Sources */,
|
||||
B54AC6D60FEA9EB5006F6FBD /* stage_fallback.cpp in Sources */,
|
||||
B54AC6D70FEA9EB5006F6FBD /* stage_rca.cpp in Sources */,
|
||||
B59F96E3103478DE00A57C1A /* stage_side_formulas.cpp in Sources */,
|
||||
B59F96E4103478DE00A57C1A /* stage_unit_formulas.cpp in Sources */,
|
||||
|
|
|
@ -699,7 +699,6 @@ set(wesnoth-main_SRC
|
|||
ai/composite/stage.cpp
|
||||
ai/configuration.cpp
|
||||
ai/contexts.cpp
|
||||
ai/default/ai.cpp
|
||||
ai/default/attack.cpp
|
||||
ai/default/contexts.cpp
|
||||
ai/formula/ai.cpp
|
||||
|
@ -710,7 +709,6 @@ set(wesnoth-main_SRC
|
|||
ai/formula/stage_unit_formulas.cpp
|
||||
ai/game_info.cpp
|
||||
ai/gamestate_observer.cpp
|
||||
ai/interface.cpp
|
||||
ai/lua/core.cpp
|
||||
ai/lua/lua_object.cpp
|
||||
ai/lua/unit_advancements_aspect.cpp
|
||||
|
@ -724,7 +722,6 @@ set(wesnoth-main_SRC
|
|||
ai/testing/ca_global_fallback.cpp
|
||||
ai/testing/ca_testing_move_to_targets.cpp
|
||||
ai/testing/ca_testing_recruitment.cpp
|
||||
ai/testing/stage_fallback.cpp
|
||||
ai/testing/stage_rca.cpp
|
||||
ai/testing/stage_sf_with_rca.cpp
|
||||
animated_game.cpp
|
||||
|
|
|
@ -224,7 +224,6 @@ wesnoth_sources = Split("""
|
|||
ai/composite/stage.cpp
|
||||
ai/configuration.cpp
|
||||
ai/contexts.cpp
|
||||
ai/default/ai.cpp
|
||||
ai/default/attack.cpp
|
||||
ai/default/contexts.cpp
|
||||
ai/formula/ai.cpp
|
||||
|
@ -235,7 +234,6 @@ wesnoth_sources = Split("""
|
|||
ai/formula/stage_unit_formulas.cpp
|
||||
ai/game_info.cpp
|
||||
ai/gamestate_observer.cpp
|
||||
ai/interface.cpp
|
||||
ai/lua/core.cpp
|
||||
ai/lua/lua_object.cpp
|
||||
ai/lua/unit_advancements_aspect.cpp
|
||||
|
@ -249,7 +247,6 @@ wesnoth_sources = Split("""
|
|||
ai/testing/ca_global_fallback.cpp
|
||||
ai/testing/ca_testing_move_to_targets.cpp
|
||||
ai/testing/ca_testing_recruitment.cpp
|
||||
ai/testing/stage_fallback.cpp
|
||||
ai/testing/stage_rca.cpp
|
||||
ai/testing/stage_sf_with_rca.cpp
|
||||
animated_game.cpp
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "units/map.hpp"
|
||||
//#include "units/types.hpp" // used in the below commented-out code
|
||||
#include "ai/composite/rca.hpp"
|
||||
#include "ai/default/ai.hpp"
|
||||
|
||||
#include "recruitment.hpp"
|
||||
|
||||
|
|
|
@ -179,7 +179,8 @@ std::string ai_composite::evaluate(const std::string& str)
|
|||
cfg["engine"] = "fai";///@todo 1.9 : consider allowing other engines to evaluate
|
||||
engine_ptr e_ptr = get_engine_by_cfg(cfg);
|
||||
if (!e_ptr) {
|
||||
return interface::evaluate(str);
|
||||
// This should be unreachable, but not entirely sure...
|
||||
return "engine not found for evaluate command";
|
||||
}
|
||||
return e_ptr->evaluate(str);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define AI_COMPOSITE_AI_HPP_INCLUDED
|
||||
|
||||
#include "contexts.hpp"
|
||||
#include "ai/interface.hpp"
|
||||
#include "component.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -33,7 +32,7 @@
|
|||
//============================================================================
|
||||
namespace ai {
|
||||
|
||||
class ai_composite : public ai_context, public virtual default_ai_context_proxy, public interface, public component {
|
||||
class ai_composite : public ai_context, public virtual default_ai_context_proxy, public component {
|
||||
public:
|
||||
|
||||
|
||||
|
@ -58,7 +57,7 @@ public:
|
|||
/**
|
||||
* Evaluate command (using fai)
|
||||
*/
|
||||
virtual std::string evaluate(const std::string& str);
|
||||
virtual std::string evaluate(const std::string& str);
|
||||
|
||||
/**
|
||||
* On new turn
|
||||
|
|
|
@ -1,185 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2003 - 2016 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Artificial intelligence - The computer commands the enemy.
|
||||
*/
|
||||
|
||||
#include "ai.hpp"
|
||||
|
||||
#include "ai/actions.hpp"
|
||||
#include "ai/manager.hpp"
|
||||
#include "ai/formula/ai.hpp"
|
||||
|
||||
#include "array.hpp"
|
||||
#include "game_board.hpp"
|
||||
#include "game_events/manager.hpp"
|
||||
#include "game_events/pump.hpp"
|
||||
#include "game_classification.hpp"
|
||||
#include "log.hpp"
|
||||
#include "mouse_handler_base.hpp"
|
||||
#include "recall_list_manager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "terrain/filter.hpp"
|
||||
#include "units/unit.hpp"
|
||||
#include "units/udisplay.hpp"
|
||||
#include "wml_exception.hpp"
|
||||
|
||||
#include "pathfind/pathfind.hpp"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
static lg::log_domain log_ai("ai/general");
|
||||
#define DBG_AI LOG_STREAM(debug, log_ai)
|
||||
#define LOG_AI LOG_STREAM(info, log_ai)
|
||||
#define WRN_AI LOG_STREAM(warn, log_ai)
|
||||
#define ERR_AI LOG_STREAM(err, log_ai)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
//silence "inherits via dominance" warnings
|
||||
#pragma warning(disable:4250)
|
||||
#endif
|
||||
|
||||
namespace ai {
|
||||
|
||||
idle_ai::idle_ai(readwrite_context &context, const config& /*cfg*/)
|
||||
: recursion_counter_(context.get_recursion_count())
|
||||
{
|
||||
init_readwrite_context_proxy(context);
|
||||
}
|
||||
|
||||
std::string idle_ai::describe_self() const
|
||||
{
|
||||
return "[idle_ai]";
|
||||
}
|
||||
|
||||
|
||||
void idle_ai::new_turn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void idle_ai::switch_side(side_number side)
|
||||
{
|
||||
set_side(side);
|
||||
}
|
||||
|
||||
|
||||
config idle_ai::to_config() const
|
||||
{
|
||||
return config();
|
||||
}
|
||||
|
||||
|
||||
int idle_ai::get_recursion_count() const
|
||||
{
|
||||
return recursion_counter_.get_count();
|
||||
}
|
||||
|
||||
|
||||
void idle_ai::play_turn()
|
||||
{
|
||||
resources::game_events->pump().fire("ai turn");
|
||||
}
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
variant attack_analysis::get_value(const std::string& key) const
|
||||
{
|
||||
using namespace game_logic;
|
||||
if(key == "target") {
|
||||
return variant(new location_callable(target));
|
||||
} else if(key == "movements") {
|
||||
std::vector<variant> res;
|
||||
for(size_t n = 0; n != movements.size(); ++n) {
|
||||
map_formula_callable* item = new map_formula_callable(NULL);
|
||||
item->add("src", variant(new location_callable(movements[n].first)));
|
||||
item->add("dst", variant(new location_callable(movements[n].second)));
|
||||
res.push_back(variant(item));
|
||||
}
|
||||
|
||||
return variant(&res);
|
||||
} else if(key == "units") {
|
||||
std::vector<variant> res;
|
||||
for(size_t n = 0; n != movements.size(); ++n) {
|
||||
res.push_back(variant(new location_callable(movements[n].first)));
|
||||
}
|
||||
|
||||
return variant(&res);
|
||||
} else if(key == "target_value") {
|
||||
return variant(static_cast<int>(target_value*1000));
|
||||
} else if(key == "avg_losses") {
|
||||
return variant(static_cast<int>(avg_losses*1000));
|
||||
} else if(key == "chance_to_kill") {
|
||||
return variant(static_cast<int>(chance_to_kill*100));
|
||||
} else if(key == "avg_damage_inflicted") {
|
||||
return variant(static_cast<int>(avg_damage_inflicted));
|
||||
} else if(key == "target_starting_damage") {
|
||||
return variant(target_starting_damage);
|
||||
} else if(key == "avg_damage_taken") {
|
||||
return variant(static_cast<int>(avg_damage_taken));
|
||||
} else if(key == "resources_used") {
|
||||
return variant(static_cast<int>(resources_used));
|
||||
} else if(key == "terrain_quality") {
|
||||
return variant(static_cast<int>(terrain_quality));
|
||||
} else if(key == "alternative_terrain_quality") {
|
||||
return variant(static_cast<int>(alternative_terrain_quality));
|
||||
} else if(key == "vulnerability") {
|
||||
return variant(static_cast<int>(vulnerability));
|
||||
} else if(key == "support") {
|
||||
return variant(static_cast<int>(support));
|
||||
} else if(key == "leader_threat") {
|
||||
return variant(leader_threat);
|
||||
} else if(key == "uses_leader") {
|
||||
return variant(uses_leader);
|
||||
} else if(key == "is_surrounded") {
|
||||
return variant(is_surrounded);
|
||||
} else {
|
||||
return variant();
|
||||
}
|
||||
}
|
||||
|
||||
void attack_analysis::get_inputs(std::vector<game_logic::formula_input>* inputs) const
|
||||
{
|
||||
using namespace game_logic;
|
||||
inputs->push_back(formula_input("target", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("movements", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("units", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("target_value", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("avg_losses", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("chance_to_kill", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("avg_damage_inflicted", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("target_starting_damage", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("avg_damage_taken", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("resources_used", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("terrain_quality", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("alternative_terrain_quality", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("vulnerability", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("support", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("leader_threat", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("uses_leader", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("is_surrounded", FORMULA_READ_ONLY));
|
||||
}
|
||||
|
||||
} //end of namespace ai
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2003 - 2016 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef AI_DEFAULT_AI_HPP_INCLUDED
|
||||
#define AI_DEFAULT_AI_HPP_INCLUDED
|
||||
|
||||
#include "ai/interface.hpp"
|
||||
#include "ai/composite/stage.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
//silence "inherits via dominance" warnings
|
||||
#pragma warning(disable:4250)
|
||||
#endif
|
||||
|
||||
|
||||
namespace ai {
|
||||
|
||||
/** A trivial ai that sits around doing absolutely nothing. */
|
||||
class idle_ai : public readwrite_context_proxy, public interface {
|
||||
public:
|
||||
idle_ai(readwrite_context &context, const config& /*cfg*/);
|
||||
void play_turn();
|
||||
void new_turn();
|
||||
std::string describe_self() const;
|
||||
void switch_side(side_number side);
|
||||
int get_recursion_count() const;
|
||||
virtual config to_config() const;
|
||||
static config preparse_cfg(ai_context&, const config& cfg) {return cfg;}
|
||||
private:
|
||||
recursion_counter recursion_counter_;
|
||||
};
|
||||
|
||||
} //end of namespace ai
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "ai.hpp"
|
||||
#include "ai/manager.hpp"
|
||||
|
||||
#include "actions/attack.hpp"
|
||||
|
@ -29,6 +28,7 @@
|
|||
#include "map/map.hpp"
|
||||
#include "team.hpp"
|
||||
#include "units/unit.hpp"
|
||||
#include "formula/callable_objects.hpp" // for location_callable
|
||||
|
||||
static lg::log_domain log_ai("ai/attack");
|
||||
#define LOG_AI LOG_STREAM(info, log_ai)
|
||||
|
@ -331,4 +331,81 @@ double attack_analysis::rating(double aggression, const readonly_context& ai_obj
|
|||
return value;
|
||||
}
|
||||
|
||||
variant attack_analysis::get_value(const std::string& key) const
|
||||
{
|
||||
using namespace game_logic;
|
||||
if(key == "target") {
|
||||
return variant(new location_callable(target));
|
||||
} else if(key == "movements") {
|
||||
std::vector<variant> res;
|
||||
for(size_t n = 0; n != movements.size(); ++n) {
|
||||
map_formula_callable* item = new map_formula_callable(NULL);
|
||||
item->add("src", variant(new location_callable(movements[n].first)));
|
||||
item->add("dst", variant(new location_callable(movements[n].second)));
|
||||
res.push_back(variant(item));
|
||||
}
|
||||
|
||||
return variant(&res);
|
||||
} else if(key == "units") {
|
||||
std::vector<variant> res;
|
||||
for(size_t n = 0; n != movements.size(); ++n) {
|
||||
res.push_back(variant(new location_callable(movements[n].first)));
|
||||
}
|
||||
|
||||
return variant(&res);
|
||||
} else if(key == "target_value") {
|
||||
return variant(static_cast<int>(target_value*1000));
|
||||
} else if(key == "avg_losses") {
|
||||
return variant(static_cast<int>(avg_losses*1000));
|
||||
} else if(key == "chance_to_kill") {
|
||||
return variant(static_cast<int>(chance_to_kill*100));
|
||||
} else if(key == "avg_damage_inflicted") {
|
||||
return variant(static_cast<int>(avg_damage_inflicted));
|
||||
} else if(key == "target_starting_damage") {
|
||||
return variant(target_starting_damage);
|
||||
} else if(key == "avg_damage_taken") {
|
||||
return variant(static_cast<int>(avg_damage_taken));
|
||||
} else if(key == "resources_used") {
|
||||
return variant(static_cast<int>(resources_used));
|
||||
} else if(key == "terrain_quality") {
|
||||
return variant(static_cast<int>(terrain_quality));
|
||||
} else if(key == "alternative_terrain_quality") {
|
||||
return variant(static_cast<int>(alternative_terrain_quality));
|
||||
} else if(key == "vulnerability") {
|
||||
return variant(static_cast<int>(vulnerability));
|
||||
} else if(key == "support") {
|
||||
return variant(static_cast<int>(support));
|
||||
} else if(key == "leader_threat") {
|
||||
return variant(leader_threat);
|
||||
} else if(key == "uses_leader") {
|
||||
return variant(uses_leader);
|
||||
} else if(key == "is_surrounded") {
|
||||
return variant(is_surrounded);
|
||||
} else {
|
||||
return variant();
|
||||
}
|
||||
}
|
||||
|
||||
void attack_analysis::get_inputs(std::vector<game_logic::formula_input>* inputs) const
|
||||
{
|
||||
using namespace game_logic;
|
||||
inputs->push_back(formula_input("target", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("movements", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("units", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("target_value", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("avg_losses", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("chance_to_kill", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("avg_damage_inflicted", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("target_starting_damage", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("avg_damage_taken", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("resources_used", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("terrain_quality", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("alternative_terrain_quality", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("vulnerability", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("support", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("leader_threat", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("uses_leader", FORMULA_READ_ONLY));
|
||||
inputs->push_back(formula_input("is_surrounded", FORMULA_READ_ONLY));
|
||||
}
|
||||
|
||||
} //end of namespace ai
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "ai/default/contexts.hpp" // for attack_analysis
|
||||
#include "ai/formula/function_table.hpp" // for ai_function_symbol_table
|
||||
#include "ai/game_info.hpp" // for move_result_ptr, move_map, etc
|
||||
#include "ai/interface.hpp" // for interface
|
||||
#include "candidates.hpp" // for base_candidate_action, etc
|
||||
|
||||
|
||||
|
@ -502,18 +501,8 @@ variant formula_ai::execute_variant(const variant& var, ai_context &ai_, bool co
|
|||
return variant();
|
||||
} else if(fallback_command) {
|
||||
if(get_recursion_count()<recursion_counter::MAX_COUNTER_VALUE) {
|
||||
if(fallback_command->key() == "human")
|
||||
{
|
||||
//we want give control of the side to human for the rest of this turn
|
||||
throw fallback_ai_to_human_exception();
|
||||
} else
|
||||
{
|
||||
LOG_AI << "Explicit fallback to: " << fallback_command->key() << std::endl;
|
||||
ai_ptr fallback( manager::create_transient_ai(fallback_command->key(), config(), &ai_));
|
||||
if(fallback) {
|
||||
fallback->play_turn();
|
||||
}
|
||||
}
|
||||
//we want give control of the side to human for the rest of this turn
|
||||
throw fallback_ai_to_human_exception();
|
||||
}
|
||||
return variant();
|
||||
} else {
|
||||
|
|
|
@ -195,13 +195,10 @@ public:
|
|||
};
|
||||
|
||||
class fallback_callable : public formula_callable {
|
||||
std::string key_;
|
||||
variant get_value(const std::string& /*key*/) const { return variant(); }
|
||||
public:
|
||||
explicit fallback_callable(const std::string& key) : key_(key) {
|
||||
explicit fallback_callable() {
|
||||
}
|
||||
|
||||
const std::string& key() const { return key_; }
|
||||
};
|
||||
|
||||
class safe_call_callable : public formula_callable {
|
||||
|
|
|
@ -1277,10 +1277,11 @@ public:
|
|||
: function_expression("fallback", args, 0, 1)
|
||||
{}
|
||||
private:
|
||||
variant execute(const formula_callable& variables, formula_debugger *fdb) const {
|
||||
if( args().size() == 0 )
|
||||
return variant(new fallback_callable(""));
|
||||
return variant(new fallback_callable(args()[0]->evaluate(variables,add_debug_info(fdb,0,"fallback:name")).as_string()));
|
||||
variant execute(const formula_callable& variables, formula_debugger*) const {
|
||||
// The parameter is not used, but is accepted for legacy compatibility
|
||||
if(args().size() == 1 && args()[0]->evaluate(variables).as_string() != "human")
|
||||
return variant();
|
||||
return variant(new fallback_callable);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ typedef std::multimap<map_location,map_location> move_map;
|
|||
/** The standard way in which a map of possible movement routes to location is recorded*/
|
||||
typedef std::map<map_location,pathfind::paths> moves_map;
|
||||
|
||||
class interface;
|
||||
class ai_composite;
|
||||
|
||||
typedef boost::shared_ptr< interface > ai_ptr;
|
||||
typedef boost::shared_ptr<ai_composite> ai_ptr;
|
||||
|
||||
class attack_analysis;
|
||||
typedef std::vector<attack_analysis> attacks_vector;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2009 - 2016 by Yurii Chernyi <terraninfo@terraninfo.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for the AI and AI-ai_manager contract.
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "interface.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
namespace ai {
|
||||
|
||||
static lg::log_domain log_ai("ai/general");
|
||||
|
||||
// =======================================================================
|
||||
//
|
||||
// =======================================================================
|
||||
std::string interface::describe_self() const
|
||||
{
|
||||
return "? [ai]";
|
||||
}
|
||||
|
||||
// This is defined in the source file so that it can easily access the logger
|
||||
bool ai_factory::is_duplicate(const std::string& name)
|
||||
{
|
||||
if (get_list().find(name) != get_list().end()) {
|
||||
LOG_STREAM(err, log_ai) << "Error: Attempt to double-register AI " << name << std::endl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} //end of namespace ai
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2003 - 2016 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Interface to the AI.
|
||||
*/
|
||||
|
||||
#ifndef AI_INTERFACE_HPP_INCLUDED
|
||||
#define AI_INTERFACE_HPP_INCLUDED
|
||||
|
||||
#include <boost/shared_ptr.hpp> // for shared_ptr
|
||||
#include <global.hpp>
|
||||
#include <map> // for map, map<>::value_compare
|
||||
#include <string> // for string, basic_string, etc
|
||||
#include <utility> // for make_pair, pair
|
||||
#include "savegame_config.hpp" // for savegame_config
|
||||
#include "config.hpp" // for config
|
||||
#include "ai/game_info.hpp" // for ai_ptr, side_number
|
||||
namespace ai { class ai_context; }
|
||||
|
||||
namespace ai {
|
||||
|
||||
class interface : savegame::savegame_config {
|
||||
public:
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
interface()
|
||||
: savegame_config()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual ~interface() {}
|
||||
|
||||
|
||||
/**
|
||||
* Function that is called when the AI must play its turn.
|
||||
* Derived classes should implement their AI algorithm in this function.
|
||||
*/
|
||||
virtual void play_turn() = 0;
|
||||
|
||||
/**
|
||||
* Function called when a a new turn is played
|
||||
*/
|
||||
virtual void new_turn() = 0;
|
||||
|
||||
/**
|
||||
* Function called after the new ai is created
|
||||
*
|
||||
*/
|
||||
virtual void on_create() {
|
||||
}
|
||||
|
||||
virtual void switch_side(ai::side_number side) = 0;
|
||||
|
||||
/** Evaluate */
|
||||
virtual std::string evaluate(const std::string& /*str*/)
|
||||
{ return "evaluate command not implemented by this AI"; }
|
||||
|
||||
/** Describe self*/
|
||||
virtual std::string describe_self() const;
|
||||
|
||||
|
||||
/** serialize to config **/
|
||||
virtual config to_config() const = 0;
|
||||
};
|
||||
|
||||
class ai_factory;
|
||||
|
||||
class ai_factory{
|
||||
bool is_duplicate(const std::string &name);
|
||||
public:
|
||||
typedef boost::shared_ptr< ai_factory > factory_ptr;
|
||||
typedef std::map<std::string, factory_ptr> factory_map;
|
||||
typedef std::pair<const std::string, factory_ptr> factory_map_pair;
|
||||
|
||||
static factory_map& get_list() {
|
||||
static factory_map *ai_factories;
|
||||
if (ai_factories==NULL) {
|
||||
ai_factories = new factory_map;
|
||||
}
|
||||
return *ai_factories;
|
||||
}
|
||||
|
||||
virtual ai_ptr get_new_instance( ai_context &context, const config &cfg) = 0;
|
||||
|
||||
ai_factory( const std::string &name )
|
||||
{
|
||||
if (is_duplicate(name)) {
|
||||
return;
|
||||
}
|
||||
factory_ptr ptr_to_this(this);
|
||||
get_list().insert(make_pair(name,ptr_to_this));
|
||||
}
|
||||
|
||||
virtual ~ai_factory() {}
|
||||
};
|
||||
|
||||
|
||||
template<class AI>
|
||||
class register_ai_factory : public ai_factory {
|
||||
public:
|
||||
register_ai_factory( const std::string &name )
|
||||
: ai_factory( name )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ai_ptr get_new_instance( ai_context &context, const config &cfg){
|
||||
config preparsed_cfg = AI::preparse_cfg(context, cfg);
|
||||
ai_ptr a(new AI(context,preparsed_cfg));
|
||||
a->on_create();
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} //end of namespace ai
|
||||
|
||||
#endif
|
|
@ -39,7 +39,6 @@
|
|||
#include "game_info.hpp" // for side_number, engine_ptr, etc
|
||||
#include "game_config.hpp" // for debug
|
||||
#include "game_errors.hpp" // for game_error
|
||||
#include "interface.hpp" // for ai_factory, etc
|
||||
#include "lua/unit_advancements_aspect.hpp"
|
||||
#include "registry.hpp" // for init
|
||||
#include "util.hpp" // for lexical_cast
|
||||
|
@ -143,7 +142,7 @@ holder::~holder()
|
|||
}
|
||||
|
||||
|
||||
interface& holder::get_ai_ref()
|
||||
ai_composite& holder::get_ai_ref()
|
||||
{
|
||||
if (!this->ai_) {
|
||||
this->init(this->side_);
|
||||
|
@ -495,7 +494,7 @@ const std::string manager::evaluate_command( side_number side, const std::string
|
|||
}
|
||||
|
||||
if (!should_intercept(str)){
|
||||
interface& ai = get_active_ai_for_side(side);
|
||||
ai_composite& ai = get_active_ai_for_side(side);
|
||||
raise_gamestate_changed();
|
||||
return ai.evaluate(str);
|
||||
}
|
||||
|
@ -681,24 +680,6 @@ bool manager::add_ai_for_side( side_number side, const std::string& ai_algorithm
|
|||
}
|
||||
|
||||
|
||||
ai_ptr manager::create_transient_ai(const std::string &ai_algorithm_type, const config &cfg, ai_context *ai_context )
|
||||
{
|
||||
assert(ai_context!=NULL);
|
||||
|
||||
//to add your own ai, register it in registry,cpp
|
||||
ai_factory::factory_map::iterator aii = ai_factory::get_list().find(ai_algorithm_type);
|
||||
if (aii == ai_factory::get_list().end()){
|
||||
aii = ai_factory::get_list().find("");
|
||||
if (aii == ai_factory::get_list().end()){
|
||||
throw game::game_error("no default ai set!");
|
||||
}
|
||||
}
|
||||
LOG_AI_MANAGER << "Creating new AI of type [" << ai_algorithm_type << "]"<< std::endl;
|
||||
ai_ptr new_ai = aii->second->get_new_instance(*ai_context,cfg);
|
||||
return new_ai;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// REMOVE
|
||||
// =======================================================================
|
||||
|
@ -805,7 +786,7 @@ void manager::play_turn( side_number side ){
|
|||
const int turn_start_time = SDL_GetTicks();
|
||||
/*hack. @todo 1.9 rework via extended event system*/
|
||||
get_ai_info().recent_attacks.clear();
|
||||
interface& ai_obj = get_active_ai_for_side(side);
|
||||
ai_composite& ai_obj = get_active_ai_for_side(side);
|
||||
resources::game_events->pump().fire("ai turn");
|
||||
raise_turn_started();
|
||||
if (resources::tod_manager->has_tod_bonus_changed()) {
|
||||
|
@ -855,7 +836,7 @@ holder& manager::get_active_ai_holder_for_side( side_number side )
|
|||
// AI POINTERS
|
||||
// =======================================================================
|
||||
|
||||
interface& manager::get_active_ai_for_side( side_number side )
|
||||
ai_composite& manager::get_active_ai_for_side( side_number side )
|
||||
{
|
||||
return get_active_ai_holder_for_side(side).get_ai_ref();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace ai { class ai_composite; } // lines 45-45
|
|||
namespace ai { class ai_context; } // lines 42-42
|
||||
namespace ai { class component; } // lines 43-43
|
||||
namespace ai { class default_ai_context; } // lines 41-41
|
||||
namespace ai { class interface; } // lines 36-36
|
||||
namespace ai { class readonly_context; } // lines 39-39
|
||||
namespace ai { class readwrite_context; } // lines 40-40
|
||||
namespace ai { class side_context; } // lines 38-38
|
||||
|
@ -59,7 +58,7 @@ public:
|
|||
|
||||
virtual ~holder();
|
||||
|
||||
interface& get_ai_ref();
|
||||
ai_composite& get_ai_ref();
|
||||
|
||||
const std::string describe_ai();
|
||||
|
||||
|
@ -338,16 +337,6 @@ public:
|
|||
static bool add_ai_for_side( side_number side, const std::string& ai_algorithm_type, bool replace = true);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a smart pointer to a new AI.
|
||||
* @param ai_algorithm_type type of AI algorithm to create
|
||||
* @param cfg a config of the ai
|
||||
* @param ai_context context in which this ai is created
|
||||
* @return the reference to the created AI
|
||||
*/
|
||||
static ai_ptr create_transient_ai( const std::string &ai_algorithm_type, const config &cfg, ai_context *ai_context);
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// REMOVE
|
||||
// =======================================================================
|
||||
|
@ -545,7 +534,7 @@ private:
|
|||
* @return a reference to the active AI.
|
||||
* @note This reference may become invalid after specific manager operations.
|
||||
*/
|
||||
static interface& get_active_ai_for_side( side_number side );
|
||||
static ai_composite& get_active_ai_for_side( side_number side );
|
||||
|
||||
|
||||
};
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "ai/composite/stage.hpp" // for ministage, idle_stage, etc
|
||||
#include "ai/composite/rca.hpp"
|
||||
#include "ai/game_info.hpp" // for attacks_vector
|
||||
#include "ai/interface.hpp" // for register_ai_factory
|
||||
#include "akihara/recruitment.hpp" // for recruitment
|
||||
#include "composite/ai.hpp" // for ai_composite
|
||||
#include "composite/aspect.hpp" // for composite_aspect, etc
|
||||
|
@ -34,7 +33,6 @@
|
|||
#include "composite/engine_fai.hpp" // for engine_fai
|
||||
#include "composite/engine_lua.hpp" // for engine_lua
|
||||
#include "composite/goal.hpp" // for register_goal_factory, etc
|
||||
#include "default/ai.hpp"
|
||||
#include "lua/unit_advancements_aspect.hpp"
|
||||
#include "recruitment/recruitment.hpp" // for recruitment
|
||||
#include "testing/aspect_attacks.hpp" // for aspect_attacks
|
||||
|
@ -43,7 +41,6 @@
|
|||
#include "testing/ca_testing_move_to_targets.hpp"
|
||||
#include "testing/ca_testing_recruitment.hpp"
|
||||
#include "testing/stage_sf_with_rca.hpp"
|
||||
#include "testing/stage_fallback.hpp" // for fallback_to_other_ai
|
||||
#include "testing/stage_rca.hpp"
|
||||
|
||||
#include <boost/shared_ptr.hpp> // for shared_ptr, etc
|
||||
|
@ -52,16 +49,6 @@
|
|||
|
||||
|
||||
namespace ai {
|
||||
// =======================================================================
|
||||
// AIs
|
||||
// =======================================================================
|
||||
|
||||
static register_ai_factory<ai_composite> ai_factory_default("");
|
||||
static register_ai_factory<ai_composite> ai_default_ai_factory("default_ai");
|
||||
static register_ai_factory<idle_ai> ai_idle_ai_factory("idle_ai");
|
||||
static register_ai_factory<ai_composite> ai_composite_ai_factory("composite_ai");
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// Engines
|
||||
// =======================================================================
|
||||
|
@ -85,9 +72,6 @@ static register_stage_factory<testing_ai_default::candidate_action_evaluation_lo
|
|||
static register_stage_factory<testing_ai_default::strategy_formulation_with_rca>
|
||||
strategy_formulation_with_rca_factory("testing_ai_default::strategy_formulation_with_rca");
|
||||
|
||||
static register_stage_factory<testing_ai_default::fallback_to_other_ai>
|
||||
fallback_to_other_ai_factory("testing_ai_default::fallback");
|
||||
|
||||
static register_stage_factory<idle_stage>
|
||||
ai_idle_stage_factory("empty");
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define AI_TESTING_ASPECT_ATTACKS_HPP_INCLUDED
|
||||
|
||||
#include "ai/composite/aspect.hpp"
|
||||
#include "ai/interface.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2009 - 2016 by Yurii Chernyi <terraninfo@terraninfo.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stage: fallback to other AI
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "stage_fallback.hpp"
|
||||
|
||||
#include "ai/configuration.hpp"
|
||||
#include "ai/manager.hpp"
|
||||
#include "ai/composite/ai.hpp"
|
||||
#include "log.hpp"
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
static lg::log_domain log_ai_testing_stage_fallback("ai/stage/fallback");
|
||||
#define DBG_AI_TESTING_STAGE_FALLBACK LOG_STREAM(debug, log_ai_testing_stage_fallback)
|
||||
#define LOG_AI_TESTING_STAGE_FALLBACK LOG_STREAM(info, log_ai_testing_stage_fallback)
|
||||
#define ERR_AI_TESTING_STAGE_FALLBACK LOG_STREAM(err, log_ai_testing_stage_fallback)
|
||||
|
||||
fallback_to_other_ai::fallback_to_other_ai( ai_context &context, const config &cfg )
|
||||
: stage(context,cfg), cfg_(cfg), fallback_ai_()
|
||||
{
|
||||
}
|
||||
|
||||
void fallback_to_other_ai::on_create()
|
||||
{
|
||||
fallback_ai_ = manager::create_transient_ai(cfg_["type"], cfg_.child_or_empty("params"), this);
|
||||
}
|
||||
|
||||
|
||||
config fallback_to_other_ai::to_config() const
|
||||
{
|
||||
config cfg = stage::to_config();
|
||||
|
||||
if (fallback_ai_) {
|
||||
cfg["type"] = cfg_["type"];
|
||||
cfg.add_child("params",fallback_ai_->to_config());
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
bool fallback_to_other_ai::do_play_stage()
|
||||
{
|
||||
if (fallback_ai_) {
|
||||
LOG_AI_TESTING_STAGE_FALLBACK << "side "<<get_side()<<" : falling back to "<<fallback_ai_->describe_self()<<std::endl;
|
||||
fallback_ai_->new_turn();
|
||||
fallback_ai_->play_turn();
|
||||
} else {
|
||||
ERR_AI_TESTING_STAGE_FALLBACK << "side "<<get_side()<<" : UNABLE TO FALLBACK, fallback ai is NULL"<<std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
fallback_to_other_ai::~fallback_to_other_ai()
|
||||
{
|
||||
}
|
||||
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
} // end of namespace ai
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2009 - 2016 by Yurii Chernyi <terraninfo@terraninfo.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Stage: fallback to other AI
|
||||
* @file
|
||||
*/
|
||||
|
||||
#ifndef AI_TESTING_STAGE_FALLBACK_HPP_INCLUDED
|
||||
#define AI_TESTING_STAGE_FALLBACK_HPP_INCLUDED
|
||||
|
||||
#include "ai/composite/stage.hpp"
|
||||
#include "ai/interface.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
//silence "inherits via dominance" warnings
|
||||
#pragma warning(disable:4250)
|
||||
#endif
|
||||
|
||||
namespace ai {
|
||||
|
||||
namespace testing_ai_default {
|
||||
|
||||
class fallback_to_other_ai: public stage {
|
||||
public:
|
||||
fallback_to_other_ai( ai_context &context, const config &cfg );
|
||||
|
||||
~fallback_to_other_ai();
|
||||
|
||||
bool do_play_stage();
|
||||
|
||||
void on_create();
|
||||
|
||||
config to_config() const;
|
||||
|
||||
private:
|
||||
const config &cfg_;
|
||||
|
||||
ai_ptr fallback_ai_;
|
||||
};
|
||||
|
||||
} // end of namespace testing_ai_default
|
||||
|
||||
} // end of namespace ai
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue