How the BOT works
中文版
这个 BOT 不是机器学习,也不是深度搜索很多步的“无敌 AI”。它是一个一层模拟 + 打分规则的启发式机器人:轮到 O 时,它会列出当前所有合法落子,每个都试下一遍,然后给每个选择打分,最后选分数最高的一步。
- 先看能不能直接赢:如果某一步能让 O 赢下大棋盘,直接给最高分。
- 优先赢小棋盘:如果这步能赢下当前小棋盘,会加很多分;如果把小棋盘下成平局,也会小幅加分。
- 防止你下一步直接赢:它会模拟 X 的下一手;如果发现这步之后 X 有机会立刻赢大棋盘,就大幅扣分。
- 堵你的三连:如果你在某个小棋盘里已经差一步成线,BOT 会给“堵住这条线”的落子加分。
- 尽量把你送去不舒服的棋盘:在 Ultimate Tic-Tac-Toe 里,BOT 下在哪个小格,会决定你下一步必须去哪块小棋盘。它会避免把你送去太舒服的位置,比如中心还空、你已经有很多棋子的棋盘。
- 偏爱中心和角:中心格和角落通常更有战略价值,所以会额外加一点分。
- 少量随机扰动:分数里有一点点随机数,避免每局都完全一样。
所以它的风格是:能赢就赢、该堵就堵、同时尽量用规则把你“赶”到不舒服的小棋盘。但它只看短期局面,不会像真正的强 AI 那样做完整的多步推演。
English version
The BOT is not machine learning, and it is not a deep multi-move unbeatable AI. It is a one-ply simulation plus heuristic scoring player: when it is O's turn, it lists every legal move, tries each move on a copied board, scores the result, and then chooses the highest-scoring move.
- Win immediately if possible: if a move wins the big board for O, it gets the highest score.
- Prefer winning mini boards: a move that wins a mini board gets a large bonus; forcing a draw on a mini board gets a small bonus.
- Avoid giving X an immediate win: after each candidate move, the BOT simulates X's next legal moves. If X could immediately win the big board, that candidate gets a heavy penalty.
- Block your threats: if X is one move away from completing a line on a mini board, the BOT gives extra points to moves that block it.
- Send you to awkward boards: in Ultimate Tic-Tac-Toe, the cell O chooses controls which mini board X must play next. The BOT tries not to send you to comfortable boards, such as boards with an open center or many existing X pieces.
- Like center and corners: center and corner cells usually have better strategic value, so they get a small bonus.
- Tiny randomness: a very small random value is added so games do not always look exactly the same.
In short: it wins when it can, blocks when it should, and uses the forced-board rule to push you into less comfortable positions. But it only reasons about the near-term position, not a full deep search.