gamie

A Rust library provides abstractions for several classic tiny games.

Version Documentation License

gamie aims to provide simple yet adequate abstractions for several classic tiny games.

gamie is quite lightweight, only came with a few dependencies, it can be easily integrated into your projects.

Usage

To use gamie, you should enable modules you need in Cargo.toml. For example tictactoe:

toml [dependencies] gamie = { version = "*", features = ["tictactoe"] }

Now you can use the tictactoe:

```rust use gamie::tictactoe::{TicTacToe, Player as TicTacToePlayer, GameState as TicTacToeGameState};

let mut game = TicTacToe::new().unwrap(); game.place(TicTacToePlayer::Player0, 1, 1).unwrap(); game.place(TicTacToePlayer::Player1, 0, 0).unwrap(); game.place(TicTacToePlayer::Player0, 0, 2).unwrap(); game.place(TicTacToePlayer::Player1, 2, 0).unwrap(); game.place(TicTacToePlayer::Player0, 1, 0).unwrap(); game.place(TicTacToePlayer::Player1, 1, 2).unwrap(); game.place(TicTacToePlayer::Player0, 2, 1).unwrap(); game.place(TicTacToePlayer::Player1, 0, 1).unwrap(); game.place(TicTacToePlayer::Player0, 2, 2).unwrap(); assert!(game.isended()); asserteq!(game.state(), &TicTacToeGameState::Tie); ```

Check the docs for further usage information.

Modules

Currently, the following modules are available:

Serialize / Deserialize

Bring in the serde feature to enable serialization and deserialization.

toml [dependencies] gamie = { version = "*", features = ["serde", "tictactoe"] }

no_std

This crate runs flawlessly on bare metal. To remove the Rust standard library dependency, opt out the std feature by disabling default-features in Cargo.toml:

toml [dependencies] gamie = { version = "*", features = ["tictactoe"], default-features = false }

License

GNU General Public License v3.0