This game’s moves
Copies the seed, settings and moves as text. Paste it into “Seeds and saved games” to replay this game.
This game’s stats
Seeds and saved games
A seed gives the same board whenever the board size and rules match. A game record also sets those and replays its moves.
How the seed works
The seed only decides how much energy each hexagon holds. Who moves first and the AI’s moves are not taken from it, which is why a game record lists its moves.
1. The seed is a number. New games get a random 6-digit whole number, such as 482913. You can also type any whole number up to 9 digits.
2. Make random numbers. The seed is used directly as the starting state of a Mulberry32 generator, which returns numbers from 0 up to (but not including) 1.
3. Fill the board. Hexagons are filled row by row, starting at a1, b1, c1… then a2, b2, and so on. Letters count columns from the blue edge on the left, and numbers count rows from the red edge at the top. Each hexagon takes the next random number r and gets the energy value at position floor(r × count) in the list of energy values, in the order written (1,2,3 in the standard rules, or your custom list). With the mirror option on, a hexagon whose column comes before its row (such as a2) copies the hexagon with row and column swapped (b1) and uses no random number.
Here is the same thing in JavaScript:
function mulberry32(a) {
return function () {
a |= 0; a = (a + 0x6D2B79F5) | 0;
let t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const rand = mulberry32(482913); // the seed
const values = [1, 2, 3]; // energy values, in order
for (let row = 0; row < N; row++)
for (let col = 0; col < N; col++)
energy[row][col] = mirrored && col < row
? energy[col][row]
: values[Math.floor(rand() * values.length)];
Check your version. With the standard rules on a 9×9 board, the seed 482913 gives a top row (a1 to i1) of 1 3 3 2 3 3 1 1 3 energy.
How the AI works
The AI chooses its moves with a method called Monte Carlo tree search (MCTS). To decide on a move, the AI plays many quick practice games against itself, starting from the current position. In these practice games, the moves are mostly chosen at random. Each practice game is called a rollout. Rollouts follow the full rules of Surge Hex, including energy and surges.
After each rollout, the AI notes which player won. Moves that lead to more wins get tried more often, and moves that keep losing get tried less often. When the AI has finished all its rollouts, it plays the move it found most promising in the simulations.
The AI also uses two tricks to learn faster. The first trick is called RAVE (Rapid Action Value Estimation). With RAVE, the AI learns from every move played in a rollout, not just the first one. The second trick makes the rollouts look more like real Hex. When a rollout attacks one of a player’s bridges, that player always defends it.
The more rollouts the AI plays before each move, the stronger and slower it gets. Easy uses 500 rollouts per move, Medium uses 3,000, Hard uses 12,000 and Very hard uses 40,000. A “+” after a level, as in Hard+, means the AI is using more rollouts than that level but fewer than the next one.
To see how MCTS works in more detail, watch Mihai Nica’s explainer video on MCTS.