Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI: isSea units are not considered for "Sea Defense" if they're also subs #11740

Closed
TheDog-GH opened this issue Jul 6, 2023 · 11 comments · Fixed by #11812
Closed

AI: isSea units are not considered for "Sea Defense" if they're also subs #11740

TheDog-GH opened this issue Jul 6, 2023 · 11 comments · Fixed by #11812
Assignees
Labels
Needs Clarification Ticket is not actionable pending more information

Comments

@TheDog-GH
Copy link
Contributor

TheDog-GH commented Jul 6, 2023

In this map 1941 Global Command Decision
The use of
<option name="**canNotTarget**" value="$All-Air$"/>
in isSea units blocks/ignores the purchase of Sea Units checking the HardAI logs for;
Sea Defense Options
In maps that dont use canNotTarget the Sea Defense Options have a colon and a list of units
eg. Sea Defense Options: Destroyer, Cruiser etc

However the canNotTarget
<option name="canNotTarget" value="$All-Air$"/>
for isLand & isAir units works fine. :-/

TripleA-2.6+14388 &
1941 Global Command Decision v120 were the test versions (link below)
https://drive.google.com/file/d/1Q5XcTxMNdUZVAjjTWbz4mw0gL-Bjlw6r/view?usp=sharing

@asvitkine (I have not checked 2.5 thoroughly but I think it does the same as above)
I have been testing using just Japan & USA, turning off the other nations for a faster result.

@asvitkine
Copy link
Contributor

asvitkine commented Jul 16, 2023

Which units do expect to show up as "sea defense options"?

In the log, I see:

  Sea: ProductionRule:buyDestroyer-LongL | cost=6 | moves=3 | quantity=1 | hitPointEfficiency=0.267 | attackEfficiency=1.167 | defenseEfficiency=1.000 | isSub=true | isTransport=false | isCarrier=false
  Sea: ProductionRule:buyCruiser-LongL | cost=9 | moves=3 | quantity=1 | hitPointEfficiency=0.222 | attackEfficiency=1.111 | defenseEfficiency=1.000 | isSub=true | isTransport=true | isCarrier=false
  Sea: ProductionRule:buyBattleship | cost=18 | moves=2 | quantity=1 | hitPointEfficiency=0.200 | attackEfficiency=1.333 | defenseEfficiency=1.333 | isSub=true | isTransport=true | isCarrier=false
  Sea: ProductionRule:buyCarrier-Fleet | cost=18 | moves=3 | quantity=1 | hitPointEfficiency=0.122 | attackEfficiency=0.417 | defenseEfficiency=0.500 | isSub=true | isTransport=false | isCarrier=true
  Sea: ProductionRule:buySubmarine-Adv | cost=7 | moves=2 | quantity=1 | hitPointEfficiency=0.286 | attackEfficiency=1.429 | defenseEfficiency=1.286 | isSub=true | isTransport=false | isCarrier=false
  Sea: ProductionRule:buyConvoy | cost=10 | moves=2 | quantity=1 | hitPointEfficiency=0.120 | attackEfficiency=0.300 | defenseEfficiency=0.400 | isSub=true | isTransport=true | isCarrier=false

These are all isSub=true, which means they will be put into "Sea Sub Options" per the AI's logic.
Is there something else besides those that's not showing up? If not, the issue is because everything is a "sub".

@asvitkine asvitkine added the Needs Clarification Ticket is not actionable pending more information label Jul 16, 2023
@TheDog-GH
Copy link
Contributor Author

TheDog-GH commented Jul 16, 2023

But the sea units are not all isSub, (you can confirm as you have the xml) but maybe thats the real problem. using canNotTarget makes all sea units isSub :-/ Im quessing.

Only HQ-Submarine, Submarine & Submarine-Adv are isSub

Destroyer xml is below with no isSub

<!-- Destroyer -->
	<attachment name="unitAttachment" attachTo="Destroyer" javaClass="UnitAttachment" type="unitType">
		<option name="attack" value="1"/>
		<option name="defense" value="1"/>
<!--			<option name="canNotTarget" value="$All-Air$"/>  AI will not purchase -->
			<option name="canNotTarget" value="$All-Air$"/>
		<option name="movement" value="3"/>
			<option name="isSea" value="true"/>
			<option name="isDestroyer" value="true"/>	<!-- target subs -->
			<option name="blockade" value="1"/>
<!-- AA -->
		<option name="isAAforCombatOnly" value="true"/>
			<option name="offensiveAttackAA" value="1"/>
			<option name="attackAA" value="1"/>
				<option name="offensiveAttackAAmaxDieSides" value="12"/>
				<option name="attackAAmaxDieSides" value="12"/>
					<option name="maxAAattacks" value="1"/>
					<option name="maxRoundsAA" value="-1"/>
            <option name="mayOverStackAA" value="true"/>
		<option name="typeAA" value="Flak"/>											
		<option name="targetsAA" value="$All-Air-Targetable$"/>

		<option name="createsResourcesList" value="-1:PUs"/>
			<option name="requiresUnits" value="Industry-Hvy"/>
			<option name="requiresUnits" value="Industry-Med"/>
	</attachment>

Run it under 2.5 and it works as intended. EDIT Just checked, it does the same under 2.5 as 2.6

@TheDog-GH
Copy link
Contributor Author

Just checked, 2.5 also does the same as 2.6
Apologies too many variations.

