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

Matches#lambda$territoryIsPassableAndNotRestricted$120:1007 - java.lang.NullPointerException #13158

Open
tripleabuilderbot opened this issue Feb 1, 2025 · 18 comments
Labels
2.6 Error Report Issue reported via the in-game error reporter

Comments

@tripleabuilderbot
Copy link
Contributor

User Description

I'm trying to play a custom version of WWIIv3 1939 that allows players to place non-infantry units for minor powers based on the number of territories they control, using productionPerXTerritories.

The game works properly with human players, with Easy AI, and with DoNothing AI, but when using Hard AI or Fast AI I get a Null Pointer Exception as soon as it's the AI's turn.

Possibly related to #12872.

Map

ww2v3_11n

TripleA Version

2.6+14176

Java Version

11.0.9.1

Operating System

Windows 10

Stack Trace

Exception: java.lang.NullPointerException 
java.lang.Exception
	at games.strategy.triplea.delegate.Matches.lambda$territoryIsPassableAndNotRestricted$120(Matches.java:1007)
	at java.base/java.util.function.Predicate.lambda$negate$1(Predicate.java:80)
	at games.strategy.triplea.delegate.Matches.lambda$territoryIsImpassableToLandUnits$121(Matches.java:1012)
	at java.base/java.util.function.Predicate.lambda$negate$1(Predicate.java:80)
	at games.strategy.triplea.delegate.Matches.lambda$territoryIsNotImpassableToLandUnits$122(Matches.java:1016)
	at java.base/java.util.function.Predicate.lambda$and$0(Predicate.java:69)
	at games.strategy.triplea.ai.pro.ProTechAi.findAttackers(ProTechAi.java:428)
	at games.strategy.triplea.ai.pro.ProTechAi.determineEnemyBlitzStrength(ProTechAi.java:391)
	at games.strategy.triplea.ai.pro.ProTechAi.getStrengthOfPotentialAttackers(ProTechAi.java:170)
	at games.strategy.triplea.ai.pro.ProTechAi.tech(ProTechAi.java:47)
	at games.strategy.triplea.ai.pro.AbstractProAi.tech(AbstractProAi.java:312)
	at games.strategy.triplea.ai.AbstractAi.start(AbstractAi.java:511)
	at games.strategy.engine.framework.ServerGame.waitForPlayerToFinishStep(ServerGame.java:593)
	at games.strategy.engine.framework.ServerGame.runStep(ServerGame.java:450)
	at games.strategy.engine.framework.ServerGame.runNextStep(ServerGame.java:345)
	at games.strategy.engine.framework.ServerGame.startGame(ServerGame.java:312)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.launchInternal(LocalLauncher.java:92)
	at games.strategy.engine.framework.startup.launcher.LocalLauncher.lambda$launch$0(LocalLauncher.java:60)
	at java.base/java.lang.Thread.run(Thread.java:834)


@tripleabuilderbot tripleabuilderbot added 2.6 Error Report Issue reported via the in-game error reporter labels Feb 1, 2025
@JGreenLowe
Copy link
Contributor

WW2v3-1939-11N-custom.txt

Here's a text version of the XML file I'm using for the game.

@JGreenLowe
Copy link
Contributor

Image

@TheDog-GH
Copy link
Contributor

Hi, thats an old version, upgrade to 2.7
https://github.com/triplea-game/triplea/releases

Maybe worth having the old 2.5 installed at the same time, as sometimes it gives better error messages.
https://forums.triplea-game.org/topic/3724/how-to-have-triplea-2-5-2-6-installed-at-the-same-time

@JGreenLowe
Copy link
Contributor

OK, I think I've found the problem -- looks like the Hard AI and the Fast AI don't have any instructions for how to place non-infantry units for a noPU nation. They can buy and place units with PUs as normal, and they can place infantry for a noPU nation, but they can't place, e.g., artillery for a noPU nation.

