/** * 도둑잡기 computer player. There is nothing to read from face-down cards, so every level plays the same way: a random * card from the neighbour's fan, and now and then (like a person fidgeting) a shuffle of its own hand first. The * human-like thinking time comes from the room's bot driver. Uses only the view and the legal actions. */ import type { BotStrategy } from '../bots/types'; import { pick, playable } from '../bots/policy'; import { SHUFFLES_PER_TURN, type OldMaidAction, type OldMaidView } from './types'; /** Chance to shuffle its own hand before drawing (at most once a turn). */ export const SHUFFLE_CHANCE = 0.15; export const oldMaidBot: BotStrategy = ({ view, legal, random }) => { const draws = legal.filter((a) => a.type === 'draw'); const fresh = (view.my?.shufflesLeft ?? 0) === SHUFFLES_PER_TURN; if (fresh && legal.some((a) => a.type === 'shuffle') && random() < SHUFFLE_CHANCE) return { type: 'shuffle' }; return draws.length ? pick(draws, random) : pick(playable(legal), random); };