Skip to content

Commit

Permalink
feat: zener display
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoDog896 committed Jan 18, 2025
1 parent d816b42 commit e7b1da9
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 18 deletions.
52 changes: 49 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/game-solver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ edition = "2021"
[features]
"xxhash" = ["dep:twox-hash"]
"rayon" = ["dep:rayon", "xxhash", "dep:sysinfo", "dep:moka"]
# "reinforcement" = ["dep:rand", "dep:dfdx", "dep:itertools"]
"js" = ["moka/js"]

[dependencies]
Expand All @@ -21,7 +20,7 @@ rand = { version = "0.8", optional = true }
rayon = { version = "1.8", optional = true }
sysinfo = { version = "0.30", optional = true }
twox-hash = { version = "1.6", optional = true }
itertools = { version = "0.13", optional = true }
itertools = { version = "0.13" }
futures = "0.3.30"
thiserror = "1.0"
castaway = "0.2.3"
Expand Down
4 changes: 3 additions & 1 deletion crates/games-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use anyhow::Result;
use clap::Parser;
use games::{
chomp::Chomp, domineering::Domineering, naive_nim::Nim, order_and_chaos::OrderAndChaos,
reversi::Reversi, sprouts::Sprouts, tic_tac_toe::TicTacToe, util::cli::play, Games,
reversi::Reversi, sprouts::Sprouts, tic_tac_toe::TicTacToe, util::cli::play, zener::Zener,
Games,
};

/// `game-solver` is a solving utility that helps analyze various combinatorial games.
Expand All @@ -28,6 +29,7 @@ fn main() -> Result<()> {
Games::Domineering(args) => play::<Domineering<5, 5>>(args.try_into().unwrap(), cli.plain),
Games::Chomp(args) => play::<Chomp>(args.try_into().unwrap(), cli.plain),
Games::Sprouts(args) => play::<Sprouts>(args.try_into().unwrap(), cli.plain),
Games::Zener(args) => play::<Zener>(args.try_into().unwrap(), cli.plain),
};

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/games/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ thiserror = "1.0.63"
petgraph = { version = "0.6.5", features = ["serde-1"] }
castaway = "0.2.3"
ratatui = "0.28.1"
owo-colors = "4.1.0"
owo-colors = { version = "4.1.0", features = ["supports-colors"] }

[features]
"egui" = ["dep:egui", "dep:egui_commonmark"]
2 changes: 1 addition & 1 deletion crates/games/src/domineering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use array2d::Array2D;
use clap::Args;
use game_solver::{
game::{Game, GameState, Normal},
player::{PartizanPlayer, Player},
player::PartizanPlayer,
};
use serde::{Deserialize, Serialize};
use std::{
Expand Down
13 changes: 12 additions & 1 deletion crates/games/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::{
use clap::Subcommand;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use zener::ZenerArgs;

#[derive(Subcommand, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub enum Games {
Expand All @@ -27,9 +28,10 @@ pub enum Games {
Domineering(DomineeringArgs),
Chomp(ChompArgs),
Sprouts(SproutsArgs),
Zener(ZenerArgs),
}

pub static DEFAULT_GAMES: Lazy<[Games; 7]> = Lazy::new(|| {
pub static DEFAULT_GAMES: Lazy<[Games; 8]> = Lazy::new(|| {
[
Games::Reversi(Default::default()),
Games::TicTacToe(Default::default()),
Expand All @@ -38,6 +40,7 @@ pub static DEFAULT_GAMES: Lazy<[Games; 7]> = Lazy::new(|| {
Games::Domineering(Default::default()),
Games::Chomp(Default::default()),
Games::Sprouts(Default::default()),
Games::Zener(Default::default()),
]
});

Expand All @@ -51,6 +54,7 @@ impl Games {
Self::Domineering(_) => "Domineering".to_string(),
Self::Chomp(_) => "Chomp".to_string(),
Self::Sprouts(_) => "Sprouts".to_string(),
Self::Zener(_) => "Zener".to_string(),
}
}

Expand All @@ -63,6 +67,7 @@ impl Games {
Self::Domineering(_) => include_str!("./domineering/README.md"),
Self::Chomp(_) => include_str!("./chomp/README.md"),
Self::Sprouts(_) => include_str!("./sprouts/README.md"),
Self::Zener(_) => include_str!("./zener/README.md"),
}
}

Expand Down Expand Up @@ -112,6 +117,12 @@ impl Games {
&mut cache,
"crates/games/src/sprouts/README.md"
),
Self::Zener(_) => egui_commonmark::commonmark_str!(
"zener",
ui,
&mut cache,
"crates/games/src/zener/README.md"
),
};
}
}
18 changes: 17 additions & 1 deletion crates/games/src/zener/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
Zener is
Zener is a loopy finite combinatorial game played on a five by seven grid.
Past `game-solver`'s demo, you can play it online at [boardgamearena](https://en.boardgamearena.com/gamepanel?game=zener).

The first row is where Right's unique starting pieces are located,
and the last row is where Left's unique starting pieces are located.

The first player to move is Left, and the allowed moves per piece are only
adjacent horizontal and vertical tiles.

After the first turn, a player makes two moves: they must move the 'type' of piece
that the other player moved (there are five types: Left has the orientation `1 2 3 4 5`
and Right has the orientation `5 4 3 2 1` relative to a side of the board) first,
then they can freely move another piece. This alternates until either no player can make a move,
or a player gets a piece past the first or last row.

Players can 'lock' a piece by moving on top of it: only the piece on top can move, and multiple
pieces can be stacked at a time.
Loading

0 comments on commit e7b1da9

Please sign in to comment.