r/ComputerChess • u/salsa_sauce • May 29 '22
Are chess engines “stateless”?
Curious outsider here, no clue how chess engines work so forgive me if this is obvious…
When an engine evaluates its next move, does it only calculate “forward” from the current position? Or does it evaluate the history of the match so far?
Does the answer vary between rule-based and neural-networked engines?
19
Upvotes
14
u/[deleted] May 29 '22
for leela the history of the last 8 moves are a part of the input, their is some logic to this; a bad plan is better than no plan and knowing the last 8 moves helps leela's value and policy network play better and maybe come up with plans easier? not sure about the last one as any nn is a black box
12
u/OldWolf2 May 29 '22
Leela actually takes the last few moves as NN input .
Stockfish doesn't; however the hash table is not cleared between moves. So the result you get from analyzing the previous position and then making a move, may differ from if you analyze the later position fresh .
10
u/jbum May 29 '22
Speaking as someone who programmed chess engines in the 90s and early 2000s, while they generally approach each move independently, it was a common technique to use information from prior searches in the form of a cached hash of prior evaluations, which is used to help prune the search tree faster, and basically improve performance.
The chess engine is going to reach the same conclusions without the cached information, but the cache makes it faster.
2
u/Flandoo May 29 '22 edited May 29 '22
There are three rules of chess that require knowing the history of the game:
I don't think there's any other reason an engine would care about the game history (edit: the other commenter made a point about extending the search horizon on recaptures, which is salient!)
1
u/EpicGamerBoss May 29 '22
This may not be entirely accurate and could depend on the engine but in traditional engines many previously evaluated positions are saved in a hash table/transposition tables. The table saves a few different things like the position, search depth, evaluation and other things. Once the engine plays the move many of the components in the table don't match any more (like search depth) so the previous evaluation is not very useful. For neural network engines the use of previous evaluations depends on the engine.
1
u/Disservin May 29 '22
Currently stockfish has a brand new variable called "previousDepth" this uses the previous reached to apply some more pruning. But there is also something called history table/heuristic, that is being used for move sorting, this works with the previous move too.
1
u/totorontoo Aug 07 '22
Are Monte Carlo chess engines stateless?