diff options
Diffstat (limited to 'internal/casino/craps_simplified_test.go')
| -rw-r--r-- | internal/casino/craps_simplified_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/casino/craps_simplified_test.go b/internal/casino/craps_simplified_test.go new file mode 100644 index 0000000..e36bc2d --- /dev/null +++ b/internal/casino/craps_simplified_test.go @@ -0,0 +1,35 @@ +package casino + +import "testing" + +func TestSimplifiedCrapsAll36SettlementsAndHouseEdge(t *testing.T) { + // Total returns for a one-credit wager, including the winning stake. + returns := [13]int{2: 4, 3: 2, 4: 2, 10: 3, 11: 3, 12: 6} + totalReturned, wins := 0, 0 + for a := 1; a <= 6; a++ { + for b := 1; b <= 6; b++ { + tb := variantFixture("simplified") + tb.join("a") + w := &testWallet{chips: 100} + tb.bet("a", "pass", 1, w) + want := returns[a+b] + for _, row := range tb.projectionFor(tb.players.get("a")) { + if row.Total == a+b && row.Net != want-1 { + t.Fatalf("preview for %d+%d: got %d, want %d", a, b, row.Net, want-1) + } + } + tb.resolveRoll(a, b) + if w.paid != want || len(w.open) != 0 || tb.players.get("a").HasBet || tb.point != 0 { + t.Fatalf("roll %d+%d: paid %d, want %d; open %v, point %d", a, b, w.paid, want, w.open, tb.point) + } + totalReturned += w.paid + if w.paid > 0 { + wins++ + } + } + } + // 36 credits wagered, 35 returned: house edge exactly 1/36 = 2.777...%. + if totalReturned != 35 || wins != 12 { + t.Fatalf("all 36 rolls: returned %d, wins %d", totalReturned, wins) + } +} |