@TheDog-GH
Copy link
Contributor Author

TheDog-GH commented Jul 16, 2023

Removing the line
<!-- <option name="canNotTarget" value="$All-Air$"/> -->
in both Destroyer & Cruiser gives the following from the AI logs;
Sea Defense Options: Destroyer, Cruiser
Sea Transport Options: Cruiser, Battleship, Convoy
Sea Carrier Options: Carrier
Sea Sub Options: HQ-Fleet, Battleship, Carrier, Submarine, Convoy

@TheDog-GH
Copy link
Contributor Author

So I expect the following
Sea Defense Options: Destroyer, Cruiser, Battleship, Carrier-Fleet, Convoy (could also include Carrier)
Sea Transport Options: Cruiser, Battleship, Convoy
Sea Carrier Options: Carrier-Fleet
Sea Sub Options: HQ-Fleet, Submarine-Adv (could also include Submarine)

or very similar

@asvitkine asvitkine removed the 2.6 label Jul 16, 2023
@asvitkine asvitkine changed the title 2.6+14388 does not buy isSea units if using canNotTarget AI: isSea units are not considered for "Sea Defense" if they're also subs or transports Jul 16, 2023
@TheDog-GH
Copy link
Contributor Author

For reference in 2.5 and not using canNotTarget
If a Cruiser or Battleship is also a Transport capable it would appear in both
Sea Defense Options:
Sea Transport Options:
Note not just Sea Transport Options as you new heading is suggesting

This extract is taken from the AI log from the 1941 CD map with the canNotTarget removed from the Sea units.
Sea Defense Options: Destroyer, Cruiser, Battleship, Carrier-Fleet, Convoy
Sea Transport Options: Cruiser, Battleship, Convoy
Sea Carrier Options: Carrier-Fleet
Sea Sub Options: HQ-Fleet, Submarine-Adv

@asvitkine asvitkine changed the title AI: isSea units are not considered for "Sea Defense" if they're also subs or transports AI: isSea units are not considered for "Sea Defense" if they're also subs Jul 17, 2023
@TheDog-GH
Copy link
Contributor Author

@asvitkine
Please can you look at this issue, in the next week, as our map making project has stalled until this is fixed. 😁

The work around is ugly and uses triggers to try and compensate for the lack of AI purchasing.

@asvitkine
Copy link
Contributor

@TheDog-GH it's a very simple change, so I've sent the PR: #11812

I also confirmed on your map that the units get listed in Sea Defense Options and that AI sometimes builds them (I only saw destroyers).

The only thing I'm worried about is if it results in some bad AI behavior on more normal WWII triplea maps - i.e. if AI starts buying more subs as defense units when it shouldn't be. Would be good if someone can test it once the change is in.

@TheDog-GH
Copy link
Contributor Author

TheDog-GH commented Jul 25, 2023

@asvitkine
Caveat, I have not played any of the classic A&A maps, so I can only go by the Hard AI logs.

America 1st turn FastAI using map = WW2v5_1942_2nd_Edition_High_Production_Mod.xml

TripleA-2.6+14439
Sea Defense Options: transport, submarine, destroyer, cruiser, carrier, battleship
Sea Transport Options: transport
Sea Carrier Options: carrier
Sea Sub Options: submarine

TripleA-2.5.22294
Sea Defense Options: transport, destroyer, cruiser, carrier, battleship
Sea Transport Options: transport
Sea Carrier Options: carrier
Sea Sub Options: submarine

Observations: 2.6 Sea Defense Options includes submarine and 2.5 does not

.
.
America 1st turn FastAI using map = 1941_global_command_decision.xml v125

TripleA-2.6+14439
Sea Defense Options: Destroyer, Cruiser, Battleship, Carrier-Fleet, Submarine, Convoy
Sea Transport Options: Cruiser, Battleship, Convoy
Sea Carrier Options: Carrier-Fleet
Sea Sub Options: Destroyer, Cruiser, Battleship, Carrier-Fleet, Submarine, Convoy

TripleA-2.5.22294
Sea Defense Options
Sea Transport Options: Cruiser, Battleship, Convoy
Sea Carrier Options: Carrier-Fleet
Sea Sub Options: Destroyer, Cruiser, Battleship, Carrier-Fleet, Submarine, Convoy

Observations: On our map the same issue was there in 2.5 Sea Defense Options (no : is blank)
Note that Sea Sub Options: in both 2.5 & 2.6, all sea units are classified as isSub, this is wrong and is probably due to me using canNotTarget

An aside testing our map with your TripleA code, the AI buys lots of sea units and gives a much better account of itself at sea. So much so its worthy of lots of xml sea code removal as I was trying to make up for the AI not buying sea units and releasing a new version. Thanks again!

Black Elk will also post later with his thoughts.

@asvitkine
Copy link
Contributor

asvitkine commented Jul 26, 2023

I confirm that "isSub" in the AI logs is actually based on canNotTarget.

@black-elk
Copy link

I ran a few quick test games in v3 v5 and Iron War using that build TripleA_2.6+14439 to see if anything jumped out at me, but the AI purchasing behavior seemed pretty decent. I'll try a few other maps when I get a chance. In 1941 command decision the AI purchasing seems much improved in my game so far. Thanks so much! Whatever you guys did, it's humming now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Clarification Ticket is not actionable pending more information
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants