Skip to main content

Crate gamie

Crate gamie 

Source
Expand description

§gamie

A Rust library providing abstractions for several classic tiny games.

Version Documentation License

gamie provides simple, well-designed abstractions for several classic tiny games.

gamie has minimal dependencies and can be easily integrated into your projects.

§Usage

To use gamie, enable the desired feature flags in Cargo.toml. For example, to use tictactoe:

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

Now you can use the Tic-Tac-Toe game abstraction:

use gamie::tictactoe::{Game, Status};

let mut game = Game::new().unwrap();
game.put(1, 1).unwrap();  // Player0 at center
game.put(0, 0).unwrap();  // Player1 at top-left
game.put(0, 2).unwrap();  // Player0 at top-right
game.put(2, 0).unwrap();  // Player1 at bottom-left
game.put(1, 0).unwrap();  // Player0 at middle-left
game.put(1, 2).unwrap();  // Player1 at middle-right
game.put(2, 1).unwrap();  // Player0 at bottom-center
game.put(0, 1).unwrap();  // Player1 at top-center
game.put(2, 2).unwrap();  // Player0 at bottom-right
assert_eq!(game.status(), &Status::Draw);

Check the docs for further information.

§Modules

Currently, the following modules are available:

§Serialization

Enable the serde feature to add serialization and deserialization support for game state types.

Enable the rkyv feature to add rkyv archive, serialize, and deserialize support. Generated archived and resolver types are re-exported from each game module’s rkyv submodule.

§no_std

This crate is no_std by default and runs flawlessly on bare metal.

§License

Licensed under either of:

at your option.

Modules§

connect_four
Connect Four game implementation
gomoku
Gomoku (Five in a Row) game implementation
minesweeper
Minesweeper game implementation
reversi
Reversi (Othello) game implementation
tictactoe
Tic-Tac-Toe game implementation