Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AY2324S1-CS2113-T18-1/tp
Browse files Browse the repository at this point in the history
…into tricia
  • Loading branch information
TriciaBK committed Nov 14, 2023
2 parents 9fa6733 + aa788a2 commit d7bb443
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 172 deletions.
15 changes: 9 additions & 6 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Contributors

Display | Name | Github Profile | Homepage
---|:---:|:---:|:---:
![](https://avatars0.githubusercontent.com/u/22460123?s=100) | Jeffry Lum | [Github](https://github.com/j-lum/) | [Homepage](https://se.kasugano.moe)
![](https://avatars0.githubusercontent.com/u/1673303?s=100) | Damith C. Rajapakse | [Github](https://github.com/damithc/) | [Homepage](https://www.comp.nus.edu.sg/~damithch/)
![]() | Ou Ningxiang | [Github](https://github.com/onx001/) | [Homepage](https://github.com/onx001)
Name | Github Profile
---|:---:
Antriksh Dhand | [Github](https://github.com/antrikshdhand/)
Ou Ningxiang | [Github](https://github.com/onx001/)
Oh Ken Wei | [Github](https://github.com/ken-ruster/)
Tong Zheng Hong | [Github](https://://github.com/TongZhengHong/)
Tricia Boo Koh | [Github](https://://github.com/TriciaBK/)
# I would like to join this list. How can I help the project

For more information, please refer to our [contributor's guide](https://oss-generic.github.io/process/).

For more information, please refer to our [contributor's guide](README.md#contributing).
7 changes: 3 additions & 4 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ How the minimax algorithm works:
5. The `getBestMove` method returns the best move for the CPU to make.

### Move types
The Move class and its subclasses are responsible for handling the different types of moves in chess.
The Move class is an abstract class that is extended by the following subclasses: StandardMove, PawnOpening, CastleMove, EnPassantMove and PromotionMove.
The Move class is also extended by the following classes: CastleSide, Direction, MoveDirection, MoveType and PromotionPiece.
Below is a class diagram representing the Move class.
The Move class and its subclasses are responsible for handling the different types of moves in chess. The Move class is a parent class of several move types: CastleMove, EnPassantMove and PromoteMove. The MoveFactory class is responsible for generating the correct move type.

Below is a class diagram representing the parent Move class.

![](images/MoveClass.png)

Expand Down
215 changes: 117 additions & 98 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ However, if you prefer to **start a fresh game** or if **no previous game is fou
Choose your starting color to start new game! [b/w/exit]
```

Next, you can choose the difficulty of the AI you will be pitched against! The current supported difficulty levels range from 1 to 4. Please enter the number corresponding to your preferred difficulty level.
Next, you can choose the difficulty of the AI you will be pitched against! The current supported difficulty levels range from 1 to 3. Please enter the number corresponding to your preferred difficulty level.
```
Choose your difficulty level! [1/2/3/4/exit]
Choose your difficulty level! [1/2/3/exit]
```

Inputs that are not compliant with the expect input (indicated in `[]`) will be rejected and users will be prompted to re-input.
Expand All @@ -94,7 +94,7 @@ Additionally, every time a move is executed, ChessMaster provides a comprehensiv
</tr>
<tr>
<td>

<pre><code>
move d2 d4
_________________________________________________________________
Expand Down Expand Up @@ -162,9 +162,7 @@ _________________________________________________________________

The game will automatically end and a victor be declared when one side has been checkmated, or if both players are stuck in a stalemate situation where neither player can avoid moving into a checked position.

Checkmate is the point in the game where the attacking player has the opponent's king in a situation where it can't escape being captured on the next move.

The king is "trapped" and has no safe squares to move to, and no other pieces can help.
Checkmate is the point in the game where the attacking player has the opponent's king in a situation where it can't escape being captured on the next move. The king is "trapped" and has no safe squares to move to, and no other pieces can help.

Otherwise, you may use the `exit` command if you wish to end the game midway and quit the program or `restart` command to start a new game.

Expand All @@ -180,7 +178,7 @@ Examples:
- `move a2 a4`
- `move b3 g6`

ChessMaster also automatically checks if the move was valid and legal before it is executed. If the move is valid, an output as shown above in the [Gameplay](#gameplay) section will be output. Else, the following error
ChessMaster automatically checks if the move is valid and legal before it is executed. If the move is valid, an output as shown above in the [Gameplay](#gameplay) section will be output. Else, the following error
message will be shown:

`Oops, that move isn't valid!`
Expand Down Expand Up @@ -291,26 +289,29 @@ Objective:
_________________________________________________________________
```

#### Further details of special rules
#### 1. Castling

1. Castling
For the move to be valid:
- It's the king's first move.
- It's the rook's first move.
- There are no pieces between the king and the rook.
- The king is not in check and the king will not be in check after castling

For the move to be valid:
- It's the king's first move.
- It's the rook's first move.
- There are no pieces between the king and the rook.
- The king is not in check and the king will not be in check after castling

To perform castling on either sides:
- Move your king two squares to the right/left (towards the rook).
- The rook will jump over the king and land on the square next to the king.
To perform castling on either sides:
- Move your king two squares to the right/left (towards the rook).
- The rook will jump over the king and land on the square next to the king.

Example of castling availability: `moves e1`
Examples and expected output:

Expected Output:
<table>
<tr>
<th>Castling availability: <code>moves e1</code></th>
<th>Execute castle move: <code>moves e1 c1</code></th>
</tr>
<tr>
<td>

<pre><code>
(a) (b) (c) (d) (e) (f) (g) (h)
<pre><code> (a) (b) (c) (d) (e) (f) (g) (h)
_________________________________
(8) | R | | | | K | | | R | (8)
_________________________________
Expand All @@ -328,26 +329,23 @@ _________________________________________________________________
_________________________________
(1) | r | |[.]|[.]|{k}| b | n | r | (1)
_________________________________
(a) (b) (c) (d) (e) (f) (g) (h)

_________________________________________________________________
(a) (b) (c) (d) (e) (f) (g) (h)

Available coordinates for King at e1:
e2 d1 d2 c1
_________________________________________________________________
</code></pre>
_________________________________________________________________

Example: `move e1 c1`
Available coordinates for King at e1:
e2 d1 d2 c1
_________________________________________________________________</code></pre>

Expected Output:
</td>
<td>

<pre><code>
_________________________________________________________________
<pre><code>_________________________________________________________________

You moved King from e1 to c1
_________________________________________________________________
You moved King from e1 to c1
_________________________________________________________________

(a) (b) (c) (d) (e) (f) (g) (h)
(a) (b) (c) (d) (e) (f) (g) (h)
_________________________________
(8) | R | | | | K | | | R | (8)
_________________________________
Expand All @@ -365,75 +363,82 @@ _________________________________________________________________
_________________________________
(1) | | |(k)| r |( )| b | n | r | (1)
_________________________________
(a) (b) (c) (d) (e) (f) (g) (h)
</code></pre>
(a) (b) (c) (d) (e) (f) (g) (h)</code></pre>

2. En Passant:

This move only happens when your opponent moves their pawn two squares forward from its starting position and lands next to your pawn.
To capture en passant, you must do it on your very next move.
- Move your pawn diagonally forward to the square that your opponent's pawn would have occupied if it had moved only one square forward.
</td>
</tr>
</table>

Sample previous board:
#### 2. En Passant:

<pre><code>
_________________________________________________________________
This move only happens when your opponent moves their pawn two squares forward from its starting position and lands next to your pawn.
To capture en passant, you must do it on your very next move.
- Move your pawn diagonally forward to the square that your opponent's pawn would have occupied if it had moved only one square forward.

ChessMaster moved Pawn from e7 to e5
_________________________________________________________________
<table>
<tr>
<th>Sample board before en passant</th>
<th>Executing en passant move: <code>move d5 e6</code></th>
</tr>
<tr>
<td>

(a) (b) (c) (d) (e) (f) (g) (h)
_________________________________
(8) | R | | B | Q | K | B | | R | (8)
_________________________________
(7) | P | P | P | P |( )| P | P | P | (7)
_________________________________
(6) | | | N | | | | | | (6)
_________________________________
(5) | | | | p |(P)| | | | (5)
_________________________________
(4) | | | | | | | | | (4)
_________________________________
(3) | | | | | | | | | (3)
_________________________________
(2) | p | p | | | p | p | p | p | (2)
_________________________________
(1) | r | n | b | q | k | b | n | r | (1)
_________________________________
(a) (b) (c) (d) (e) (f) (g) (h)
</code></pre>
<pre><code>_________________________________________________________________

Example: `move d5 e6`
ChessMaster moved Pawn from e7 to e5
_________________________________________________________________

Expected output:
(a) (b) (c) (d) (e) (f) (g) (h)
_________________________________
(8) | R | | B | Q | K | B | | R | (8)
_________________________________
(7) | P | P | P | P |( )| P | P | P | (7)
_________________________________
(6) | | | N | | | | | | (6)
_________________________________
(5) | | | | p |(P)| | | | (5)
_________________________________
(4) | | | | | | | | | (4)
_________________________________
(3) | | | | | | | | | (3)
_________________________________
(2) | p | p | | | p | p | p | p | (2)
_________________________________
(1) | r | n | b | q | k | b | n | r | (1)
_________________________________
(a) (b) (c) (d) (e) (f) (g) (h)</code></pre>

<pre><code>
(a) (b) (c) (d) (e) (f) (g) (h)
_________________________________
(8) | R | | B | Q | K | B | | R | (8)
_________________________________
(7) | P | P | P | P | | P | P | P | (7)
_________________________________
(6) | | | N | |(p)| | | | (6)
_________________________________
(5) | | | |( )| | | | | (5)
_________________________________
(4) | | | | | | | | | (4)
_________________________________
(3) | | | | | | | | | (3)
_________________________________
(2) | p | p | | | p | p | p | p | (2)
_________________________________
(1) | r | n | b | q | k | b | n | r | (1)
_________________________________
(a) (b) (c) (d) (e) (f) (g) (h)
</td>
<td>

<pre><code>_________________________________________________________________

You moved Pawn from d5 to e6
_________________________________________________________________

_________________________________________________________________
(a) (b) (c) (d) (e) (f) (g) (h)
_________________________________
(8) | R | | B | Q | K | B | | R | (8)
_________________________________
(7) | P | P | P | P | | P | P | P | (7)
_________________________________
(6) | | | N | |(p)| | | | (6)
_________________________________
(5) | | | |( )| | | | | (5)
_________________________________
(4) | | | | | | | | | (4)
_________________________________
(3) | | | | | | | | | (3)
_________________________________
(2) | p | p | | | p | p | p | p | (2)
_________________________________
(1) | r | n | b | q | k | b | n | r | (1)
_________________________________
(a) (b) (c) (d) (e) (f) (g) (h)</code></pre>

Available coordinates for Pawn at d5:
e6 c6 d6
_________________________________________________________________
</code></pre>
</td>
</tr>
</table>

### Show commands: `help`

Expand Down Expand Up @@ -528,8 +533,8 @@ _________________________________________________________________

### Step back in history: `stepback`

Displays the board state as it was a certain number of moves ago. Note that this command does not reverse any moves
in the current game.
Displays the board state as it was a certain number of moves ago. **Note that this command does not reverse any moves
in the current game.**

Format: `stepback [number of moves to step back]`

Expand Down Expand Up @@ -565,7 +570,6 @@ Use `show` to see the current board.
_________________________________________________________________
```


### List pieces in play: `captured`

Lists each player's pieces grouped by whether they have been captured or not.
Expand Down Expand Up @@ -632,6 +636,21 @@ Every time a turn ends, ChessMaster will save the current state of the game. Whe
user will be prompted to choose whether to load the saved game or begin a new one. ChessMaster only supports a single
saved game, and starting a new one will delete the existing save file.

### Editing the storage file
Tasks data are saved automatically in a text (.txt) file `<JAR file location>/data/ChessMaster.txt`. Users are welcome to update data directly by editing this data file to achieve a desired game state.

The format of the saved game in the storage file is as follows:

```json
[CURRENT_PLAYER_COLOR] // Either BLACK or WHITE
[GAME_DIFFICULTY] // Integer from 1 - 3
[NEXT_TURN_COLOR] // Either BLACK or WHITE
[HUMAN_MOVE_HISTORY] // delimited by ','
[CPU_MOVE_HISTORY] // delimited by ','
[CHESS_BOARD_PIECE] // Next 8 lines of 8 characters each
[hasMoved_FLAGS] // Next 8 lines of 8 characters each
```

## FAQ

> **Q**: How do I transfer my data to another computer?
Expand Down
2 changes: 2 additions & 0 deletions docs/diagrams/MoveSequence.puml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ g -> cb : move :Move
deactivate g
activate cb
cb -> cb : isValidMove()
activate cb
cb --> cb : :boolean
deactivate cb
alt Move is valid
create mf
cb -> mf : createMove()
Expand Down
Binary file modified docs/images/MoveSequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 27 additions & 5 deletions docs/team/antrikshdhand.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
# Project Portfolio Page [DRAFT]
# Project Portfolio Page

By Antriksh Dhand (@antrikshdhand)

## Overview

I primarily focused on enhancing the gameplay experience and ensuring the robustness of the codebase. I implemented new key commands, refactored existing code for an improved object-oriented design, and explored end-to-end testing strategies.

## Contributions

### Code contributed

Check out my contributions on the [TP Dashboard](https://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=antrikshdhhttps://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=antrikshdhand&breakdown=truehttps://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=antrikshdhand&breakdown=truehttps://nus-cs2113-ay2324s1.github.io/tp-dashboard/?search=antrikshdhand&breakdown=trueand&breakdown=true).

### Enhancements implemented

### Contributions to the UG
#### `captured`, `history`, and `stepback` Commands

I implemented the `captured`, `history`, and `stepback` commands, allowing the player access to commands they would generally expect to see in a modern chess game. The `stepback` command posed a unique challenge, requiring a deep dive into move reversal mechanisms. This effort involved significant code refactoring to promote cleaner, more object-oriented structures.

#### Object-Oriented Design Refactoring

To enhance code maintainability and extensibility, I introduced sub-classes such as `CastleMove` and `EnPassantMove`. Additionally, the implementation of the `MoveFactory` class, adopting the Factory method pattern, has streamlined the creation of Move objects. This in turn fed into making the reversal of moves much more cleaner to implement and more robust overall. I also encouraged and administered the use of SLAP in our codebase.

### Contributions to the User Guide (UG)

While not introducing new major sections, I diligently maintained the UG by documenting my new commands and ensuring that information stays relevant and up to date.

### Contributions to the Developer Guide (DG)

#### End-to-End Testing Section

I made substantial progress in establishing end-to-end testing for the CLI. Despite not achieving full completion, I laid the groundwork and documented the process in the DG, providing a valuable resource for future testing efforts. You can see a stub of this code in the DG.

### Contributions to the DG
### General Contributions

### Contributions to team-based tasks
Regularly contributed to team discussions, providing insights and assistance where needed.

### Review/mentoring contributions
Actively participated in code reviews and offered constructive feedback to enhance overall code quality.
Loading

0 comments on commit d7bb443

Please sign in to comment.