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
- Core types:
Player,Cell,GameState,MoveError GameEnginestruct to manage game state and moves- Minimax AI: unbeatable computer player with
GameEngine::get_best_move
§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§
- Game
Engine - The core Tic-Tac-Toe game engine.