Skip to content

Commit

Permalink
Version 0.8.0 release 🎉
Browse files Browse the repository at this point in the history
Merge pull request #4 from pkrisz99/development
  • Loading branch information
pkrisz99 authored Feb 12, 2023
2 parents 9b53f96 + f76cd25 commit 08b7274
Show file tree
Hide file tree
Showing 22 changed files with 1,271 additions and 655 deletions.
3 changes: 2 additions & 1 deletion Python/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
perft.json
perft.json
wac.epd
125 changes: 125 additions & 0 deletions Python/AccuracyTesting.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7c25a2a9",
"metadata": {},
"source": [
"### Automated accuracy testing\n",
"\n",
"This is script is made for testing Renegade with various suites. \n",
"Particularly: http://www.bergbomconsulting.se/chess/epdfiles/wac.epd\n",
"\n",
"As long as the engine returns `bestmove ....` and then sends a stopping message (in this case `Stopping engine.`), it should be easy to adapt it to other engines as well.\n",
"\n",
"Requires the `python-chess` library for converting the algebraic notation to uci string."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b5c71f52",
"metadata": {},
"outputs": [],
"source": [
"# Set the path to executable and json here\n",
"path = \"../x64/Release/Renegade.exe\"\n",
"epd = \"wac.epd\"\n",
"\n",
"parameters = \"movetime 1000\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11062104",
"metadata": {},
"outputs": [],
"source": [
"import subprocess\n",
"import json\n",
"import time\n",
"import chess\n",
"\n",
"tests = []\n",
"with open(epd) as file:\n",
" lines = [line.rstrip().split() for line in file]\n",
" for line in lines:\n",
" fen = line[0] + \" \" + line[1] + \" \" + line[2] + \" \" + line[3] + \" 0 1\"\n",
" moves = []\n",
" i = line.index(\"bm\")\n",
" while True:\n",
" i += 1\n",
" best_move = line[i]\n",
" if best_move.endswith(\";\"):\n",
" best_move = best_move[:-1]\n",
" moves.append(best_move)\n",
" break\n",
" moves.append(best_move)\n",
" tests.append({\"fen\": fen, \"bm\": moves})\n",
" \n",
"def run():\n",
" print(\"Started.\\n\")\n",
" good = 0\n",
" total = 0\n",
" for test in tests:\n",
" total += 1\n",
" board = chess.Board(test['fen'])\n",
" bm_uci = []\n",
" for bm in test['bm']:\n",
" bm_uci.append(board.parse_san(bm).uci())\n",
" output = runtest(test['fen'])\n",
" if str(output, 'ascii') in bm_uci:\n",
" good += 1\n",
" print('%3d. %-68s ' % (total, test['fen']), ' -> ', output, '(correct: ', bm_uci, ')')\n",
" print(\"\\nCompleted.\")\n",
" print(\"Constraints: '%s', correct: %d/%d\" % (parameters, good, total))\n",
"\n",
"def runtest(fen):\n",
" proc = subprocess.Popen([path, '-l', ''], stdout=subprocess.PIPE, stdin=subprocess.PIPE)\n",
" proc.stdin.write(('position fen ' + fen + '\\n').encode())\n",
" proc.stdin.write(('go %s\\n' % parameters).encode())\n",
" proc.stdin.close()\n",
" i = 0\n",
" start = time.time_ns()\n",
" lastline = \"\"\n",
" while True:\n",
" out = proc.stdout.readline().strip()\n",
" if out == b'Stopping engine.': break\n",
" lastline = out\n",
" return lastline.split()[1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "949a62a7",
"metadata": {},
"outputs": [],
"source": [
"run()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ The engine is moderately strong, and regularly competes on Lichess over at https


## Features
**Board representation >** Bitboards with a generated lookup table, threefold repetition, insufficient material, checkmate and stalemate detection
**Board representation >** Bitboards, dynamically generated lookup tables, threefold repetition detection

**Move generation >** Pseudolegal, attack map generation for legality checking, lookup tables, parallel bitwise sliding attack generation
**Move generation >** Pseudolegal, insufficient material, checkmate and stalemate recognition, attack map generation for legality checking, lookup tables, parallel bitwise sliding attack generation

**Search >** Alpha-beta pruning, iterative deepening, move ordering, principal variation search, quiescence search, transposition table, killer move heuristic, null move pruning, delta pruning, check extensions
**Search >** Alpha-beta pruning, iterative deepening, move ordering, principal variation search, quiescence search, transposition table, killer move heuristic, null move pruning, delta pruning, check extensions, futility pruning, razoring, drawish endgame recognition

**Evaluation >** Material, piece-square tables, tapered evaluation, tempo bonus, doubled & tripled pawn penalty, passed pawn bonus, king safety
**Evaluation >** Material, piece-square tables, tapered evaluation, piece mobility, tempo bonus, doubled & tripled pawn penalty, passed pawn bonus, king safety

**Misc >** Communication with UCI protocol, Texel's tuning method, time management, perft, limited opening book support, debug commands
**Misc >** Communication with UCI protocol, Texel's tuning method, time management, perft, opening book support, debug commands


### Known issues & future plans

While Renegade itself is quite good against human players, it has a significantly harder time against other engines. The move generation is quite slow, only achieving about ~4 million nps in perft and 300k during evaluation, and a lot of pruning ideas are also remain to be implemented. To compensate for this, the evaluation function is a bit more thorough.
While Renegade itself is quite good against human players, it has a significantly harder time against other engines. The move generation is quite slow, only achieving about ~5 million nps in perft and 300k during evaluation, and a lot of pruning ideas are also remain to be implemented. To compensate for this, the evaluation function is a bit more thorough.

The engine is generally stable, and shouldn't make invalid moves or forfeit on time. Some of the issues include the inability to listen for `stop` commands and occasionally outputting incorrect PV lines.

Expand All @@ -35,13 +35,13 @@ If you are familiar with the protocol, you can also try running it by itself.

Example output:
```
Renegade chess engine 0.7.0 [Jan 15 2023 20:52:03]
Renegade chess engine 0.8.0 [Feb 12 2023 23:27:32]
go depth 5
info depth 1 seldepth 1 score cp 32 nodes 20 nps 170068 time 0 hashfull 0 pv g1f3
info depth 2 seldepth 2 score cp 18 nodes 59 nps 26823 time 2 hashfull 0 pv g1f3 g8f6
info depth 3 seldepth 3 score cp 32 nodes 523 nps 129870 time 4 hashfull 0 pv g1f3 g8f6 b1c3
info depth 4 seldepth 8 score cp 18 nodes 1354 nps 167069 time 8 hashfull 0 pv g1f3 g8f6 b1c3 b8c6
info depth 5 seldepth 9 score cp 22 nodes 8514 nps 325346 time 26 hashfull 0 pv g1f3 g8f6 b1c3 b8c6 e2e4
info depth 1 seldepth 1 score cp 32 nodes 20 nps 48157 time 0 hashfull 0 pv g1f3
info depth 2 seldepth 2 score cp 18 nodes 59 nps 19280 time 3 hashfull 0 pv g1f3 g8f6
info depth 3 seldepth 3 score cp 32 nodes 523 nps 101219 time 5 hashfull 0 pv g1f3 g8f6 b1c3
info depth 4 seldepth 8 score cp 18 nodes 1307 nps 140643 time 9 hashfull 0 pv g1f3 g8f6 b1c3 b8c6
info depth 5 seldepth 9 score cp 22 nodes 5261 nps 240744 time 21 hashfull 0 pv g1f3 g8f6 b1c3 b8c6 e2e4
bestmove g1f3
```

Expand All @@ -50,4 +50,6 @@ Most UCI commands are supported including limiting search to a specific depth, t
Furthermore, there are some custom commands, including `eval`, `draw` and `fen`. Perft test can be accessed by typing `go perft [n]` or `go perftdiv [n]`.

## Acknowledgments
Getting this far would not have been possible without the contributors of the [Chess Programming Wiki](https://www.chessprogramming.org/Main_Page), and I'm deeply grateful for [Maksim Korzh](https://youtube.com/playlist?list=PLmN0neTso3Jxh8ZIylk74JpwfiWNI76Cs) and [Bluefever Software](https://youtube.com/playlist?list=PLZ1QII7yudbc-Ky058TEaOstZHVbT-2hg) for making a video series on this subject.
Getting this far would not have been possible without the contributors of the [Chess Programming Wiki](https://www.chessprogramming.org/Main_Page), and I'm deeply grateful for [Maksim Korzh](https://youtube.com/playlist?list=PLmN0neTso3Jxh8ZIylk74JpwfiWNI76Cs) and [Bluefever Software](https://youtube.com/playlist?list=PLZ1QII7yudbc-Ky058TEaOstZHVbT-2hg) for making a video series on this subject.

Additionally, I would also like to thank everyone who spent the time trying out and testing the engine, which provides valuable feedback.
Loading

0 comments on commit 08b7274

Please sign in to comment.