tobymao / 18xx

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

[1846] OR payout effects on stock market wrong #760

Closed wcraigtrader closed 4 years ago

wcraigtrader commented 4 years ago

In OR 1.2 the IC ran 3 trains for $140. Its stock price was $70, so it should have double-jumped to $90, but instead its price dropped to $60.

Player 2 operates IC
IC passes
IC spends $20 and lays tile #9 with rotation 2 on F6
IC spends $20 and lays tile #8 with rotation 3 on E5
IC places a token on D6 for $80
IC runs a 2 train for $30 (D6, G7)
IC runs a 2 train for $40 (G7, G9)
IC runs a 2 train for $70 (G9, J10)
IC pays out $140 = $14 x 10 shares
Player 2 receives $42 = $14 x 3 shares
IC receives $56 = $14 x 4 shares
IC's share price changes from $70 to $60

1846-force-close-a-company-in-OR1-1.txt

tobymao commented 4 years ago

@wcraigtrader can you repro this for me? the game is invalid now and it may be fixed

wcraigtrader commented 4 years ago

OK, new game, OR1.2. Each snapshot is taken right before the payout, and for each one I full-paid:

First up, GT:

GT spends $40 and lays tile #294 with rotation 0 on C15
GT spends $20 and lays tile #9 with rotation 1 on D8
GT buys Michigan Southern from Player 3 for $60
GT receives $45, a 2 train, and a token on C15
GT places a token on D6 for $80
GT runs a 3/5 train for $120 (D14, C15, C17)
GT pays out $120 = $12 x 10 shares
Player 3 receives $24 = $12 x 2 shares
GT receives $72 = $12 x 6 shares
GT's share price changes from $90 to $80
GT buys Steamboat Company from Player 3 for $40
GT finishes buying trains
GT skips buying companies

GT should have single-jumped from $90 to $100 1846-payout-single-jump.txt

Next up, IC:

Player 1 operates IC
IC passes
IC spends $20 and lays tile #9 with rotation 2 on F6
IC spends $20 and lays tile #8 with rotation 3 on E5
IC places a token on D6 for $80
IC runs a 2 train for $30 (D6, G7)
IC runs a 2 train for $40 (G7, G9)
IC runs a 2 train for $70 (G9, J10)
IC pays out $140 = $14 x 10 shares
Player 1 receives $42 = $14 x 3 shares
IC receives $56 = $14 x 4 shares
IC's share price changes from $70 to $60
IC buys Ohio & Indiana from Player 1 for $40
IC finishes buying trains
IC skips buying companies

IC should have double-jumped from $70 to $90. 1846-payout-double-jump.txt

Finally the NYC:

Player 2 operates NYC
NYC passes
NYC spends $20 and lays tile #294 with rotation 0 on E17
NYC spends $20 and lays tile #8 with rotation 2 on E15
NYC places a token on D14 for $80
NYC runs a 2 train for $80 (C15, D14)
NYC runs a 2 train for $80 (C15, D14)
NYC runs a 2 train for $80 (E17, D14)
NYC pays out $240 = $24 x 10 shares
Player 2 receives $72 = $24 x 3 shares
NYC receives $96 = $24 x 4 shares
NYC's share price changes from $70 to $60

