Keep track of move history and allow game navigation#25
Open
Bhoomish-Patel wants to merge 1 commit intoprrockzed:mainfrom
Open
Keep track of move history and allow game navigation#25Bhoomish-Patel wants to merge 1 commit intoprrockzed:mainfrom
Bhoomish-Patel wants to merge 1 commit intoprrockzed:mainfrom
Conversation
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 Pull Request Overview
Description
Please provide a clear and concise description of the changes made in this pull request.
Summary:
To check the
[ ]box, write 'x' between the square brackets (leave the box unchecked if it is not applicable to you)🐛 Bug Fix:
✨ New Feature:
track of move history and allowing users to navigate between the moves provides a better player experience.
Move History and Game Navigation Feature
The feature to keep track of move history and allow game navigation was implemented in the Arbiter component of the chess application. Below are the key components and strategies used:
State Management
Board State
The current state of the chessboard is managed using the
useStatehook, which holds aBoardobject. This object is cloned from the initial board setup and updated with each move.Board History
A separate state,
boardHistory, is maintained to keep a record of all board states after each move. This allows for easy navigation between different game states.Move History
Another state,
moveHistory, is used to store the algebraic notation of moves for each team. This is updated every time a move is played, capturing the move details and any special notations like check or promotion.Move Execution
The
playMovefunction is responsible for executing a move.boardHistory.moveHistorywith algebraic notation, including special cases like check or pawn promotion.Game Navigation
Navigation Functions
Two functions are implemented to facilitate navigation through the game's history:
gotToMove: Navigates to a specific move in the game history.User Interface
Navigation Buttons:
Move History Table:
A table displays the move history for all teams, allowing players to review past moves. The teams are:
Summary of Key Features
useStatefor board, board history, and move history.Additional Context
Open Source Programs
KWoc
✅ Checklist: