triplea-game / triplea

TripleA is a turn based strategy game and board game engine, similar to Axis & Allies or Risk.
https://triplea-game.org/
GNU General Public License v3.0
1.33k stars 391 forks source link

Incorrect unit repair #2256

Closed panther2 closed 7 years ago

panther2 commented 7 years ago

My Operating System:

Win 7/64

TripleA version:

1.9.0.0.6242 (noted with)

Map:

ww2Global40_2nd_Ed

Can you describe how to trigger the error? (eg: what sequence of actions will recreate it?)

Move your damaged capital ship (Battleship or Carrier) to a friendly naval base. On the next Purchase and Repair Phase it will be repaired even if your capital is in enemy's hand.

Instead of this error, what should have happened?

As long as your capital is taken by the enemy, there is no "Purchase and Repair Phase". The placement of a damaged capital ship in a SZ next to a friendly naval base leads to a repair only during "Purchase and Repair Phase".

TripleA correctly skips repair for facilities but incorrectly repairs units.

Rule discussion here: http://www.axisandallies.org/forums/index.php?topic=40380.0

Savegame to reproduce: test3.zip

ron-murhammer commented 7 years ago

@panther2 Is this a new bug or has this always existed in TripleA?

Cernelius commented 7 years ago

Yah, I was just thinking you may want to add a ### step specifically asking if the issue is known to be absent in a previous version (like if it is something that used to work fine for the user, until recently). Just saying.

ssoloff commented 7 years ago

I believe it happens in 1.9.0.0.3635, as well. Not sure if I reproduced it correctly using the attached save game, though. I had to use edit mode to give the battleship in SZ 93 one hit during France's first turn after load, and then observed it get repaired at the start of France's following turn.

panther2 commented 7 years ago

It was because of the above stated discussion that I tested paticularly this issue. I am not aware that it had been subject to discussion before, but chances are that the issue had been there before.

@ssoloff - using the savegame in history mode shows the issue (Fr1, Fr2), too.

DanVanAtta commented 7 years ago

:champagne: for @panther2 on this bug report.

For clarity on the build version prefix '6242'. It is not 'earliest known' version, but version tested and reported. Helpful for tester coordination. I want the first question for such reports to be "is this a major" before we ask whether it is live or not.

panther2 commented 7 years ago

Thank you @DanVanAtta , and good point, too.

panther2 commented 7 years ago

@ron-murhammer While there please note https://github.com/triplea-maps/world_war_ii_global/issues/23 (new issue).

During a discussion about the question where UK damaged battleships being for example in the Pacific can be repaired while Calcutta is in enemy's hands and London is still British, this map-issue came up.

