tobymao / 18xx

A platform for playing 18xx games online!
https://18xx.games
Other
298 stars 185 forks source link

[System18: Britain] Incorrect route calculation with 4D train #11317

Closed ianwilson156 closed 1 week ago

ianwilson156 commented 2 weeks ago

https://18xx.games/game/184158

OR7.2, DGN running a 4D from London to S. Ireland via Birmingham & Coventry. I make that 2*(100+50+70+30+30(Wales)+40(Lon-port)) = 640, but the program calculates 780. It also gives a 80 mine bonus, but that is not doubled by the 4D, so should be only 40..

roseundy commented 2 weeks ago

Looks like the 4D isn't behaving as intended. It seems to be counting (and doubling) the dits on the route. The mine bonus is wrong too, as you noticed.

roseundy commented 2 weeks ago

The second problem is caused by adding the mine bonus for each train. This broke when I was asked to refactor my code to use the "extra_revenue" method.

ianwilson156 commented 2 weeks ago

I guess that a 4D could count (and double) a dit, if it had to - that is, there weren't enough cities. Unlikely, but you never know. It is supposed to count the 4 best revenue locations (one with a token).

roseundy commented 2 weeks ago

I haven't gotten to the bottom of the first issue yet. As far as I know, I haven't changed the code in a way that the 4D won't work correctly. Other games have 4Ds defined exactly the same way (and presumably work).

ianwilson156 commented 2 weeks ago

Which other games? I can only think of Ardennes, but in that the 4D must skip dits.

roseundy commented 2 weeks ago

I thought 18NY had a 4DE train that was similar, but now that I look at the rules it only counts stations with tokens and offboards. Hmmm.

roseundy commented 2 weeks ago

Found the bug, I was double-counting the doubled route bonuses for Scotland/Wales/London-Port. I went out of my way to double the revenue. Another bug caused by a change that I was suggested to make.