pub struct Solver { /* private fields */ }Expand description
Reusing the same solver instead of repeatedly running score in order to calculate similar positions, may have performance benefits, because we can reuse the transposition table.
Implementations§
Source§impl Solver
impl Solver
pub fn new() -> Solver
Sourcepub fn score(&mut self, game: &ConnectFour) -> i8
pub fn score(&mut self, game: &ConnectFour) -> i8
Calculates the score of a connect four game. The score is set up so always picking the move with the lowest score results in perfect play. Perfect meaning winning as fast as possible, drawing or loosing as late as possible.
A positive score means the player who can put in the next stone can win. Positions which can be
won faster are scored higher. The score is 1 if the current player can win with his last stone.
Two if he can win with his second to last stone and so on. A score of zero means the game will
end in a draw if both players play perfectly. A negative score means the opponent (the player
which is not putting in the next stone) is winnig. It is -1 if the opponent is winning with
his last stone. -2 if he is winning second to last stone and so on.
Sourcepub fn best_moves(&mut self, game: &ConnectFour, best_moves: &mut Vec<Column>)
pub fn best_moves(&mut self, game: &ConnectFour, best_moves: &mut Vec<Column>)
Fills best_moves with all the legal moves, which have the best strong score.