Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce opening book support #1883

Closed
wants to merge 3 commits into from

Conversation

noobpwnftw
Copy link
Contributor

My study have shown that it does no harm to use an opening book instead of a search, while the latter being largely deterministic.

This is a primitive version, using a PolyGlot-like book format but with our own Zobrist hash keys, so the probing might be cheap enough to be used elsewhere in search.

The burden is on the creation of the book to provide more diversity to the openings and cover some corner cases, which is another area of research.

No functional changes without a book.

My study have shown that it does no harm to use an opening book instead of a search, while the latter being largely deterministic.

This is a primitive version, using a PolyGlot-like book format but with our own Zobrist hash keys, so the probing might be cheap enough to be used elsewhere in search.

The burden is on the creation of the book to provide more diversity to the openings and cover some corner cases, which is another area of research.

No functional changes without a book.
swap_endian(v);
return v;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to move that ? I thought that other engines used that probing code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving endianness conversion utilities to misc.h since they are also used in book.c.

@joergoster
Copy link
Contributor

Please not.
SF had book support integrated a (long) while ago. It had been dropped for good reasons.
See also f4dcec0

@noobpwnftw
Copy link
Contributor Author

noobpwnftw commented Dec 19, 2018

@joergoster I'm probing the book not only at root, but also during search to prune moves that are not in book. I see it as a search accelerator, also after this many years, a paper recently published on Science doesn't seem to have good knowledge on how to use a book during testing. :)

Currently, the format is not even portable, it is SF's own cheat-sheet, while only move list is used, other fields are there just for alignments and possible future improvements.

@Hanamuke
Copy link

Can a search that uses the book be stronger that when moves are fed by the GUI? If yes doesn't that just mean that the book is not very good? Also, for engine testing, the book is often used to force the engine to play suboptimal moves

@noobpwnftw
Copy link
Contributor Author

Book-accelerated searches can be a lot faster, they have their candidate moves narrowed down by the book. We can build such books on better hardware and/or with unlimited time, then in daily use the book provide sufficient information to "reproduce" what was found during the creation of the book.

With this perspective, and since the book cannot be perfect in every possible line, there are cases it may be weaker than local searches, so it is better to make use of the information from the book.
For example: some book record can have a "depth" field, when SF is running on a laptop, that may be the best data it can rely on, but when SF is running on some decent hardware, it may not be that useful.

@vondele
Copy link
Member

vondele commented Dec 19, 2018

somewhat of a naive question. An opening book used in search, and with depth info etc. sounds a lot like the current transposition table. How different would be your plan from loading a precomputed TT ? Possibly some recipe is needed to compute this TT (zeroth order approx. a long search from the rootPos).

@MichaelB7
Copy link
Contributor

Removing the old book code, although well intentioned, the removal author was only contemplating SF being used under what I would call engine tournament conditions where the book is purposely control by the GUI for both engines. It totally ignored the usage by private individual who is solely using SF for training (player training not engine) purposes where having the use of multiple books is is a feature, where one book (GUI) guides the initial play and a second, wider book ( engine) takes over once the first book is out of book. In some respects, removing the book code seems to be more in line with a vision statement that espouses to build the strongest engine possible while leaving open the possibility for individual users to modify the open source to use SF as they see fit. Bottom line , I would support it being added back to the code, but I can also appreciate why it was removed in the first place. I like the fact that you are presenting an opportunity for SF to play better in engine tournaments - as we can all see the concept ( book or no book) is getting blurred with MCTS and A0 type chess engines, what’s the real practical difference of having an engine book or engine that has millions of positions analyzed prior to a match ? With the hardware at our disposal , there is no doubt in my mind, we could build the strongest engine book ever - Cerebellum on steroids if you will - but that’s a direction that the maintainers would have to buy into. I hope they do.

@noobpwnftw
Copy link
Contributor Author

noobpwnftw commented Dec 19, 2018

@vondele
It would make more sense if "book" is renamed to "precomputed TT".
One could save all TT entries having depth > X from rootPos and later use it straightforward, which almost what's happening here.

My point is that, it does not make much sense to launch local searches from rootPos every time, then, no point to launch local searches from rootPos+1, ... up to a point that local searches become the more efficient way to solve the problem.

Data mining and the engine are two different paths, yet they both have some shortcomings if not closely integrated with each other.

@mcostalba
Copy link

This is more a "study" than a patch to be committed (of course).

This project may be interesting to someone, but I'd suggest for clarity to not advertise it as a PR. This could only lead to misunderstandings.

@mcostalba
Copy link

Indeed I am not sure the official SF repo is the right place for this derived project, even as a side branch, like teh cluster one. I'd suggest to keep it in your repo and grow it (build a book, test, verify (i.e. measure) you have an advantage, etc..) there.

@noobpwnftw
Copy link
Contributor Author

How to create a book is a derived project, having the ability to probe books is not.

If your goal is to create a minimalist chess engine at all cost, then I see plenty of code can be removed and resort to crippled alternatives provided by the GUI.

A PR page here to advertise anything sounds like a horrible idea to me, and to show an advantage I could just run it unchanged.

@mcostalba
Copy link

@noobpwnftw please could you list which functions in SF could be removed and deferred to "crippled" alternatives provided by a GUI? I am a bit curious because I fail to see any.

@Atahan-Turkoglu
Copy link

The main difference between the two maintainers: M.Costalba is dour like a boss and S.Nicolet is smiling like a director of human resources... This is the reason for S.Nicolet's great success.

@vondele
Copy link
Member

vondele commented Dec 19, 2018

I never like when discussions in PRs get off-topic like this.

@nickolasreynolds
Copy link

noobpwnftw's book support seems interesting to me. There is of course the tending-toward-minimalist philosophy that led to book support being removed in the past, but things are somewhat different now, I think. There are contributors and resources that allow the Stockfish project to go in directions that weren't possible or practical before.

vondele and noob are step-by-step breathing life into the cluster branch, noob is working on his book project, and -- taken together -- perhaps in the not-too-distant future it will be possible to assemble the strongest chess playing entity in history for some nefarious purpose.

It seems like some harmless fun, I'm not sure why we wouldn't want to formally embrace it.

@noobpwnftw noobpwnftw closed this Dec 20, 2018
@vondele
Copy link
Member

vondele commented Dec 20, 2018

@noobpwnftw I really hope that this discussion here didn't make you quit the project in anger.

@noobpwnftw
Copy link
Contributor Author

@vondele
There have never been much of a discussion, it may be too complicated to have one.

But it's all cool, I just didn't feel the need to announce it everywhere when I need to do some maintenance work(OS upgrades, etc) before holiday arrives, during which I might find nobody around to fix up things in case of something go south.

@vondele
Copy link
Member

vondele commented Dec 20, 2018

@noobpwnftw agreed, good to hear you're still on board!

@mcostalba
Copy link

@atahan I am happy for you that you don't seem to have an idea what a real ugly boss is :-). Good for you!

Actually I am not boss of anything, I have just written my opinion in a clear but hopefully respectful and educated way. I am sorry for the reaction, it wasn't my intention to provoke. But I'd assume that if someone posts 300 lines of new code without any kind of quantitative support apart from his good will, I would expect that he is at least ready to answer few questions, and "why we should commit this?" seems to me a legitimate question.

Anyhow I am happy he stays and keep giving his important contribution to the project

@31m059
Copy link

31m059 commented Dec 20, 2018

I like the fact that you are presenting an opportunity for SF to play better in engine tournaments - as we can all see the concept ( book or no book) is getting blurred with MCTS and A0 type chess engines, what’s the real practical difference of having an engine book or engine that has millions of positions analyzed prior to a match ? With the hardware at our disposal , there is no doubt in my mind, we could build the strongest engine book ever - Cerebellum on steroids if you will - but that’s a direction that the maintainers would have to buy into. I hope they do.

I agree with everything @MichaelB7 said but want to especially highlight this. The state of play of engine chess has changed dramatically in recent years. While I'm aware of the algorithmic differences, I have some doubts whether the difference between playing millions of games against yourself and storing the positions on the one hand, and playing millions of games against yourself and black-box "learning" from them on the other, is a principled or sound one...it seems that AB engines may be accepting an unnecessary and ad-hoc handicap.

I think this is an intriguing and natural extension of SF that integrates quite nicely into the larger goals of the project. It seems quite natural to make it a side branch like cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants