Crate xo_core

Source
Expand description

§xo-core

xo-core is a fast, reusable, and well-tested Tic-Tac-Toe (Noughts and Crosses) game engine for Rust. It provides all core logic and an unbeatable Minimax AI, with a simple, public API suitable for embedding in CLI, GUI, or web apps.

§High-Level Summary

§Example Usage

use xo_core::{GameEngine, Player, Cell, GameState};

let mut game = GameEngine::new();
// X plays at 0, O at 4, X at 1, O at 5, X at 2 (X wins)
let moves = [0, 4, 1, 5, 2];
for m in moves {
    game.make_move(m).unwrap();
}
assert_eq!(game.check_state(), GameState::Win(Player::X));

§Board Layout

Board cells are indexed as follows:

 0 | 1 | 2
---|---|---
 3 | 4 | 5
---|---|---
 6 | 7 | 8

§Integration

The engine is detached from I/O and UI, making it easy to use in CLI, GUI, or web applications.

§License

MIT

Structs§

GameEngine
The core Tic-Tac-Toe game engine.

Enums§

Cell
Represents the state of a single cell on the board.
GameState
Represents the overall state of the game.
MoveError
Errors that can occur when attempting to make a move.
Player
Represents the two possible players in the game.