Merge pull request #892 from GKnirps/king_tourist_bug

Add documentation for tourist trade bug in King
This commit is contained in:
Jeff Atwood
2023-08-28 11:33:08 -07:00
committed by GitHub
2 changed files with 19 additions and 2 deletions

View File

@@ -78,3 +78,18 @@ On basic line 1310 we see this:
but it should probably be:
1310 IF J=0 THEN 1324
### Bug 5
On basic line 1390 the income from tourism is calculated:
```
1390 A=INT(A+Q)
1400 V1=INT(((B-P1)*22)+(RND(1)*500))
1405 V2=INT((2000-D)*15)
1410 PRINT " YOU MADE";ABS(INT(V1-V2));"RALLODS FROM TOURIST TRADE."
```
It is very easily possible that `V2` is larger than `V1` e.g. if all of the land has been sold. In the original game this does not make a difference because of Bug 1 (see above).
However, judging by how `V1` and `V2` are handled in the code, it looks like `V1` is the basic income from tourism and `V2` is a deduction for pollution. When `ABS(INT(V1-V2))` is used as earnings from tourism, the player actually _gets_ money for a large enough pollution. So a better solution would be to let `V1 - V2` cap out at 0, so once the pollution is large enough, there is no income from tourists anymore.

View File

@@ -61,7 +61,7 @@ class GameState:
return self.countrymen - self.population_change
def sell_land(self, amount: int) -> None:
assert amount < self.farmland
assert amount <= self.farmland
self.land -= amount
self.rallods += self.land_buy_price * amount
@@ -126,7 +126,9 @@ class GameState:
def handle_tourist_trade(self) -> None:
V1 = int(self.settled_people * 22 + random() * 500)
V2 = int((INITIAL_LAND - self.land) * 15)
tourist_trade_earnings = int(V1 - V2)
tourist_trade_earnings = 0
if V1 > V2:
tourist_trade_earnings = V1 - V2
print(f" YOU MADE {tourist_trade_earnings} RALLODS FROM TOURIST TRADE.")
if V2 != 0 and not (V1 - V2 >= self.tourism_earnings):
print(" DECREASE BECAUSE ")