To convert a single bitboard to a numpy array:
def bitboard_to_array(bb: int) -> np.ndarray:
s = 8 * np.arange(7, -1, -1, dtype=np.uint64)
b = (bb >> s).astype(np.uint8)
b = np.unpackbits(b, bitorder="little")
return b.reshape(8, 8)
To convert multiple bitboards to a numpy array:
def bitboards_to_array(bb: np.ndarray) ->...
I never was lucky googling
No need to google. All you needed to do was search on this site and you could have come up with this answer which amongst other things says:
Ronald de Man (syzygy developer) has published software for generating these tablebases (up to 6 man) on Github
I found this reddit post which has two comments which answer this question.
This is essentially exactly what I was looking for and bonus points in that I think I found their github that has their code which seems shockingly simple
I made something like that, both open source
Lichess has the "learn from your mistakes" feature, which can be used to play your significantly bad moves in a game as a puzzle.
From your profile, select a variant/time control on the left, then click "view the games" in the top right. Click on a game, go to the analysis board, and at the bottom, in the "computer analysis" ...
I don't know of a single program that does all that. I do it myself with following steps. I save most of my games in a pgn file. The interesting ones, esp. my losses, are analyzed by Stockfish. The "blunder threshold" is your choice, typically 3 - 5 pawns or more. With Notepad++ text editor I enter the FEN of the position in a pgn file, of course ...
We are going to need the source code : git clone https://github.com/official-stockfish/Stockfish.git (see the right address at Stockfish's github as this address could change) somewhere on your PC. (You need the command line utilities of Tortois Git for instance.) Let's call StockFishDIr the full path to the StockFish folder (that contains src as subfolder) ...
As the version of python-chess I'm running doesn't support chess.uci, here's what worked for me.
engine = chess.engine.SimpleEngine.popen_uci("/path/to/engine.exe")
board = chess.Board()
info = engine.analyse(board, chess.engine.Limit(time=10),multipv=20))
info is a list of InfoDict objects, each with the keys "pv" and "score", ...
I actually did the experiment and will answer now. Three main factors go into the evaluation (as king safety doesn't play the slightest role): material, space, and movability.
The effect of space is rather high at +1.4.
[FEN "4k3/p1p1p1p1/P1P1P1P1/8/8/8/8/4K3 w - - 0 1"]
Any useless doubled pawn is about +0.7, giving +4.2.
The chessboard editor at https://www.apronus.com/chess/pgnviewer/ has two modes selected by radio buttons: "position setup" and "legal moves only". In position setup you can do anything on the board including adding or removing chessmen.
I have found the problem: my board representation was different and while my ranks are also from 0-7, but they are counted from the black side, while in the polyglot encoding, they are counted from the white side (which makes sense).
So I had to invert my ranks like so:
unsigned short fromFile = (moveKey>>6)&7,
fromRank = ...