Crates.io | hive-engine |
lib.rs | hive-engine |
version | 0.2.0 |
source | src |
created_at | 2024-11-04 03:11:42.503692 |
updated_at | 2024-11-05 04:20:02.668931 |
description | A game engine for Hive. |
homepage | |
repository | https://github.com/OlivierPelletier/hive |
max_upload_size | |
id | 1434498 |
size | 59,442 |
A game engine for the board game Hive made with Rust.
Hive is a bug-themed tabletop game, designed by John Yianni and published in 2001 by Gen42 Games. The object of Hive is to capture the opponent's queen bee by completely surrounding it, while avoiding the capture of one's own queen (Wikipedia).
The goal of this project is to create a reliable game engine for the game Hive using Rust Programming Language.
Add hive-engine to your dependencies:
hive-engine = "0"
And then get started in your main.rs
:
// Initialize game
let mut game: Game = Game::tournament();
//List actions for a player
let actions: Vec<Action> = game.list_actions_for_player( & game.players[game.current_player_index]);
// Play an action
let chosen_action: Action = actions[0];
game.play_action(chosen_action);
// Check if there's a winner
let winner: Option<PieceColor> = game.winner();
cargo run
...
__ __ __ __ __ __ __ __ __ __
-2,-6 -1,-6 0,-6 1,-6 2,-6 3,-6 4,-6 5,-6 6,-6 7,-6
__ __ __ __ __ __ W BETL __ W SANT __
-2,-5 -1,-5 0,-5 1,-5 2,-5 3,-5 4,-5 5,-5 6,-5 7,-5
__ __ __ __ __ W SANT W GRHP W GRHP __ __
-2,-4 -1,-4 0,-4 1,-4 2,-4 3,-4 4,-4 5,-4 6,-4 7,-4
__ __ __ __ __ W SPDR __ __ __ __
-2,-3 -1,-3 0,-3 1,-3 2,-3 3,-3 4,-3 5,-3 6,-3 7,-3
__ __ __ __ __ B QBEE __ __ __ __
-2,-2 -1,-2 0,-2 1,-2 2,-2 3,-2 4,-2 5,-2 6,-2 7,-2
__ __ B GRHP B SPDR B SPDR __ __ __ __ __
-2,-1 -1,-1 0,-1 1,-1 2,-1 3,-1 4,-1 5,-1 6,-1 7,-1
__ __ __ __ W QBEE __ __ __ __ __
-2,0 -1,0 0,0 1,0 2,0 3,0 4,0 5,0 6,0 7,0
__ __ __ __ W SPDR B SANT __ __ __ __
-2,1 -1,1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1
__ __ __ W BETL __ __ __ __ __ __
-2,2 -1,2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7,2
[(0): B GRHP from: 0,-1 , to: 3,-1 ][(1): B SANT from: 3,1 , to: 2,2 ][(2): B SANT from: 3,1 , to: 1,3 ]...
Choose an action:
...
B wins!
cargo test