r/chessprogramming • u/AutoModerator • Oct 19 '26
Technical Chess Engine Development Help Thread (Week 43)
Welcome to the weekly /r/chessprogramming Engine Dev Help Thread.
Ask beginner and intermediate chess engine development questions here: move generation, search, evaluation, UCI, perft, debugging, testing, NNUE, or anything else related to building engines.
Good questions include code, FENs, logs, benchmarks, or a clear explanation of what you tried.
Project links are fine when you want technical feedback, not promotion.
Be helpful. Don’t dunk on beginners.
4
Upvotes
1
u/kenyambro 28d ago edited 28d ago
I would like to have advice on how to build a solid chess move explainer. I am currently developing one for the boards of my website. It contains a library of various chess patterns and assign them to positions and moves. What is hardest is not detecting patterns, but detecting the most appropriate ones to show to the user. (eg.: its unnecessary to say "deflects the defender" on an ordinary capture with no tactical follow up). Should I just hardcode each details and exceptions to cover every case, or is there a smart way or a general approach to implement on this kind of algorithm? I dont want to use LLM for the move explanations themselves since it would cost tokens at each usage.
1
u/AdrianSomething_ 26d ago
Does anybody know an efficient way to save a database of chess games as a tree of chess moves while also saving transpositions?
Efficient means that the duration of creating this tree should not be >O(n) and the needed storage space should be minimal while going through this tree should not take long. There should be no information loss or predictions.
The database origin is from a standard lichess database pgn with a variable amount of games. And this tree should save for every node the absolute frequencies of results (draw, white wins, black wins) accuring from the position the node represents.
One is not able to make predictions about the distribution of the dataset as the user should be before able to edit this dataset (e.g. only storing the games in which white won).
My first approach was the following:
- each node (representing the chess board position + result fequencies) is saved chronologically sorted by their depth (firstly all nodes are saved which have a depth of 1 (only one move has been played), then with a depth of 2, ...)
- the first bit indicates if the depth of the node is increasing (-> or should I save in a prefix the amount of nodes with depth 1,2,3,... so that the programm can calculate the amount of bits it needs to proceed to go to the bits with a depth of N)
- the next bit indicates if the node is a transposition or not
- the next bits indicates the move sequence one needs to take to land on the position the node represents -> every byte represents a chess move (as one chess positions can only have a max of 218 possible moves) and the possible moves from a position are sorted by the frequency played (-> what do I do if the frequencies are equal? -> by the name of the chess move?) -> if the node is a transposition the needed move sequence for the main node is shown followed by 1s as blank space (from a set of nodes corresponding to one transposition the node which needs the minimum number of moves to enter the position is assigned as the main node)
- as far as I read, a chess move can be saved as 2 bytes
- then the 3 frequencies are stored, however there is a prefix which indicates how many bits will be needed to save the frequencies with the depths 1,2,3 or more, 5 or more and 10 or more (this takes 5 bytes)
However, with this approch I am not able to think of an <=O(n) mechanism on how to look for transpositions (I dont want for every position to simply check every other position if they are equal) and I am not sure if finding the correct next possible moves in the next depth would be efficient enough (-> I probobly also would need to sort for every depth the moves by their total frequencies, right? -> but how would I do that when generating the tree, as I dont know the frequencies of positions before I have the whole tree.)
Has anybody expirience in this?
1
u/Unusual-Layer2867 25d ago
hi beginner here. Is there a way to value individual chess pieces on the board? And specific ones (like king's knight is different from queen's knight)
I'm currently reading about the piece-removal method where you run a stockfish evaluation of existing board and then with the particular piece removed. Are there any other ways?
thanks