feat: honest AI opponent in quick game
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 14s
CI / ui (pull_request) Successful in 49s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m12s

New Game's quick game gains an explicit opponent selector — 🤖 AI (default)
or 👤 Random player. AI starts a game seated with a pooled robot that joins
and moves at once: no per-move timeout (a 7-day inactivity loss reusing the
turn-timeout sweeper), chat/nudge disabled, no statistics, the opponent shown
as 🤖 everywhere. The random path (disguised robot) is unchanged.

Driven by one game flag (games.vs_ai), set only on AI-started games so the
disguised path is never revealed; Matchmaker.StartVsAI seats the robot
directly (no open pool); the robot replies event-driven via the game service's
after-commit/after-create hook. Wire: vs_ai on EnqueueRequest + GameView.
This commit is contained in:
Ilia Denisov
2026-06-15 20:14:24 +02:00
parent 91d5c341ef
commit aa765a0c06
56 changed files with 901 additions and 86 deletions
+6 -1
View File
@@ -70,6 +70,9 @@ table GameView {
// last_activity_unix is the lobby sort key: the current turn's start for an active
// game, the finish time for a finished one.
last_activity_unix:long;
// vs_ai marks an honest-AI game: the opponent is shown as 🤖 and chat/nudge/add-friend
// are disabled in the client. A robot-filled random game keeps vs_ai=false.
vs_ai:bool;
}
// MoveRecord is one decoded move (a committed play, or a hint preview).
@@ -289,11 +292,13 @@ table GameList {
// --- lobby (authenticated) ---
// EnqueueRequest joins the auto-match pool for a variant under a per-turn word rule.
// EnqueueRequest starts a quick game for a variant under a per-turn word rule.
// multiple_words_per_turn true is standard Scrabble; false is the single-word rule.
// vs_ai true starts an honest-AI game against a robot instead of human auto-match.
table EnqueueRequest {
variant:string;
multiple_words_per_turn:bool;
vs_ai:bool;
}
// MatchResult reports whether the caller has been paired into a game yet.
+16 -1
View File
@@ -61,8 +61,20 @@ func (rcv *EnqueueRequest) MutateMultipleWordsPerTurn(n bool) bool {
return rcv._tab.MutateBoolSlot(6, n)
}
func (rcv *EnqueueRequest) VsAi() bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
if o != 0 {
return rcv._tab.GetBool(o + rcv._tab.Pos)
}
return false
}
func (rcv *EnqueueRequest) MutateVsAi(n bool) bool {
return rcv._tab.MutateBoolSlot(8, n)
}
func EnqueueRequestStart(builder *flatbuffers.Builder) {
builder.StartObject(2)
builder.StartObject(3)
}
func EnqueueRequestAddVariant(builder *flatbuffers.Builder, variant flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(variant), 0)
@@ -70,6 +82,9 @@ func EnqueueRequestAddVariant(builder *flatbuffers.Builder, variant flatbuffers.
func EnqueueRequestAddMultipleWordsPerTurn(builder *flatbuffers.Builder, multipleWordsPerTurn bool) {
builder.PrependBoolSlot(1, multipleWordsPerTurn, false)
}
func EnqueueRequestAddVsAi(builder *flatbuffers.Builder, vsAi bool) {
builder.PrependBoolSlot(2, vsAi, false)
}
func EnqueueRequestEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}
+16 -1
View File
@@ -173,8 +173,20 @@ func (rcv *GameView) MutateLastActivityUnix(n int64) bool {
return rcv._tab.MutateInt64Slot(26, n)
}
func (rcv *GameView) VsAi() bool {
o := flatbuffers.UOffsetT(rcv._tab.Offset(28))
if o != 0 {
return rcv._tab.GetBool(o + rcv._tab.Pos)
}
return false
}
func (rcv *GameView) MutateVsAi(n bool) bool {
return rcv._tab.MutateBoolSlot(28, n)
}
func GameViewStart(builder *flatbuffers.Builder) {
builder.StartObject(12)
builder.StartObject(13)
}
func GameViewAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) {
builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(id), 0)
@@ -215,6 +227,9 @@ func GameViewStartSeatsVector(builder *flatbuffers.Builder, numElems int) flatbu
func GameViewAddLastActivityUnix(builder *flatbuffers.Builder, lastActivityUnix int64) {
builder.PrependInt64Slot(11, lastActivityUnix, 0)
}
func GameViewAddVsAi(builder *flatbuffers.Builder, vsAi bool) {
builder.PrependBoolSlot(12, vsAi, false)
}
func GameViewEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}
+3
View File
@@ -42,6 +42,8 @@ type GameView struct {
EndReason string
Seats []SeatView
LastActivityUnix int64
// VsAI marks an honest-AI game (the opponent is shown as 🤖, chat/nudge/add-friend off).
VsAI bool
}
// TileRecord is one tile in a decoded MoveRecord (the concrete letter, "?" for a blank
@@ -158,6 +160,7 @@ func BuildGameView(b *flatbuffers.Builder, g GameView) flatbuffers.UOffsetT {
fb.GameViewAddEndReason(b, endReason)
fb.GameViewAddSeats(b, seats)
fb.GameViewAddLastActivityUnix(b, g.LastActivityUnix)
fb.GameViewAddVsAi(b, g.VsAI)
return fb.GameViewEnd(b)
}