Skip to content

Commit

Permalink
Merge pull request #309 from chesslablab/issue/307-Update-the-docs-on…
Browse files Browse the repository at this point in the history
…-the-game-modes

Issue/307 update the docs on the game modes
  • Loading branch information
programarivm authored Jul 19, 2024
2 parents 66d222f + 7f31fb3 commit 24c2f04
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 43 deletions.
24 changes: 18 additions & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ That's it!
Now you're set up to start playing chess.

```js
ws.send('/start classical fen');
ws.send('/start classical analysis');
```

The `/start` command starts a new classical chess game and retrieves a JSON response from the server.
Expand All @@ -30,8 +30,12 @@ The `/start` command starts a new classical chess game and retrieves a JSON resp
{
"/start": {
"variant": "classical",
"mode": "fen",
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -"
"mode": "analysis",
"turn": "w",
"movetext": "",
"fen": [
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -"
]
}
}
```
Expand Down Expand Up @@ -65,7 +69,11 @@ The `/play_lan` command above retrieves the following JSON response.
"isMate": false,
"isStalemate": false,
"isFivefoldRepetition": false,
"mode": "fen",
"isFiftyMoveDraw": false,
"isDeadPositionDraw": false,
"doesDraw": false,
"doesWin": false,
"mode": "analysis",
"variant": "classical",
"isValid": true
}
Expand Down Expand Up @@ -93,7 +101,11 @@ Once again the `/play_lan` command makes a chess move, this time retrieving the
"isMate": false,
"isStalemate": false,
"isFivefoldRepetition": false,
"mode": "fen",
"isFiftyMoveDraw": false,
"isDeadPositionDraw": false,
"doesDraw": false,
"doesWin": false,
"mode": "analysis",
"variant": "classical",
"isValid": true
}
Expand All @@ -106,7 +118,7 @@ Described below is the series of steps required to start a classical chess game

```js
const ws = new WebSocket('wss://async.chesslablab.org:8443');
ws.send('/start classical fen');
ws.send('/start classical analysis');
ws.send('/play_lan w e2e4');
ws.send('/play_lan b e7e5');
```
Expand Down
Binary file modified docs/getting-started_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/getting-started_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/legal.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The location of the piece on the board.
Start a classical game to find out the legal moves of the piece on e2.

```js
ws.send('/start classical fen');
ws.send('/start classical analysis');
ws.send('/legal e2');
```

Expand Down
6 changes: 4 additions & 2 deletions docs/play-lan.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The chess move in LAN format.
Starts a classical game to play 1.e4.

```js
ws.send('/start classical fen');
ws.send('/start classical analysis');
ws.send('/play_lan w e2e4');
```

Expand All @@ -41,7 +41,9 @@ ws.send('/play_lan w e2e4');
"isFivefoldRepetition": false,
"isFiftyMoveDraw": false,
"isDeadPositionDraw": false,
"mode": "fen",
"doesDraw": false,
"doesWin": false,
"mode": "analysis",
"variant": "classical",
"isValid": true
}
Expand Down
70 changes: 41 additions & 29 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@ The chess variant as per these options.

- `classical` chess, also known as standard or slow chess.
- `960` is the same as classical chess except that the starting position of the pieces is randomized.
- `dunsany` is an asymmetric variant in which Black has the standard chess army and White has 32 pawns.
- `losing` chess, the objective of each player is to lose all of their pieces or be stalemated.
- `racing-kings` consists of being the first player to move their king to the eighth row.

## `mode`

The game mode as per these options.

- `fen` is used to start games from specific chess positions.
- `san` is used to load games from the starting position.
- `analysis` is used to start games for further analysis.
- `play` allows to play chess online with other players.
- `stockfish` allows to play chess against the computer.

## `add` (optional)
## `settings` (optional)

Additional optional parameters may be required depending on the mode selected as shown in the examples below.

- `color`
- `fen`
- `increment`
- `min`
- `movetext`
- `startPos`
- `settings`
- `color`
- `submode`

---

Expand All @@ -35,15 +39,19 @@ Additional optional parameters may be required depending on the mode selected as
### Start a classical game

```js
ws.send('/start classical fen');
ws.send('/start classical analysis');
```

```text
{
"/start": {
"variant": "classical",
"mode": "fen",
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -"
"mode": "analysis",
"turn": "w",
"movetext": "",
"fen": [
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -"
]
}
}
```
Expand All @@ -52,18 +60,22 @@ ws.send('/start classical fen');

| Name | Description | Required |
| ---- | ----------- | -------- |
| `add` | `fen` | Yes |
| `settings` | `fen` | Yes |

```js
ws.send('/start classical fen "{\\"fen\\":\\"r1bqkbnr/pppppppp/2n5/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq d3\\"}"');
ws.send('/start classical analysis "{\\"fen\\":\\"r1bqkbnr/pppppppp/2n5/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq d3\\"}"');
```

```text
{
"/start": {
"variant": "classical",
"mode": "fen",
"fen": "r1bqkbnr/pppppppp/2n5/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq -"
"mode": "analysis",
"turn": "b",
"movetext": "",
"fen": [
"r1bqkbnr/pppppppp/2n5/8/3PP3/8/PPP2PPP/RNBQKBNR b KQkq -"
]
}
}
```
Expand All @@ -72,17 +84,17 @@ ws.send('/start classical fen "{\\"fen\\":\\"r1bqkbnr/pppppppp/2n5/8/3PP3/8/PPP2

| Name | Description | Required |
| ---- | ----------- | -------- |
| `add` | `movetext` | Yes |
| `settings` | `movetext` | Yes |

```js
ws.send('/start classical san "{\\"movetext\\":\\"1.e4 Nc6 2.d4\\"}"');
ws.send('/start classical analysis "{\\"movetext\\":\\"1.e4 Nc6 2.d4\\"}"');
```

```text
{
"/start": {
"variant": "classical",
"mode": "san",
"mode": "analysis",
"turn": "b",
"movetext": "1.e4 Nc6 2.d4",
"fen": [
Expand All @@ -99,26 +111,26 @@ ws.send('/start classical san "{\\"movetext\\":\\"1.e4 Nc6 2.d4\\"}"');

| Name | Description | Required |
| ---- | ----------- | -------- |
| `add` | `movetext`<br/>`startPos` | Yes |
| `settings` | `movetext`<br/>`startPos` | Yes |

```js
ws.send('/start 960 san "{\\"movetext\\":\\"1.e4 Nc6 2.d4\\",\\"startPos\\":\\"BNRKQBRN\\"}"');
ws.send('/start 960 analysis "{\\"movetext\\":\\"1.e4 Nc6 2.d4\\",\\"startPos\\":\\"BNRKQBRN\\"}"');
```

```text
{
"/start": {
"variant": "960",
"mode": "san",
"mode": "analysis",
"turn": "b",
"movetext": "1.e4 Nc6 2.d4",
"fen": [
"bnrkqbrn/pppppppp/8/8/8/8/PPPPPPPP/BNRKQBRN w KQkq -",
"bnrkqbrn/pppppppp/8/8/4P3/8/PPPP1PPP/BNRKQBRN b KQkq e3",
"b1rkqbrn/pppppppp/2n5/8/4P3/8/PPPP1PPP/BNRKQBRN w KQkq -",
"b1rkqbrn/pppppppp/2n5/8/3PP3/8/PPP2PPP/BNRKQBRN b KQkq d3"
"rnbkqbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBKQBNR w KQkq -",
"rnbkqbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBKQBNR b KQkq e3",
"r1bkqbnr/pppppppp/2n5/8/4P3/8/PPPP1PPP/RNBKQBNR w KQkq -",
"r1bkqbnr/pppppppp/2n5/8/3PP3/8/PPP2PPP/RNBKQBNR b KQkq d3"
],
"startPos": "BNRKQBRN"
"startPos": "RNBKQBNR"
}
}
```
Expand All @@ -127,7 +139,7 @@ ws.send('/start 960 san "{\\"movetext\\":\\"1.e4 Nc6 2.d4\\",\\"startPos\\":\\"B

| Name | Description | Required |
| ---- | ----------- | -------- |
| `add` | `color` | Yes |
| `settings` | `color` | Yes |

```js
ws.send('/start classical stockfish {"color":"b"}');
Expand Down Expand Up @@ -156,8 +168,8 @@ ws.send('/start classical play {"min":5,"increment":3,"color":"b","submode":"onl
"variant": "classical",
"mode": "play",
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -",
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhc3luYy5jaGVzc2xhYmxhYi5vcmciLCJpYXQiOjE3MTYzOTE1MTMsImV4cCI6MTcxNjM5NTExMywidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJvbmxpbmUiLCJjb2xvciI6ImIiLCJtaW4iOjUsImluY3JlbWVudCI6MywiZmVuIjoicm5icWtibnIvcHBwcHBwcHAvOC84LzgvOC9QUFBQUFBQUC9STkJRS0JOUiB3IEtRa3EgLSJ9.BBJROgd2AP9_65QM3UIuxHk9HJ7ySwb_Y7HlVFFxnQE",
"hash": "2a2c768c"
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhc3luYy5jaGVzc2xhYmxhYi5vcmciLCJpYXQiOjE3MjE0MDIyNzksImV4cCI6MTcyMTQwNTg3OSwidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJvbmxpbmUiLCJjb2xvciI6ImIiLCJtaW4iOjUsImluY3JlbWVudCI6MywiZmVuIjoicm5icWtibnIvcHBwcHBwcHAvOC84LzgvOC9QUFBQUFBQUC9STkJRS0JOUiB3IEtRa3EgLSJ9.ftJf7UkcL7EwrjsKQh29VgLHKVtKXggl5TZIruRdKoA",
"hash": "70a777dd"
}
}
```
Expand All @@ -166,7 +178,7 @@ ws.send('/start classical play {"min":5,"increment":3,"color":"b","submode":"onl

| Name | Description | Required |
| ---- | ----------- | -------- |
| `add` | `settings` | Yes |
| `settings` | `min`<br/>`increment`<br/>`color`<br/>`submode` | Yes |

```js
ws.send('/start classical play "{\\"min\\":5,\\"increment\\":3,\\"color\\":\\"w\\",\\"submode\\":\\"friend\\"}"');
Expand All @@ -178,8 +190,8 @@ ws.send('/start classical play "{\\"min\\":5,\\"increment\\":3,\\"color\\":\\"w\
"variant": "classical",
"mode": "play",
"fen": "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -",
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhc3luYy5jaGVzc2xhYmxhYi5vcmciLCJpYXQiOjE3MTYzOTE1NTAsImV4cCI6MTcxNjM5NTE1MCwidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJmcmllbmQiLCJjb2xvciI6InciLCJtaW4iOjUsImluY3JlbWVudCI6MywiZmVuIjoicm5icWtibnIvcHBwcHBwcHAvOC84LzgvOC9QUFBQUFBQUC9STkJRS0JOUiB3IEtRa3EgLSJ9.t40rbfZJb8JF8QpVMx9v96yQXzw54gLALMnKRS6qFdE",
"hash": "c13d765b"
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhc3luYy5jaGVzc2xhYmxhYi5vcmciLCJpYXQiOjE3MjE0MDI1MDYsImV4cCI6MTcyMTQwNjEwNiwidmFyaWFudCI6ImNsYXNzaWNhbCIsInN1Ym1vZGUiOiJmcmllbmQiLCJjb2xvciI6InciLCJtaW4iOjUsImluY3JlbWVudCI6MywiZmVuIjoicm5icWtibnIvcHBwcHBwcHAvOC84LzgvOC9QUFBQUFBQUC9STkJRS0JOUiB3IEtRa3EgLSJ9.myjbwTAy_z8CxnPwIQiJqzqYpGmj8bg52R89HB53NrQ",
"hash": "3b9777a6"
}
}
```
8 changes: 5 additions & 3 deletions docs/stockfish.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,19 @@ ws.send('/stockfish "{\\"Skill Level\\":20}" "{\\"depth\\":12}"');
{
"/stockfish": {
"turn": "w",
"pgn": "e5",
"pgn": "c5",
"castlingAbility": "KQkq",
"movetext": "1.e4 e5",
"fen": "rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6",
"movetext": "1.e4 c5",
"fen": "rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6",
"isCapture": false,
"isCheck": false,
"isMate": false,
"isStalemate": false,
"isFivefoldRepetition": false,
"isFiftyMoveDraw": false,
"isDeadPositionDraw": false,
"doesDraw": false,
"doesWin": false,
"mode": "stockfish",
"variant": "classical"
}
Expand Down
8 changes: 6 additions & 2 deletions docs/undo.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Undoes the last move.
Starts a classical game to play 1.e4 e5 2.f4 undoing the last move.

```js
ws.send('/start classical fen');
ws.send('/start classical analysis');
ws.send('/play_lan w e2e4');
ws.send('/play_lan b e7e5');
ws.send('/play_lan w f2f4');
Expand All @@ -31,7 +31,11 @@ ws.send('/undo');
"isMate": false,
"isStalemate": false,
"isFivefoldRepetition": false,
"mode": "fen",
"isFiftyMoveDraw": false,
"isDeadPositionDraw": false,
"doesDraw": false,
"doesWin": false,
"mode": "analysis",
"variant": "classical"
}
}
Expand Down

0 comments on commit 24c2f04

Please sign in to comment.