#tic-tac-toe #game #logic #engine

super-ttt

An implementation of super tic tac toe

4 releases

0.2.0 Sep 16, 2023
0.1.2 Sep 2, 2023
0.1.1 Sep 1, 2023
0.1.0 Sep 1, 2023

#367 in Games

33 downloads per month

MIT/Apache

14KB
183 lines

Super Tic Tac Toe

Crates.io docs.rs

This Rust library provides a core implementation of the logic for playing Super Tic Tac Toe. Super Tic Tac Toe is an extended version of the traditional Tic Tac Toe game, played on a 9x9 grid of smaller Tic Tac Toe boards. The rules of the game are explained in detail in the Wikipedia entry.

Docs are found here

Installation

To use this library, add it to your Cargo.toml via

$ cargo add super-ttt

Example

Here's an example that demonstrates how to use this library to play a game:

use super_ttt::{Game, Player};

fn main() {
    // Make moves and check for a winner
    let mut game = Game::new();
    game.make_move(0, 0, 1, 1).unwrap();
    game.make_move(1, 1, 0, 0).unwrap();
    game.make_move(0, 1, 2, 2).unwrap();
    game.make_move(2, 2, 0, 2).unwrap();
    game.make_move(0, 2, 1, 0).unwrap();

    match game.get_winner() {
        super_ttt::GameState::Winner(player) => {
            println!("Player {:?} wins!", player);
        }
        super_ttt::GameState::Tie => {
            println!("It's a tie!");
        }
        super_ttt::GameState::InProgress => {
            println!("The game is still in progress.");
        }
    }
}

Contributing

Contributions to this project are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.

License

This library is licensed under the MIT License. See the LICENSE file for more information.

No runtime deps