Module open_ttt_lib::ai[][src]

Expand description

Provides functionality for creating single player games.

Examples

use open_ttt_lib::ai;
use open_ttt_lib::game;

let game = game::Game::new();
let ai_opponent = ai::Opponent::new(ai::Difficulty::Hard);

match ai_opponent.get_move(&game) {
    Some(position) => assert!(game.can_move(position)),
    None => panic!("The game is over so the AI opponent cannot do a move."),
};

Structs

Opponent

Provides a computer controlled AI opponent.

Enums

Difficulty

Selects the difficulty used by the Opponent.

Outcome

Represents a game outcome for the AI opponent.

Functions

best_position

Picks a position with the best outcome based on the provided mapping of positions to outcomes.