mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-20 02:18:23 +00:00
Serve the BotFather game noitu from the bot's HTTP server under /games/noitu when GAME_BASE_URL is set. /noitu sends the game, Play answers with a signed, expiring link, and the server validates every word against the embedded noitu dictionary (CC BY-SA 4.0), runs the bot opponent and turn timer, and reports the score with setGameScore. Modules can now register game-short-name callbacks and HTTP routes.
18 lines
341 B
Go
18 lines
341 B
Go
package opponent
|
|
|
|
import "math/rand/v2"
|
|
|
|
// easy plays a uniformly random legal move, without looking at what it hands
|
|
// the opponent.
|
|
type easy struct {
|
|
rng *rand.Rand
|
|
}
|
|
|
|
func (s *easy) Choose(b Board) (string, error) {
|
|
moves := b.LegalMoves()
|
|
if len(moves) == 0 {
|
|
return "", ErrNoMove
|
|
}
|
|
return moves[s.rng.IntN(len(moves))], nil
|
|
}
|