(For rules details - if interested - please see starting from http://www.axisandallies.org/forums/index.php?topic=40380.msg1687000#msg1687000)

Thank you.

ron-murhammer commented 7 years ago

@panther2 The fix for this should now be in the pre-release. Please test and let me know if its works as expected.

panther2 commented 7 years ago

@ron-murhammer Thank you, I have done an extensive test using 6555 documented in the attached savegame. Now the French battleship is not repaired when Paris is in enemy's hand. When France retakes Paris, the battleship is repaired correctly. Also I have tested the correct handling of repairs for British battleships in case either London or Calcutta is in enemy's hand, as discussed in the above mentioned thread http://www.axisandallies.org/forums/index.php?topic=40380.msg1687000#msg1687000 . This all (almost) works fine!

However there is one incorrect aspect remaining: The British battleship at Southern France (SZ93) should be repaired on UK1, although Paris is in enemy's hand. The operativeness of any base is not affected by the capture of the base owner's capital. The operativeness of a base is affected by damage (3 and more) only.

When it comes to repairing ships there are only two relevant questions for the owner of that ship:

  1. Do I own my capital, so my Purchase and Repair Phase takes place?
  2. No - so I can't repair. / Yes - so is my damaged capital ship at a friendly (own or allied) operative (=2 or less damage) naval base?

So in this case the owner of the British battleship has his capital and is at a friendly (French) and undamaged base. Repair can take place. Here the engine incorrectly seems to include a check who owns Paris.

Regarding the special aspects of UK repair rules, I won't further elaborate here, as this is handled correctly by the engine and can be read in the above mentioned thread.

repair_complete.zip

ron-murhammer commented 7 years ago

@panther2 Wait a sec. I was thinking whether a naval base repairs ships depends on if the owner of the naval base controls their capital. For example, if France loses Paris then the naval base in Southern France won't repair French ships or allied ships.

You are saying the rule is actually that a nation can only repair its ships if it owns its capital and could even repair at naval bases of allied nations that don't own their capitals? This would mean if you don't own your capital there is no way to repair your ships.

Just want to make sure that is the case.

panther2 commented 7 years ago

@ron-murhammer

By the rules the repair of damaged ships takes place during the "Purchase and Repair-Phase" of the ship-unit owner's nation. When the capital of the ship-owner's nation is in enemy's hands the Purchase and Repair-Phase is skipped. So there is no repair. In SZ93 of the above example. France on its turn has lost Paris, so France has no P+R-Phase to repair it's battleship, although it is at a friendly (own) and operative naval base. UK on the other hand on its turn has its capital, so UK has a P+R-Phase. As the French naval base is friendly and operative UK can repair its damaged ship.

It is the (ship unit owner's) nation being able to pay for repair (thus not represented by an IPC cost) during the P+R-Phase that primarily determines the ability to repair.

So you are right, if you don't own your capital there is no way to repair your ships. The loss of a capital does not affect the operativeness of any Air and Naval Base. But it eliminates the Repair-Phase of that power (The nation has no administration and no budget to grant money for puchases and repairs.).

UK is special: As UK must have lost both of their capitals to be in that situation. As long as UK has only lost one of its capitals, it can repair at all friendly operative bases around the world, except the British bases that belong to the economy of the lost regional capital.

Cernelius commented 7 years ago

The loss of a capital does not affect the operativeness of any Air and Naval Base.

As long as UK has only lost one of its capitals, it can repair at all friendly operative bases around the world, except the British bases that belong to the economy of the lost regional capital.

So, the rule would be that having no capital will not impede you to passively letting someone else with a capital repair at your base, with the only one exception that it does for the British capitals only (British bases in territories whose related capital is currently not British owned), but only with respect to British ships, yet still always allowing non-British ones to repair at any British bases the British themselves may not be allowed to?

panther2 commented 7 years ago

For repairs the rulebooks only require:

It is irrelevant whether the owner of an allied naval base has his capital. The base only conducts repairs. It is the ship's owning nation that (in case it has its capital) commands the ship to be repaired and pays for it (the costs being only a fraction of 1 IPC - thus not represented).

Britain is special because of its two economies. But the ship does not belong to an economy but to Britain as a whole. So as long as there is a regional capital, this remaining capital can command the damaged ship to be repaired at any allied naval base as well as British naval bases of its own economy (and "pay" for it). When both regional capitals are lost, Britain is at the same status as any other nation without capital, having no chance to repair anywhere.

This is the perspective covered by the rulebooks.

Cernelius commented 7 years ago

I was mostly suggesting to specifically confirm that British bases owned by a British economy without capital still allow repair to any allied ships but don't allow repair to British ships.

I'm just abstaining giving a personal opinion on the sensibility of these rules, but you may want to give alternative options for custom maps; up to you. Maybe ask the TWW mapmakers.

panther2 commented 7 years ago

I was mostly suggesting to specifically confirm that British bases owned by a British economy without capital still allow repair to any allied ships but don't allow repair to British ships.

Ah ok. Confirmed! That is valid for every nation without capital - Allies can repair at those naval bases, provided they have a P+R phase (an own capital) to do so. I just wanted to explain again that the point of view is not from the base's side, when it comes to repairs. The base just needs to be friendly and operative.

Cernelius commented 7 years ago

Yes. I didn't mean to reverse the point of view. What I was sayin is, more specifically:

In the scenario of British owning only part of its capitals, British bases owned by a British economy without capital still allow repair to any allied ships but don't allow repair to British ships, even tho these ships are themselves able to repair (at any other naval bases), for British still having a capital.

panther2 commented 7 years ago

The British economies have separate Purchase and Repair-Phases. When both capitals are held by UK, ships can be commanded to every friendly base for repair. When Calcutta is lost, only London can command British ships to every friendly base for repair except British bases belonging to the Pacific economy. When London is lost, only Calcutta can command British ships to every friendly base for repair except British bases belonging to the Europe economy.

Every Ally holding its own capital can command its ship to every friendly base (regardless whether the allied base owner holds its capital).

You do a turn around of the point of view: It is not the "base that is allowed to repair" that is relevant here (when operational). It is the ship unit owner who is allowed to repair (or not).

Cernelius commented 7 years ago

That is actually what I wanted to clarify; maybe I didn't. With "allow repair" I didn’t' mean that the bases, or the players owning them, are repairing; I meant "allow the ships to repair themselves" or "satisfy the naval base requirement for the ships to repair themselves".

So, let's say I can rewrite it this way:

In the scenario of British owning only part of its capitals, British bases owned by a British economy without capital still allow any allied ships to repair themselves but don't allow British ships to repair themselves, even tho these ships are themselves able to repair (at any other naval bases), for British still having a capital.

And that is not something I'm saying; but my rewording of what I'm understanding here. Anyways, that was just for having a confirmation, if anybody needs it.

Cernelius commented 7 years ago

Basically, the issue is that when I said "the base allows repair" you understood that I was saying "the base is allowed to repair", while I was saying "the base allows the ships to repair themselves" or "the ships are allowed to repair themselves by the base" (if I'm being grammatically correct, since I'm not English).

But nevermind if I'm adding confusion.

panther2 commented 7 years ago

I am afraid I have nothing more to add.

Generally, I am just explaining the rules sticking close to the rulebooks. As it is always easier to explain and understand the rules by what is written there rather than by what is not written there and/or (sometimes mis-) interpreted into them.

If your own words or interpretation help you to better understand the issue it's just fine. :smile:

ron-murhammer commented 7 years ago

@panther2 Latest changes should be in pre-release. It should now work properly for everything except the UK scenario. I have to think about whether there is an easy way to meet the UK functionality with how the dual UK players are setup in the engine.

panther2 commented 7 years ago

@ron-murhammer

Thank you. I have done another extensive testing (6564). See the attached savegame. The remaining issue, stated here https://github.com/triplea-game/triplea/issues/2256#issuecomment-328358100 is resolved now.

But (as expected) we now have issues concerning UK with British ships.

The scenario begins when India is taken by Japan. Here all damaged British ships are treated correctly, except the one at a British harbour (SZ37 Malaya). This ship is incorrectly repaired, though Calcutta is in Japan's hands.

One round later India is British again and London has been taken by Germany: Now no British ship regardless where it is in the world will be repaired (though Calcutta is British).

It looks like when London is in enemy's hands TripleA treats UK like any other nation.

I think I have identified the (or at least one) reason: Triple A incorrectly repairs those units at the beginning of the Combat Move phase, as I noticed from the history. This kind of (unit) repair should take place during the Purchase- and Repair-Phase (coded probably at the very end of that phase). This would probably solve the UK-problem with its two economies. As every economy has its own P+R-Phase including ship-repairs.

repair_setup_new_complete.zip

panther2 commented 7 years ago

@ron-murhammer

This is the result of testing the latest scenario using 6635:

When India is captured by Japan

When London is captured by Germany

repair_setup_new_complete_2.zip

Have you thought about moving the repair-logic to the Purchase-and Repair-Phase (please see my last statement)?

In the savegame you can see in history mode, that on UK1 (India is taken by Japan) the repair takes place at the beginnig of the Combat Move phase, while on UK2 (London is taken by Germany) there is no unit repair at all.

ron-murhammer commented 7 years ago

@panther2 Sorry, needed to make a small change to the code. You also need to add this in the game.xml to test:

Replace: <step name="britishCombatMove" player="British" delegate="move"/>

With:

<step name="britishCombatMove" player="British" delegate="move">
<stepProperty name="combinedTurns" value="British:UK_Pacific"/>
</step>

Also, I did see your suggestion around moving repair logic to purchase/repair. I'm trying to avoid major changes for this fix and I'm not sure exactly why it was put where it is but I assume there is some reason :)

panther2 commented 7 years ago

Thanks, @ron-murhammer . Already night here, so I will test this tomorrow.

Note to myself: code change starts at line 1369

panther2 commented 7 years ago

@ron-murhammer

Success!!!

I set up the scenario again using the modified game.xml with 6654. Now everything is handled correctly. All repairs/non repairs are done according to the rules - respecting the ownership of the local UK-capital.

Now we have to update the map-repo accordingly (https://github.com/triplea-maps/world_war_ii_global/issues/24 ).

Inside the zip find the modified xml, the scenario setup and the savegame after completing turn 2.

savedGames.zip

RoiEXLab commented 7 years ago

@panther2 Can this issue be closed then?

panther2 commented 7 years ago

@RoiEXLab

IMHO yes, I must have missed to hit "Close and comment" :wink:

ron-murhammer commented 7 years ago

@panther2 Mind submitting the PR to update the appropriate game.xml for Global? I'm guessing this should be updated in all of the various global XMLs but not sure.

panther2 commented 7 years ago

@ron-murhammer

I have already commented on this here: https://github.com/triplea-maps/world_war_ii_global/issues/24

I will submit a PR soon. I will give you a note when it is done.

panther2 commented 7 years ago

@ron-murhammer Done: https://github.com/triplea-maps/world_war_ii_global/pull/25