NYC should have double-jumped to $90 (not a triple jump, because that can't happen unless the stock price starts at $150 or higher). 1846-payout-not-a-triple-jump.txt

wcraigtrader commented 4 years ago

Without looking at the code, I'd guess the problem is a division-by-10 error in comparing the payout-per-share against the market price.

KillerOrca commented 4 years ago

Also visible in game ID 2428. Can provide other info if needed.

gchambers419 commented 4 years ago

This failed for me with HEAD on master

Player 3 operates GT GT passes GT spends $100 and lays tile #294 with rotation 0 on C15 GT spends $20 and lays tile #6 with rotation 1 on D14 GT runs a 2 train for $60 (B16, B18) GT runs a 3/5 train for $120 (C5, D6, C9, C15, B16) GT pays out $180 = $18 x 10 shares Player 3 receives $54 = $18 x 3 shares GT receives $90 = $18 x 5 shares GT's share price changes from $60 to $50 GT skips buying trains

Game data from hotseat available.

tobymao commented 4 years ago

@gchambers419 data?

gchambers419 commented 4 years ago

{ "status": "active", "actions": [ { "type": "bid", "entity": "Player 3", "entity_type": "player", "id": 1, "company": "MS", "price": 60 }, { "type": "bid", "entity": "Player 2", "entity_type": "player", "id": 2, "company": "BIG4", "price": 40 }, { "type": "bid", "entity": "Player 1", "entity_type": "player", "id": 3, "company": "MAIL", "price": 80 }, { "type": "bid", "entity": "Player 3", "entity_type": "player", "id": 4, "company": "TBC", "price": 60 }, { "type": "bid", "entity": "Player 2", "entity_type": "player", "id": 5, "company": "O&I", "price": 40 }, { "type": "bid", "entity": "Player 1", "entity_type": "player", "id": 6, "company": "C&WI", "price": 60 }, { "type": "par", "entity": "Player 1", "entity_type": "player", "id": 7, "corporation": "NYC", "share_price": "100,0,10" }, { "type": "par", "entity": "Player 2", "entity_type": "player", "id": 8, "corporation": "IC", "share_price": "100,0,10" }, { "type": "par", "entity": "Player 3", "entity_type": "player", "id": 9, "corporation": "GT", "share_price": "100,0,10" }, { "type": "lay_tile", "entity": "MS", "entity_type": "minor", "id": 10, "hex": "B16", "tile": "6-0", "rotation": 4 }, { "type": "run_routes", "entity": "MS", "entity_type": "minor", "id": 11, "routes": [ { "train": "2-0", "connections": [ [ "C15", "B16" ] ] } ] }, { "type": "lay_tile", "entity": "BIG4", "entity_type": "minor", "id": 12, "hex": "G9", "tile": "57-0", "rotation": 1 }, { "type": "lay_tile", "entity": "BIG4", "entity_type": "minor", "id": 13, "hex": "G7", "tile": "6-1", "rotation": 4 }, { "type": "run_routes", "entity": "BIG4", "entity_type": "minor", "id": 14, "routes": [ { "train": "2-1", "connections": [ [ "G9", "G7" ] ] } ] }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 15 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 16, "hex": "E19", "tile": "8-0", "rotation": 1 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 17, "hex": "E17", "tile": "293-0", "rotation": 1 }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 18 }, { "type": "buy_train", "entity": "NYC", "entity_type": "corporation", "id": 19, "train": "2-2", "price": 80 }, { "type": "buy_train", "entity": "NYC", "entity_type": "corporation", "id": 20, "train": "2-3", "price": 80 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 21 }, { "type": "lay_tile", "entity": "IC", "entity_type": "corporation", "id": 22, "hex": "J4", "tile": "9-0", "rotation": 0 }, { "type": "lay_tile", "entity": "IC", "entity_type": "corporation", "id": 23, "hex": "I3", "tile": "9-1", "rotation": 1 }, { "type": "place_token", "entity": "IC", "entity_type": "corporation", "id": 24, "city": "I5-0-0", "slot": 0 }, { "type": "buy_train", "entity": "IC", "entity_type": "corporation", "id": 25, "train": "2-4", "price": 80 }, { "type": "buy_train", "entity": "IC", "entity_type": "corporation", "id": 26, "train": "2-5", "price": 80 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 27 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 28 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 29 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 30, "hex": "C13", "tile": "9-2", "rotation": 1 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 31, "hex": "C11", "tile": "9-3", "rotation": 1 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 32 }, { "type": "buy_train", "entity": "GT", "entity_type": "corporation", "id": 33, "train": "2-6", "price": 80 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 34 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 35 }, { "type": "lay_tile", "entity": "MS", "entity_type": "minor", "id": 36, "hex": "C9", "tile": "6-2", "rotation": 4 }, { "type": "run_routes", "entity": "MS", "entity_type": "minor", "id": 37, "routes": [ { "train": "2-0", "connections": [ [ "C15", "B16" ] ] } ] }, { "type": "lay_tile", "entity": "BIG4", "entity_type": "minor", "id": 38, "hex": "G11", "tile": "9-4", "rotation": 1 }, { "type": "run_routes", "entity": "BIG4", "entity_type": "minor", "id": 39, "routes": [ { "train": "2-1", "connections": [ [ "G9", "G7" ] ] } ] }, { "type": "sell_shares", "entity": "NYC", "entity_type": "corporation", "id": 40, "shares": [ "NYC_1", "NYC_2" ], "percent": 20, "share_price": 80 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 41, "hex": "E15", "tile": "9-5", "rotation": 1 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 42, "hex": "E13", "tile": "8-1", "rotation": 2 }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 43 }, { "type": "run_routes", "entity": "NYC", "entity_type": "corporation", "id": 44, "routes": [ { "train": "2-2", "connections": [ [ "C21", "D20" ] ] }, { "train": "2-3", "connections": [ [ "D20", "E19", "E17" ] ] } ] }, { "type": "dividend", "entity": "NYC", "entity_type": "corporation", "id": 45, "kind": "payout" }, { "type": "buy_train", "entity": "NYC", "entity_type": "corporation", "id": 46, "train": "4-0", "price": 160, "variant": "3/5" }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 47 }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 48 }, { "type": "sell_shares", "entity": "IC", "entity_type": "corporation", "id": 49, "shares": [ "IC_1", "IC_2" ], "percent": 20, "share_price": 80 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 50 }, { "type": "run_routes", "entity": "IC", "entity_type": "corporation", "id": 51, "routes": [ { "train": "2-4", "connections": [ [ "I5", "J4", "K3" ] ] }, { "train": "2-5", "connections": [ [ "I5", "I3", "I1" ] ] } ] }, { "type": "dividend", "entity": "IC", "entity_type": "corporation", "id": 52, "kind": "payout" }, { "type": "buy_train", "entity": "IC", "entity_type": "corporation", "id": 53, "train": "4-1", "price": 180, "variant": "4" }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 54 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 55 }, { "type": "sell_shares", "entity": "GT", "entity_type": "corporation", "id": 56, "shares": [ "GT_1", "GT_2" ], "percent": 20, "share_price": 80 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 57, "hex": "D8", "tile": "7-0", "rotation": 2 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 58, "hex": "D6", "tile": "298-0", "rotation": 0 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 59 }, { "type": "run_routes", "entity": "GT", "entity_type": "corporation", "id": 60, "routes": [ { "train": "2-6", "connections": [ [ "B18", "B16" ] ] } ] }, { "type": "dividend", "entity": "GT", "entity_type": "corporation", "id": 61, "kind": "payout" }, { "type": "buy_train", "entity": "GT", "entity_type": "corporation", "id": 62, "train": "4-2", "price": 160, "variant": "3/5" }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 63 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 64 }, { "type": "buy_shares", "entity": "Player 1", "entity_type": "player", "id": 65, "shares": [ "NYC_3" ] }, { "type": "buy_shares", "entity": "Player 2", "entity_type": "player", "id": 66, "shares": [ "IC_3" ] }, { "type": "buy_shares", "entity": "Player 3", "entity_type": "player", "id": 67, "shares": [ "GT_3" ] }, { "type": "pass", "entity": "Player 1", "entity_type": "player", "id": 68 }, { "type": "pass", "entity": "Player 2", "entity_type": "player", "id": 69 }, { "type": "pass", "entity": "Player 3", "entity_type": "player", "id": 70 }, { "type": "pass", "entity": "MS", "entity_type": "minor", "id": 71 }, { "type": "run_routes", "entity": "MS", "entity_type": "minor", "id": 72, "routes": [ { "train": "2-0", "connections": [ [ "C15", "B16" ] ] } ] }, { "type": "lay_tile", "entity": "BIG4", "entity_type": "minor", "id": 73, "hex": "G13", "tile": "57-1", "rotation": 1 }, { "type": "run_routes", "entity": "BIG4", "entity_type": "minor", "id": 74, "routes": [ { "train": "2-1", "connections": [ [ "G9", "G7" ] ] } ] }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 75 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 76, "hex": "D12", "tile": "8-2", "rotation": 5 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 77, "hex": "D10", "tile": "9-6", "rotation": 1 }, { "type": "run_routes", "entity": "NYC", "entity_type": "corporation", "id": 78, "routes": [ { "train": "2-2", "connections": [ [ "C21", "D20" ] ] }, { "train": "2-3", "connections": [ [ "D20", "E19", "E17" ] ] } ] }, { "type": "dividend", "entity": "NYC", "entity_type": "corporation", "id": 79, "kind": "payout" }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 80 }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 81 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 82 }, { "type": "lay_tile", "entity": "IC", "entity_type": "corporation", "id": 83, "hex": "H6", "tile": "9-7", "rotation": 0 }, { "type": "lay_tile", "entity": "IC", "entity_type": "corporation", "id": 84, "hex": "G9", "tile": "15-0", "rotation": 1 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 85 }, { "type": "run_routes", "entity": "IC", "entity_type": "corporation", "id": 86, "routes": [ { "train": "2-4", "connections": [ [ "I5", "J4", "K3" ] ] }, { "train": "2-5", "connections": [ [ "I5", "I3", "I1" ] ] }, { "train": "4-1", "connections": [ [ "G13", "G11", "G9" ], [ "G7", "G9" ], [ "G7", "H6", "I5" ] ] } ] }, { "type": "dividend", "entity": "IC", "entity_type": "corporation", "id": 87, "kind": "payout" }, { "type": "buy_train", "entity": "IC", "entity_type": "corporation", "id": 88, "train": "4-3", "price": 160, "variant": "3/5" }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 89 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 90 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 91, "hex": "B16", "tile": "619-0", "rotation": 4 }, { "type": "place_token", "entity": "GT", "entity_type": "corporation", "id": 92, "city": "298-0-0", "slot": 0 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 93 }, { "type": "run_routes", "entity": "GT", "entity_type": "corporation", "id": 94, "routes": [ { "train": "2-6", "connections": [ [ "B18", "B16" ] ] }, { "train": "4-2", "connections": [ [ "C5", "D6" ], [ "C9", "D8", "C7", "D6" ], [ "C15", "C13", "C11", "C9" ], [ "C15", "B16" ] ] } ] }, { "type": "dividend", "entity": "GT", "entity_type": "corporation", "id": 95, "kind": "payout" }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 96 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 97 }, { "type": "pass", "entity": "MS", "entity_type": "minor", "id": 98 }, { "type": "run_routes", "entity": "MS", "entity_type": "minor", "id": 99, "routes": [ { "train": "2-0", "connections": [ [ "C15", "B16" ] ] } ] }, { "type": "lay_tile", "entity": "BIG4", "entity_type": "minor", "id": 100, "hex": "G15", "tile": "57-2", "rotation": 1 }, { "type": "run_routes", "entity": "BIG4", "entity_type": "minor", "id": 101, "routes": [ { "train": "2-1", "connections": [ [ "G7", "G9" ] ] } ] }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 102 }, { "type": "lay_tile", "entity": "NYC", "entity_type": "corporation", "id": 103, "hex": "D8", "tile": "18-0", "rotation": 1 }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 104 }, { "type": "run_routes", "entity": "NYC", "entity_type": "corporation", "id": 105, "routes": [ { "train": "2-2", "connections": [ [ "C21", "D20" ] ] }, { "train": "4-0", "connections": [ [ "E17", "E15", "E13", "D12", "D10", "D8", "D6" ], [ "D20", "E19", "E17" ] ] } ] }, { "type": "dividend", "entity": "NYC", "entity_type": "corporation", "id": 106, "kind": "payout" }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 107 }, { "type": "pass", "entity": "NYC", "entity_type": "corporation", "id": 108 }, { "type": "sell_shares", "entity": "IC", "entity_type": "corporation", "id": 109, "shares": [ "IC_4" ], "percent": 10, "share_price": 50 }, { "type": "lay_tile", "entity": "IC", "entity_type": "corporation", "id": 110, "hex": "G15", "tile": "15-1", "rotation": 1 }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 111 }, { "type": "run_routes", "entity": "IC", "entity_type": "corporation", "id": 112, "routes": [ { "train": "2-4", "connections": [ [ "I5", "J4", "K3" ] ] }, { "train": "2-5", "connections": [ [ "I5", "I3", "I1" ] ] }, { "train": "4-1", "connections": [ [ "G13", "G11", "G9" ], [ "G7", "G9" ], [ "G7", "H6", "I5" ] ] } ] }, { "type": "dividend", "entity": "IC", "entity_type": "corporation", "id": 113, "kind": "payout" }, { "type": "pass", "entity": "IC", "entity_type": "corporation", "id": 114 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 115 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 116, "hex": "C15", "tile": "294-0", "rotation": 0 }, { "type": "lay_tile", "entity": "GT", "entity_type": "corporation", "id": 117, "hex": "D14", "tile": "6-3", "rotation": 1 }, { "type": "run_routes", "entity": "GT", "entity_type": "corporation", "id": 118, "routes": [ { "train": "2-6", "connections": [ [ "B18", "B16" ] ] }, { "train": "4-2", "connections": [ [ "C5", "D6" ], [ "C9", "D8", "C7", "D6" ], [ "C9", "C11", "C13", "C15" ], [ "B16", "C15" ] ] } ] }, { "type": "dividend", "entity": "GT", "entity_type": "corporation", "id": 119, "kind": "payout" }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 120 }, { "type": "pass", "entity": "GT", "entity_type": "corporation", "id": 121 } ], "id": "hs_ufmrwsqf_1592693408", "players": [ { "name": "Player 1" }, { "name": "Player 2" }, { "name": "Player 3" } ], "title": "1846", "description": "", "max_players": "3", "mode": "hotseat", "user": { "id": 0, "name": "You" }, "created_at": "2020-06-20", "loaded": true, "result": {} }

skofisk commented 4 years ago

The applied fix has been reverted/overwritten, compared to master.

tobymao commented 4 years ago

looks like @scottredracecar had a bad merge i fixed it again