granted07@kolkata:~/chess-engine$ python main.py
chess-engine
No chess library. Every rule written out by hand, then taught to look ahead.
scroll
A pawn has a first step, a diagonal, and one move that only exists for a single turn.
if p.en_passant: # true for exactly one move
The first time I asked whether a move leaves my king in check, I copied the whole board and played it out. Then I generated every reply, to see if one of them took the king.
temp_board = copy.deepcopy(self)
The engine that thinks does it differently. Move, look, move back. Nothing is copied.
undo, h = make_move(board, move, promo, colour) ... undo_move(board, move, undo)
engine/minimax.py → PST
Every piece has a number for every square. The engine goes where the numbers are tallest.
white above the plane, red below it
It looks one move ahead, then two, then three, then four. If three seconds run out, it plays the best it had.
Most of the work is knowing what not to look at.
Every position gets a fingerprint. A move changes it with a few XORs, so the engine can tell when it has been somewhere before.
r reset · t theme
white to move
waiting for your move hash f0bc8fcb04a23996