Phase 4. Hold'em, and it's the only table in the casino that is a session rather than a game: you buy in, play as many hands as you like, and leave with what's in front of you. So the live row spans hands and chips cross the border exactly twice. Everything in between is inside the engine. The bots move inside ApplyMove, as UNO's do, which is what keeps poker off a socket: shove all-in and the flop, turn, river, showdown and payout all come back in one response, as a script the felt plays back. The CFR policy the plan called "the single highest-value asset in either repo" was never read. Not once, in the whole life of the game: the trainer wrote its info-set keys under IP/OOP and the runtime looked them up under BTN/SB/BB, so every lookup missed and fell silently through to a pot-odds heuristic. Nothing looked broken, because a policy miss is not an error. And it was the wrong policy anyway — ten big blinds deep, trained on a tree where a call always ends the street, which is not poker. So the trainer is rewritten to play the real engine through the real reducer, at every stack depth the table deals, and the trainer and the table now build the key with the same function so they cannot drift apart again. A test fails if the bots stop finding themselves in it. Three money bugs, and the tests earned their keep. Chip conservation across a hundred sessions caught an uncalled bet that minted chips. A var-init ordering trap meant every card was identical, every showdown tied and every bot believed it held exactly 50% equity. And the browser caught the rake being silently zero — the tier said 5 meaning percent, the casino handed it 0.05 meaning a fraction, and integer division took the house's cut down to nothing. Claude-Session: https://claude.ai/code/session_013M5nD7PgUboJXoDcYHzpuJ
52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Every page the casino routes to must be in the games template set. This is not
|
|
// a fussy test: uno shipped with its handler wired, its engine tested and its
|
|
// template written, and every visit to the table answered "unknown page" with a
|
|
// 500 — because the page was never added to the list server.go parses. Nothing
|
|
// else caught it, since the other tests call the handlers straight and never go
|
|
// through render(). Add a game, add it here.
|
|
func TestEveryCasinoPageRenders(t *testing.T) {
|
|
s := newCasino(t)
|
|
|
|
pages := []string{
|
|
"/games",
|
|
"/games/blackjack",
|
|
"/games/hangman",
|
|
"/games/solitaire",
|
|
"/games/trivia",
|
|
"/games/uno",
|
|
"/games/holdem",
|
|
}
|
|
|
|
mux := http.NewServeMux()
|
|
s.casinoRoutes(mux)
|
|
|
|
for _, path := range pages {
|
|
t.Run(path, func(t *testing.T) {
|
|
w := httptest.NewRecorder()
|
|
mux.ServeHTTP(w, as(t, s, "reala", "GET", path, nil))
|
|
|
|
if w.Code != http.StatusOK {
|
|
t.Fatalf("GET %s = %d, want 200 (body: %s)", path, w.Code, strings.TrimSpace(w.Body.String()))
|
|
}
|
|
// render() writes the 500 as a body and a page that fails halfway
|
|
// through still comes back 200, so look at what was actually served.
|
|
body := w.Body.String()
|
|
if strings.Contains(body, "unknown page") {
|
|
t.Fatalf("GET %s served the unknown-page error: the template is missing from the games set in server.go", path)
|
|
}
|
|
if !strings.Contains(body, "</html>") {
|
|
t.Fatalf("GET %s did not render a whole page (%d bytes) — the template blew up mid-render", path, len(body))
|
|
}
|
|
})
|
|
}
|
|
}
|