Skip to content

Commit

Permalink
added check for when there are no empty tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Maneren committed Jul 23, 2021
1 parent 05e5e19 commit e87368c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gomoku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use rand::{prelude::ThreadRng, seq::SliceRandom, thread_rng};

pub mod board;
use board::{Board, TilePointer, Tile};
use board::{Board, Tile, TilePointer};

type Score = i64;

Expand Down Expand Up @@ -188,6 +188,14 @@ fn minimax(
alpha_beta: &mut AlphaBeta,
) -> Move {
let mut available_moves = board.get_empty_tiles();

if available_moves.is_empty() {
return Move {
tile: TilePointer { x: 0, y: 0 },
score: -1_000_000_000_000,
};
}

available_moves.shuffle(rng);

let board_size = board.get_size();
Expand Down

0 comments on commit e87368c

Please sign in to comment.