Page MenuHomeWildfire Games

Fix AI using Maurya elephant archers as hunters following rP23916
ClosedPublic

Authored by wraitii on Aug 17 2020, 11:12 AM.

Details

Reviewers
Nescio
Silier
bb
Group Reviewers
Balancing
Restricted Owners Package(Owns No Changed Paths)
Commits
rP24009: Fix AI using Maurya elephant archers as hunters following rP23916
Trac Tickets
#5800
Summary

The Maurya elephant archer is a fast moving citizen soldier, despite being unable to gather.

This led to an issue post rP23916.


The removal of gathering comes from rP18453.

Test Plan

Agree with the change.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wraitii created this revision.Aug 17 2020, 11:12 AM
Owners added a subscriber: Restricted Owners Package.Aug 17 2020, 11:12 AM
wraitii requested review of this revision.Aug 17 2020, 11:17 AM

If I understand correctly, this means the AI won't be able to train them, since Petra uses the CitizenSoldier class for that (see simulation/ai/petra/attackPlan.js).
The Citizen class is used by auras and technologies to exclude champions and heroes; removing it means elephant archers no longer benefit from those, effectively weakening them, so that means this patch changes gameplay.

If I understand correctly, this means the AI won't be able to train them, since Petra uses the CitizenSoldier class for that (see simulation/ai/petra/attackPlan.js).
The Citizen class is used by auras and technologies to exclude champions and heroes; removing it means elephant archers no longer benefit from those, effectively weakening them, so that means this patch changes gameplay.

Hm, you seem to be correct.
I guess the simplest fix would be to special-case this in the AI then. The elephant would remain a very odd citizen soldier.

baseManager.js and headquarters.js should probably use the Worker class, not CitizenSoldier. And maybe introduce a Hunter class for citizen cavalry but not elephants?

Regardless, since elephants can't gather, they shouldn't be able to slaughter (D2853). Moreover, elephants ought to be separated from cavalry archers (D2595).

wraitii updated this revision to Diff 13220.Aug 17 2020, 12:42 PM
wraitii retitled this revision from Fix Maurya elephant archer being a citizen soldier to Fix AI using Maurya elephant archers as hunters following rP23916.
wraitii edited the summary of this revision. (Show Details)

Alternative fix that checks that hunters can actually hunt.

baseManager.js and headquarters.js should probably use the Worker class, not CitizenSoldier.

I've added Worker to Cavalry - do you know of a counter-indication to that?

Owners added a subscriber: Restricted Owners Package.Aug 17 2020, 12:42 PM

I've added Worker to Cavalry - do you know of a counter-indication to that?

That's wrong. Worker indicates units that can build and gather everything. Cavalry can't build and can only gather food.meat; giving them a Worker class will most likely result in the AI trying to use them for things they can't.

Freagarach added inline comments.
binaries/data/mods/public/simulation/ai/petra/baseManager.js
653 ↗(On Diff #13220)

It should have an attack as well,,,

wraitii updated this revision to Diff 13222.Aug 17 2020, 12:50 PM
wraitii edited the summary of this revision. (Show Details)

Then I really have no choice but to make the minimal diff...

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
builderr-release-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1360/display/redirect

Nescio added inline comments.Aug 17 2020, 1:01 PM
binaries/data/mods/public/simulation/ai/petra/baseManager.js
653 ↗(On Diff #13222)

Shouldn't it be "food.meat"?

Build failure - The Moirai have given mortals hearts that can endure.

builderr-debug-gcc6.txt
<command-line>:0:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[1]: *** [obj/test_Debug/test_root.o] Error 1
make: *** [test] Error 2

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3006/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

builderr-debug-gcc6.txt
<command-line>:0:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[1]: *** [obj/test_Debug/test_root.o] Error 1
make: *** [test] Error 2

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/3007/display/redirect

wraitii added inline comments.Aug 17 2020, 1:08 PM
binaries/data/mods/public/simulation/ai/petra/baseManager.js
653 ↗(On Diff #13222)

canGather doesn't actually allow checking for that. I don't think it's too bad.

Given that elephants move only half as fast as cavalry, the FastMoving class is quite inappropiate. Removing it would probably solve the AI hunting issue, though it would also prevent the AI from training them.

binaries/data/mods/public/simulation/ai/petra/baseManager.js
653 ↗(On Diff #13222)

Doesn't it? simulation/ai/common-api/entity.js lines 512 to 520.

Nescio added inline comments.Aug 17 2020, 1:15 PM
binaries/data/mods/public/simulation/ai/petra/baseManager.js
653 ↗(On Diff #13222)

You're probably right (line 517).

wraitii updated this revision to Diff 13234.Aug 18 2020, 8:43 AM

Remove FastMoving from the elephant since it indeed isn't.

I don't think the AI explicitly builds war elephants now, so that ought to be fixed someday.

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:155:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
builderr-release-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:155:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/1367/display/redirect

bb accepted this revision.Aug 25 2020, 3:12 PM
This revision is now accepted and ready to land.Aug 25 2020, 3:12 PM

I don't think the AI explicitly builds war elephants now, so that ought to be fixed someday.

Yes they do.

Elephants did not have Cavalry class before so removing FastMoving does not change things before rP23916.
Condition is actually good for "Cavalry" too. It was broken quite long and worked just because in svn Cavalry = attack + gather meat.

But anyhow odd it may sound, why could not slow moving unit slaughter and gather from domestic animals instead of doing nothing because it cant do anything else ?