DevSupporter
DevSupporter

Welcome back

Please enter your details to sign in to your account

Forgot password?
Sign in

Gomoku

MinimaxAlpha-Beta PruningAdvanced

Coming Soon

Game play area will be implemented here

Play as black (โšซ) against the AI (โšช). Click intersections to place stones and get exactly five in a row (horizontal, vertical, or diagonal) to win. Overlines (6 or more) do not count, and in Hard mode black double-three moves are forbidden.

Uses a Minimax AI with Alpha-Beta pruning, heuristic pattern evaluation (open fours / threes), and candidate move restriction around existing stones for efficient search.

function getCandidates(board) {
  const RANGE = 2;
  const candidates = new Set();
  let hasStone = false;
  for (let r = 0; r < 15; r++) {
    for (let c = 0; c < 15; c++) {
      if (board[r][c] === 0) continue;
      hasStone = true;
      for (let dr = -RANGE; dr <= RANGE; dr++) {
        for (let dc = -RANGE; dc <= RANGE; dc++) {
          const nr = r + dr, nc = c + dc;
          if (nr >= 0 && nr < 15 && nc >= 0 && nc < 15 && board[nr][nc] === 0) {
            candidates.add(`${nr},${nc}`);
          }
        }
      }
    }
  }
  if (!hasStone) return [[7, 7]];
  return Array.from(candidates).map(key => key.split(',').map(Number));
}

2026 ยฉ DevSupporter - Playground for Developers by DevSupporter