Skip to content

Guide: GamerBot Ai Logic

oolga edited this page Mar 7, 2026 · 2 revisions

GamerBot AI Logic

This page explains how the GamerBot makes decisions. We used a strategy called Minimax and a custom Scoring System to make the bot play smart.


1. How the Bot Thinks (Minimax)

The bot does not just move randomly. It "simulates" the game in its head.

  • Looking Ahead: It looks 4 moves into the future (Depth 4).
  • Best vs Best: It assumes you (the human) will play perfectly. It picks the move that results in the best possible "worst-case scenario."
  • Alpha-Beta Pruning: This is a speed boost. It tells the bot: "Stop looking at this path; I already found a better move somewhere else." This makes the AI much faster.

2. How the Bot Scores a Move

Because the bot can't see the actual end of the game (it only looks 4 moves ahead), it uses a Score (Heuristic) to see who is winning.

A. Connecting Pieces (Clustering)

In the Game of Y, pieces are stronger when they are together.

  • The bot looks at the 6 neighbors around every piece.
  • If a piece touches another piece of the same color, it gets +150 points.

B. Touching the Sides

The goal of the game is to connect all three sides of the triangle.

  • Side A, B, or C: If a piece touches a side, it gets +1000 points.
  • This encourages the bot to build paths that reach the edges.

C. Defense (Blocking the Player)

The bot is very defensive.

  • It calculates how good a move is for the opponent.
  • It gives blocking moves a higher priority (1.2x more value).
  • Result: The bot would rather stop you from winning than help itself.

Technical Details

Component Logic
Search Depth 4 Turns.
Win/Loss A win is worth 1,000,000 points. A loss is -1,000,000.
Virtual Board The bot uses board.clone() to test moves without changing the real game.

Clone this wiki locally