kylchiu / sporkfish Goto Github PK
View Code? Open in Web Editor NEWChess engine in Python
License: MIT License
Chess engine in Python
License: MIT License
Separate the DEV and PROD actions so that we only get a red badge if prod CI is broken.
Add mypy to workflow.
Requirements:
OpeningBook
class, see opening_book.py
.engine.py
, similar to what is done with OpeningBook
.You can download databases for testing on: https://syzygy-tables.info/?fen=4k3/8/8/8/8/8/8/4K3_w_-_-_0_1
Zobrist hashing and cache caused 10x slowdown. Check why.
Guess that's the whole point of having MG and EG? they evaluate to give different scores?
How do I validate the piece values are correct/meaningful? Seems a bit like a random blackbox to me still.
Originally posted by @ccjeremylo in #15 (comment)
This involves storing moves that cause beta cutoffs and trying them first if they are legal next time you are at the same depth. https://rustic-chess.org/search/ordering/killers.html
Investigate and consider other time management strategies.
Engine currently makes the move for the board, but this isn't ideal as engine does not own the board. Making a move should be moved to the UCIClient level instead.
I'd like to install pypy as well. Adding this as a new feature later..
Originally posted by @KYLChiu in #22 (comment)
ncalls tottime percall cumtime percall filename:lineno(function)
254103 8.220 0.000 22.513 0.000 evaluator.py:873(evaluate)
17411446 5.067 0.000 9.103 0.000 init.py:725(piece_at)
17411318 4.558 0.000 14.572 0.000 board_py_chess.py:109(piece_at)
18221628 3.290 0.000 3.290 0.000 init.py:735(piece_type_at)
270052 1.188 0.000 2.835 0.000 init.py:2200(push)
1576589 1.115 0.000 2.544 0.000 init.py:1706(generate_pseudo_legal_moves)
6840750 0.911 0.000 0.911 0.000 piece.py:14(init)
12264738 0.864 0.000 0.864 0.000 evaluator.py:897()
3063713 0.691 0.000 0.806 0.000 init.py:314(scan_reversed)
1510784 0.689 0.000 4.759 0.000 init.py:3582(generate_legal_moves)
Notice that piece wrapping id 4.5 seconds itself. The code is just
def piece_at(self, square: Square) -> Optional[Piece]:
"""
Get the piece at the specified square.
:param square: The target square.
:type square: int
:return: The piece at the specified square, or None if the square is empty.
:rtype: Optional[Piece]
"""
return (
Piece(piece.piece_type, piece.color)
if (piece := self.board.piece_at(square))
else None
)
but due to sheer amount of calls, this becomes a problem.
Investigate why this returns None
FEN: r1r3k1/1ppp1ppp/p7/8/1P1nPPn1/3B1RP1/P1PP3q/R1BQ2K1 w - - 2 18
Re-enable lazy smp and test it works. Most urgent to check Windows.
Add tests for workflow, including
This is a long-term feature to implement NNUE (efficiently updated neural network) to replace
See:
Requirements:
Requirements:
PrincipalVariationSearch
inheriting from NegamaxSP
. Implement the pseudocode here, https://en.wikipedia.org/wiki/Principal_variation_searchComments:
_negamax
in PrincipalVariationSearcher.start_search_from_root
, because then you only get null window searches at the root.Make depth reduction factor configurable.
Given we pass them in the config file, no need to pass default values in config classes.
Change tests to be more explicit in argument passing.
Currently engine creation is hardcoded in UCIClient. Engine creation should be far more flexible, i.e. we should be able to pass in config from the main function. Easiest way to do this is serialised config via yml file, or if you think of a better option please suggest. This should include:
Long term research task to implement MCTS.
E.g. test behaviour when depth_reduction_factor = 0
@claudiayip could you upload the docker file we made if you still have it - when you get a chance pls?
https://www.chessprogramming.org/Principal_Variation - this should be printed in the searcher (currently just prints the best move). This is useful for:
Incorrect merge case
Requirements:
Tips:
ncalls tottime percall cumtime percall filename:lineno(function)
254103 7.704 0.000 17.060 0.000 evaluator.py:877(evaluate)
For a depth 6 call, we have 7 seconds spent in evaluate alone (excluding outgoing function calls). This could potentially be sped up by using numba.
Add iterative deepening: https://www.chessprogramming.org/Iterative_Deepening. The benefits are:
To do it:
search
through depths from 1 to max_depth
instead of running it only at max_depth
._negamax_mp
, i.e. you may send some processes to depth + k
for k={1,2,3...}
to populate transpositions table in parallel and see what works best.Null-move pruning is a method to reduce the alpha-beta negamax search tree. It refers passing to your turn (i.e. making a "null" move) and dynamically evaluating the position. If the evaluated score after the null move is "too good" (above beta). The assumption is that the opponent wouldn't allow such a favourable position, so the search can be pruned (beta-cutoff).
Requirements:
_negamax
.See:
NB: static evaluation function must return a score relative to the side to being evaluated, e.g. the simplest score evaluation could be:
score = materialWeight * (numWhitePieces - numBlackPieces) * who2move
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.