The previous version of my custom map had a separate bug in it that caused the noPU nations to only produce artillery (see https://forums.triplea-game.org/topic/3323/building-multiple-unit-types-with-productionperxterritories?_=1738422331993 for more details), which is what was causing the Null Pointer Exception.

Today's version of my custom map has fixed that separate bug, so human-controlled noPU nations can produce infantry, artillery, ships, etc., and the Hard/Fast AI controlled nations will just produce infantry.

This is still not the desired behavior, but at least it's not crashing the game.

@TheDog-GH
Copy link
Contributor

Do all your nations have a Capital, even fake ones?

@JGreenLowe
Copy link
Contributor

I believe so! Sowjets_Puppet_States are in Afghanistan, French are in Sahara, Dutch are in Himalaya, Chinese are in Mongolia, and Minor_Axis_Powers are in Greenland.

And then the majors have their capitals in the usual places: Washington, London, Berlin, Rome, Moscow, Tokyo.

That's eleven, right? It's the 11 Nation Mod. I don't think I missed any.

@TheDog-GH
Copy link
Contributor

Have you tried 2.5, if so did it error and give you more info?

@WCSumpton
Copy link
Contributor

playerAttachment, rulesAttachment should only be one each per player. This maybe causing some of the problems.

Cheers...

@JGreenLowe
Copy link
Contributor

Thanks, but I remembered when you taught me that lesson two years ago, and I was careful to only have one rulesAttachment per player. In fact, some players have no special rulesAttachment. Here are all the rulesAttachments in my .xml:

<!--  Rules Restrictions -->
    <!-- Sowjets_Puppet_States Rules -->
   <attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
		<option name="productionPerXTerritories" value="infantry" count="2"/>
		<option name="productionPerXTerritories" value="artillery" count="3"/>
		<option name="productionPerXTerritories" value="transport" count="4"/>
		<option name="productionPerXTerritories" value="submarine" count="5"/>
		<option name="placementAnyTerritory" value="true"/>
		<option name="placementAnySeaZone" value="true"/>		
		<option name="placementCapturedTerritory" value="true"/>
		<option name="placementPerTerritory" value="5"/>
	</attachment>
    <!-- French Rules -->
    <attachment name="rulesAttachment" attachTo="French" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
		<option name="productionPerXTerritories" value="infantry" count="2"/>
		<option name="productionPerXTerritories" value="transport" count="3"/>
		<option name="productionPerXTerritories" value="cruiser" count="4"/>
		<option name="productionPerXTerritories" value="fighter" count="6"/>
		<option name="productionPerXTerritories" value="armour" count="7"/>
		<option name="placementAnyTerritory" value="true"/>
		<option name="placementAnySeaZone" value="true"/>		
		<option name="placementCapturedTerritory" value="true"/>
		<option name="placementPerTerritory" value="5"/>
    </attachment>
    <!-- Minor_Axis_Powers Rules -->
    <attachment name="rulesAttachment" attachTo="Minor_Axis_Powers" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
		<option name="productionPerXTerritories" value="infantry" count="2"/>
		<option name="productionPerXTerritories" value="artillery" count="3"/>
		<option name="productionPerXTerritories" value="transport" count="4"/>
		<option name="productionPerXTerritories" value="armour" count="5"/>
		<option name="productionPerXTerritories" value="cruiser" count="6"/>		
		<option name="placementAnyTerritory" value="true"/>
		<option name="placementAnySeaZone" value="true"/>		
		<option name="placementCapturedTerritory" value="true"/>
		<option name="placementPerTerritory" value="5"/>
    </attachment>
    <!-- Dutch Rules -->
    <attachment name="rulesAttachment" attachTo="Dutch" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
		<option name="productionPerXTerritories" value="infantry" count="2"/>
		<option name="productionPerXTerritories" value="transport" count="3"/>
		<option name="productionPerXTerritories" value="submarine" count="4"/>
		<option name="productionPerXTerritories" value="destroyer" count="5"/>
		<option name="placementAnyTerritory" value="true"/>
		<option name="placementAnySeaZone" value="true"/>		
		<option name="placementCapturedTerritory" value="true"/>
		<option name="placementPerTerritory" value="5"/>
    </attachment>
    <!-- Chinese Rules -->
    <attachment name="rulesAttachment" attachTo="Chinese" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
      <option name="movementRestrictionTerritories" value="Chinghai:Ningxia:Sikang:Yunnan:Hupeh:Fukien:Suiyuan:Manchuria:Kiangsu:Kwangtung"/>
      <option name="movementRestrictionType" value="allowed"/>
		<option name="productionPerXTerritories" value="infantry" count="2"/>
		<option name="productionPerXTerritories" value="artillery" count="4"/>
		<option name="productionPerXTerritories" value="fighter" count="5"/>
		<option name="productionPerXTerritories" value="transport" count="8"/>      
		<option name="placementAnyTerritory" value="true"/>
		<option name="placementAnySeaZone" value="true"/>		
      <option name="placementCapturedTerritory" value="true"/>
      <option name="placementPerTerritory" value="3"/>
    </attachment>              

@WCSumpton
Copy link
Contributor

WCSumpton commented Feb 9, 2025

Nice!

After making those changes, I was able to run your xml using world_war_ii_v3 with Fast_AI and seen no errors. Will do more testing.

Question, how long/rounds until this error shows?

Cheers...

@JGreenLowe
Copy link
Contributor

Thanks! The error shows up the first time a HardAI or FastAI begins its turn. So, if Russia is a HardAI, then in round 1 at the start of Russia's turn the game will crash.

@WCSumpton
Copy link
Contributor

I'm not able to reproduce this error. I'm using your attached xml in world_war_ii_v3, setting all players to Hard/Fast AI and encounter no errors between 5 and 10 rounds.

I am sorry. I'm trying to reproduce this error, but it seems that I'm not able.

Cheers...

WW2v3-1939-11N-custom.txt

@WCSumpton
Copy link
Contributor

@JGreenLowe

I've checked the engine code for "territoryIsPassableAndNotRestricted", and it seems more for placement/movement and not with purchaseNoPU. So, I'm still unable to figure out what is happening. I will be going to bed soon, and tomorrow is the Super Bowl, so I'm not sure how much time I can spend on this until Monday-Tuesday.

Again sorry.

Cheers...

@TheDog-GH
Copy link
Contributor

@JGreenLowe
You did upgrade to the latest 2.7, yes?

@WCSumpton
Copy link
Contributor

@JGreenLowe, @TheDog-GH

I tested using both 2.5 and 2.7+. I'm beginning to think its map related.

Cheers

@JGreenLowe
Copy link
Contributor

ww2v3_11n.zip

Here's the complete folder I'm using, including the map.

@WCSumpton
Copy link
Contributor

Thank you!

I've tested all the maps, with only WW2v3-1939-11N-test.xml showing errors. This error was because French and Minor_Axis_Powers not having required Capitals (Sahara and Greenland respectively). Also, in WW2v3-1939-11N-test.xml, I noticed that the rulesAttachment were not combined (these I did not change). Because there are no playerAttachment, I decided to set the option for not having capitals to true for both French and Minor_Axis_Powers thus I did not change the status of Sahara or Greenland. After changing their capital requirements, WW2v3-1939-11N-test.xml was able to run 5 rounds with no errors and all players set to Fast_AI.

I tested WW2v3-1939-11N-custom.xml with all players at Fast_AI, all players at Hard_AI, all axis as Fast_AI with allies as Hard_AI, only Russians as Fast_AI, and one more time as only the Sowjets_Puppet_States as Hard_AI. There were no changes made to the xml and all games played with no errors.

All tests were made on engine version 2.7.14934.

Cheers...

@JGreenLowe
Copy link
Contributor

OK -- thank you for your support! WW2v3-1939-11N-test was just for debugging, so it doesn't need to work. The only map that's new is WW2v3-1939-11N-custom. Sorry I didn't make that clear in advance.

I believe the map works fine on 2.7; this is probably just a 2.6 bug that's already been fixed. I am currently playing a game on the forum on another map with an opponent who specifically requested that we use 2.6, and I don't want to be constantly reinstalling different versions, but when that game is over I will continue my development of this map using 2.7!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.6 Error Report Issue reported via the in-game error reporter
Projects
None yet
Development

No branches or pull requests

4 participants