Skip to content

Commit

Permalink
feat: update cli docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoDog896 committed Jun 1, 2024
1 parent da6dab3 commit 00ac65e
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 45 deletions.
12 changes: 12 additions & 0 deletions crates/games/src/chomp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Chomp is a two-player game played on a rectangular grid of squares.
The bottom right square is poisoned, and the players take turns eating squares.
Every square they eat, every square to the right and above it is also eaten (inclusively)

This is a flipped version of the traditional [Chomp](https://en.wikipedia.org/wiki/Chomp) game.

This is not the best example for analysis via a combinatorial game, as not only is it
impartial (making it analyzable via the Sprague-Grundy theorem), but it is also trivially
solved via the strategy-stealing argument.

However, it serves as a great test for the transposition table, as it is a game that commonly
repeats positions (as it only has nxm - 1 positions).
3 changes: 3 additions & 0 deletions crates/games/src/chomp/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use crate::chomp::Chomp;

use super::ChompMove;

/// Analyzes Chomp.
///
#[doc = include_str!("./README.md")]
#[derive(Args)]
pub struct ChompArgs {
/// The width of the game
Expand Down
13 changes: 1 addition & 12 deletions crates/games/src/chomp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
//! Chomp is a two-player game played on a rectangular grid of squares.
//! The bottom right square is poisoned, and the players take turns eating squares.
//! Every square they eat, every square to the right and above it is also eaten (inclusively)
//!
//! This is a flipped version of the traditional [Chomp](https://en.wikipedia.org/wiki/Chomp) game.
//!
//! This is not the best example for analysis via a combinatorial game, as not only is it
//! impartial (making it analyzable via the Sprague-Grundy theorem), but it is also trivially
//! solved via the strategy-stealing argument.
//!
//! However, it serves as a great test for the transposition table, as it is a game that commonly
//! repeats positions (as it only has nxm - 1 positions).
#[doc = include_str!("./README.md")]

pub mod cli;

Expand Down
5 changes: 5 additions & 0 deletions crates/games/src/domineering/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Connect 4 is a two-player game played on a 7x6 grid. Players take turns placing pieces on the
bottom row, and the pieces fall to the lowest available square in the column.
The first player to get 4 in a row (horizontally, vertically, or diagonally) wins.

Learn more: <https://en.wikipedia.org/wiki/Connect_Four>
5 changes: 5 additions & 0 deletions crates/games/src/domineering/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[doc = include_str!("./README.md")]

use std::{
collections::HashMap,
fmt::{Display, Formatter},
Expand Down Expand Up @@ -26,6 +28,9 @@ impl<const WIDTH: usize, const HEIGHT: usize> Display for Domineering<WIDTH, HEI
}
}

/// Analyzes Domineering.
///
#[doc = include_str!("./README.md")]
#[derive(Args)]
pub struct DomineeringArgs {
moves: Vec<String>,
Expand Down
6 changes: 0 additions & 6 deletions crates/games/src/domineering/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
//! Connect 4 is a two-player game played on a 7x6 grid. Players take turns placing pieces on the
//! bottom row, and the pieces fall to the lowest available square in the column.
//! The first player to get 4 in a row (horizontally, vertically, or diagonally) wins.
//!
//! Learn more: https://en.wikipedia.org/wiki/Connect_Four
pub mod cli;

use array2d::Array2D;
Expand Down
6 changes: 6 additions & 0 deletions crates/games/src/nim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Nim is the heart of impartial combinatorial game theory.
Its a game about removing objects from heaps.
Despite its ability to be rigidly analyzed,
it still makes a great example as an implementation of the `Game` trait.

Learn more about Nim here: <https://en.wikipedia.org/wiki/Nim>
3 changes: 3 additions & 0 deletions crates/games/src/nim/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ impl Display for Nim {
}
}

/// Analyzes Nim.
///
#[doc = include_str!("./README.md")]
#[derive(Args)]
pub struct NimArgs {
/// The configuration of the game. For example, 3,5,7
Expand Down
7 changes: 1 addition & 6 deletions crates/games/src/nim/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
//! Nim is the heart of impartial combinatorial game theory.
//! Its a game about removing objects from heaps.
//! Despite its ability to be rigidly analyzed,
//! it still makes a great example as an implementation of the `Game` trait.
//!
//! Learn more about Nim here: <https://en.wikipedia.org/wiki/Nim>
#[doc = include_str!("./README.md")]

pub mod cli;

Expand Down
7 changes: 7 additions & 0 deletions crates/games/src/order_and_chaos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Order and Chaos is a Tic Tac Toe variant that plays on a 6x6 square board.

The game is played by two players, order and chaos. Order plays first, and places Xs and Os on the board. Chaos also plays Xs and Os, but Chaos's goal is to make Order tie the game.

5 in a row wins the game for Order - otherwise, Chaos wins. This serves as an exemplary example for the simplicity in implementation, showing how trivial it is to implement a new game.

Learn more: <https://en.wikipedia.org/wiki/Order_and_Chaos>
3 changes: 3 additions & 0 deletions crates/games/src/order_and_chaos/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use game_solver::{game::Game, par_move_scores};

use crate::order_and_chaos::{CellType, OrderAndChaos};

/// Analyzes Order and Chaos.
///
#[doc = include_str!("./README.md")]
#[derive(Args)]
pub struct OrderAndChaosArgs {
moves: Vec<String>,
Expand Down
15 changes: 1 addition & 14 deletions crates/games/src/order_and_chaos/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
//! Order and chaos is a tic tac toe variant
//! that plays on a 6x6 square board.
//!
//! The game is played by two players, order and chaos.
//! Order plays first, and places Xs and Os on the board.
//! Chaos also plays Xs and Os, but Chaos's goal is to
//! make Order tie the game.
//!
//! 5 in a row wins the game for Order - otherwise, Chaos wins.
//! This serves as an exemplary example
//! for the simplicity in implementation,
//! showing how trivial it is to implement a new game.
//!
//! Learn more: <https://en.wikipedia.org/wiki/Order_and_Chaos>
#[doc = include_str!("./README.md")]

pub mod cli;

Expand Down
5 changes: 5 additions & 0 deletions crates/games/src/reversi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Reversi is a two-player game played on a rectangular grid of squares.

The grid is usually 8x8, but any size can be used.

More information: <https://en.wikipedia.org/wiki/Reversi>
3 changes: 3 additions & 0 deletions crates/games/src/reversi/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use game_solver::{

use super::{HEIGHT, WIDTH};

/// Analyzes Reversi.
///
#[doc = include_str!("./README.md")]
#[derive(Args)]
pub struct ReversiArgs {
/// Reversi moves, ordered as x1-y1 x2-y2 ...
Expand Down
5 changes: 1 addition & 4 deletions crates/games/src/reversi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//! Reversi is a two-player game played on a rectangular grid of squares.
//! The grid is usually 8x8, but any size can be used.
//!
//! More information: <https://en.wikipedia.org/wiki/Reversi>
#[doc = include_str!("./README.md")]

pub mod cli;

Expand Down
5 changes: 5 additions & 0 deletions crates/games/src/tic_tac_toe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Tic Tac Toe is a traditional two-player game played on a 3x3 grid.
For the sake of complexity, this allows simulating any n-dimensional 3-in-a-row game
with the same bounds as the traditional game.

This is a variant of the <https://en.wikipedia.org/wiki/Nd_game>.
3 changes: 3 additions & 0 deletions crates/games/src/tic_tac_toe/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use ndarray::IntoDimension;

use crate::tic_tac_toe::{format_dim, TicTacToe};

/// Analyzes Tic Tac Toe.
///
#[doc = include_str!("./README.md")]
#[derive(Args)]
pub struct TicTacToeArgs {
/// The amount of dimensions in the game.
Expand Down
4 changes: 1 addition & 3 deletions crates/games/src/tic_tac_toe/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Tic Tac Toe is a traditional two-player game played on a 3x3 grid.
//! For the sake of complexity, this allows simulating any n-dimensional 3-in-a-row game
//! with the same bounds as the traditional game.
#[doc = include_str!("./README.md")]

pub mod cli;

Expand Down

0 comments on commit 00ac65e

Please sign in to comment.