Skip to content

feat: implement CLI board game ORTHO#1

Merged
hyperfinitism merged 1 commit intomainfrom
feature/core
Apr 3, 2026
Merged

feat: implement CLI board game ORTHO#1
hyperfinitism merged 1 commit intomainfrom
feature/core

Conversation

@hyperfinitism
Copy link
Copy Markdown
Owner

This pull request introduces the initial implementation of a Rust-based board game called "ORTHO" along with supporting infrastructure for building, testing, linting, and license checking.

@hyperfinitism hyperfinitism requested a review from Copilot April 3, 2026 11:57
@hyperfinitism hyperfinitism self-assigned this Apr 3, 2026
@hyperfinitism hyperfinitism added the enhancement New feature or request label Apr 3, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements 'ORTHO', a CLI board game where players alternate turns selecting rows and columns on an N×N grid. The submission includes the game engine, board representation, and a command-line interface. The review identifies critical issues regarding invalid project metadata in Cargo.toml and the use of unstable Rust features. Further improvements are suggested for board memory layout efficiency, idiomatic iterator usage, and more robust error handling for standard I/O.

src/main.rs Outdated
None => "Choose any row or column".to_string(),
};
print!("{} - {} > ", player.id.name(), constraint_msg);
io::stdout().flush().unwrap();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using .unwrap() on I/O operations can cause the program to panic if the output stream is closed or encounters an error. It is safer to use .expect() with a descriptive message or handle the error.

Suggested change
io::stdout().flush().unwrap();
io::stdout().flush().expect("failed to flush stdout");

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an initial Rust implementation of the ORTHO CLI board game, including core game logic (board, turns, win detection), a terminal renderer, input parsing, and GitHub Actions workflows for build/lint/test and SPDX checks.

Changes:

  • Added core game engine modules (board, game, player, types) with unit tests.
  • Implemented CLI loop + input parsing and a text-based board renderer.
  • Added Rust project metadata (Cargo.toml/Cargo.lock), documentation (README.md), and CI workflows (build/lint/test/SPDX).

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types.rs Defines core enums/structs (axis/cell/player/errors) used across the game.
src/player.rs Stores per-player selection state and axis constraint derivation.
src/board.rs Implements board storage and win/full/empty-along checks with tests.
src/game.rs Implements turn processing, skip logic, and win detection with tests.
src/input.rs Parses user input into selections/quit commands with tests.
src/display.rs Renders the board and current selections to the terminal.
src/main.rs CLI entrypoint wiring together parsing, rendering, turn loop, and messaging.
README.md Documents rules, usage, and an example session.
Cargo.toml Declares crate metadata, MSRV, and dependencies (clap).
Cargo.lock Locks dependency graph for reproducible builds.
.github/workflows/test.yml Adds CI test workflow across toolchains and architectures.
.github/workflows/build.yml Adds CI build workflow across toolchains and architectures.
.github/workflows/lint.yml Adds rustfmt + clippy workflows.
.github/workflows/spdx.yml Adds SPDX license header checking.
.gitattributes Enforces LF normalization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +50 to +65
loop {
let sels = Selections {
p1: game.players[0].last_selection,
p2: game.players[1].last_selection,
};
render_board(&game.board, &sels);
println!();

// Auto-skip if no valid completion exists
if let Some(TurnResult::Skipped) = game.check_skip() {
println!(
"{} - No valid placement available. Turn skipped, selection cleared.\n",
game.current().id.name()
);
game.switch_player();
continue;
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_skip() can clear the current player's selection, but the board is rendered before this call and sels is built from the pre-skip state. When a skip happens, the UI will show stale selection markers even though the message says the selection was cleared. Consider moving the check_skip() block before constructing sels/calling render_board, or re-rendering the board after a skip so the displayed state matches the game state.

Copilot uses AI. Check for mistakes.
Signed-off-by: Takuma IMAMURA <209989118+hyperfinitism@users.noreply.github.com>
@hyperfinitism hyperfinitism merged commit 13576e0 into main Apr 3, 2026
46 checks passed
@hyperfinitism hyperfinitism deleted the feature/core branch April 3, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants