cosinekitty / gearbox Goto Github PK
View Code? Open in Web Editor NEWA chess engine written in C#.
License: MIT License
A chess engine written in C#.
License: MIT License
Implement UCI protocol for making a Gearbox plugin engine. That way I can use WinBoard, etc as a UI.
Right now there is a hardcoded path to the piece images. This works only on my Windows 10 development machine. Change the code to look for these images in the same folder as the executable. Change the build process to copy the images to the build output directory.
Implement a simplistic min-max search that can solve checkmate and/or material-winning analysis, without any concept of positional play. Can test this with some lichess.org puzzles?
Right now the code requires the environment variable GEARBOX_TABLEBASE_DIR
to point to the directory holding the endgame tables, in order to use them. This variable should still be supported, but it should be optional. When not set, the program should look in the same directory as the executable.
I'm thinking about creating a standalone GUI application for Linux. Bonus points if it can work for Windows also. I'm looking at Uno Platform.
Implement Portable Game Notation for individual moves.
Put a..h for files and 1..8 for ranks around the chess board.
I just saw the following invalid strings returned by Score.Format():
2021-01-05T20:32:28.5565523Z MOVE Kf7 #-3 3Q4/5k1r/8/5P1p/pP5P/P5P1/5PK1/4R3 w - - 1 59
2021-01-05T20:32:28.5776730Z MOVE Re7+ #3 3Q4/4Rk1r/8/5P1p/pP5P/P5P1/5PK1/8 b - - 2 59
2021-01-05T20:32:28.5777087Z MOVE Kf6 #--523741824 3Q4/4R2r/5k2/5P1p/pP5P/P5P1/5PK1/8 w - - 3 60
2021-01-05T20:32:28.5783610Z MOVE Qd6+ #2 8/4R2r/3Q1k2/5P1p/pP5P/P5P1/5PK1/8 b - - 4 60
2021-01-05T20:32:28.5783816Z MOVE Kxf5 #--523741824 8/4R2r/3Q4/5k1p/pP5P/P5P1/5PK1/8 w - - 0 61
2021-01-05T20:32:28.5785771Z MOVE Qe6# #1 8/4R2r/4Q3/5k1p/pP5P/P5P1/5PK1/8 b - - 1 61
2021-01-05T20:32:28.5817165Z STATS games=212, a_wins=106, a_losses=99, w_wins=107, w_losses=98, draws=7
Right now the code requires two different endgame formats depending on the number of non-king pieces: *.endgame
for 1 or 2 non-kings, or *.egm
for 3 non-kings. This should be reworked so the compressed data is used for both cases.
Apparently recursive directory deletion is more brittle on Windows 10 than Linux.
2021-01-13T03:14:12.80Z [00] Backprop[15]: white changes = 0, black changes = 0, total = 0, prev = 0
Unhandled exception. System.IO.IOException: The process cannot access the file 'b.index' because it is being used by another process.
at System.IO.FileSystem.RemoveDirectoryRecursive(String fullPath, WIN32_FIND_DATA& findData, Boolean topLevel)
at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
at System.IO.Directory.Delete(String path, Boolean recursive)
at EndgameTableGen.TableGenerator.GenerateTable(Int32[,] config) in c:\don\github\gearbox\src\EndgameTableGen\TableGenerator.cs:line 163
at EndgameTableGen.ParallelTableGenerator.ThreadFunc(Object arg) in c:\don\github\gearbox\src\EndgameTableGen\ParallelTableGenerator.cs:line 159
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart(Object obj)
Maintain a hash value inside the Board object as pieces move, etc.
Once this is implemented, it will make an efficient sanity check for PushMove/PopMove: PushMove can save the hash value in the unmove stack, and PopMove can check to make sure the restored hash value matches the popped hash value.
Thinker.NegaMax() keeps searching deeper even when the endgame tables report an exact score for the position. No matter what the score is (win, loss, draw), the score should be considered final if the position is known. Probably need to split out the endgame checker to be a separate function from Thinker.Eval().
In the Windows GUI, allow undoing one ply at a time. If undoing the ply results in a position where it is the computer's turn to move, turn off the computer, so it doesn't immediately start thinking again.
Also allow redo back toward the position from which undo was done. If any move is made which deviates from the forward path, snip the future branch and replace it with the single deviating move.
Given a Board object, or a FEN + a list of Move, generate a PGN game file. Require passing in the minimal set of header tags, and allow arbitrary optional tags.
I'm adding a function Board.GetGameResult
, but it currently only knows about checkmate and stalemate. It calls anything else "game in progress".
There should be a Resign
function to indicate that the current player resigns.
The Board also needs to understand about various non-stalemate draws:
Resign
that will have to be called to inform the Board of the free will of the players).The return value may end up being a struct that also includes a code that indicates why the game is a loss/draw, for display purposes in a UI.
When Thinker scores a position using a hash table hit, the score needs to be adjusted for the actual distance in the future, not the distance in the future when the position was evaluated. Also need to handle repeated positions: if position is repeated once, divide score in half.
Evaluate which GUI functions should be disabled while the computer is thinking. Make sure the game state is not corrupted by the computer trying to make a move onto a board that has changed due to user actions.
Also cancel any partially selected human move whenever OnTurnChanged
is called. (Not sure this ever happens.)
I'm considering creating endgame tables for 3 non-king pieces. This will require considerable computation time and storage space. The most interesting issue will be how to make the Thinker class use such tables, since they will not fit in memory.
Possibilities:
Use the lichess BOT API to make a Gearbox BOT. Here is the API specification.
I would like to make the lichess client part a separate class library. Then I could submit a pull request to be included in their documentation at:
https://github.com/lichess-org/api
Load a game from a PGN file into a Board object. This may imply that the Board needs to store all the tag values, so that it can save back to an identical PGN file (see issue #3).
I found the process of moving Astronomy Engine over to GitHub Actions was quite easy. I will do the same with Gearbox.
Somehow Score.Format returned the string #-1047483651
in a position where I had a forced mate against the Gearbox engine.
The following FEN string crashed the Windows GUI because it is an illegal position:
qk6/8/8/8/8/3BNK2/8/8 b - - 0 1
The GUI should detect this case and gracefully report a warning instead of crashing.
When the user promotes a pawn, the GUI must offer a choice of queen, rook, bishop, knight.
It takes a while to load the endgame tables. This causes a long delay before the chess board is visible. Ideally, I could load the endgame tables in the background and wait until the thinker starts; then block in the thinker thread, instead of blocking the whole UI. If that isn't practical, I should at least have a splash screen so the user can tell something is happening.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.