- Blind mode tutorial
lichess.org
Donate

Tricks to improve bot performance

I encountered a strange phenomenon: if I insist on playing the best book move against players who don't vary their game and the book contains a 3-fold repetition, then all games will end in that 3-fold repetition.

I added a little chance to play an engine move even when a book move is available and this fixed the issue ( this little chance builds up over a sequence of moves, and makes it very unlikely to reach the same 3-fold repetition sequence over and over again ).

It would be nice to have this as an official setting. Nevertheless it is one line of code ( insert it in main.py here : https://github.com/careless25/lichess-bot/commit/b32c7c73ae47f8e072d8febb740575690b009042#diff-5bc02cefb3ea9e27f1a6776eabd1935dR131 ):

if random.randint(0,100) < PLAY_BOOK_MOVE_PROBABILITY:
best_move = get_book_move(board, engine_cfg)

Of course you need to import random in the beginning of main.py ( and define PLAY_BOOK_MOVE_PROBABILITY ):

import random
PLAY_BOOK_MOVE_PROBABILITY = 90

I encountered a strange phenomenon: if I insist on playing the best book move against players who don't vary their game and the book contains a 3-fold repetition, then all games will end in that 3-fold repetition. I added a little chance to play an engine move even when a book move is available and this fixed the issue ( this little chance builds up over a sequence of moves, and makes it very unlikely to reach the same 3-fold repetition sequence over and over again ). It would be nice to have this as an official setting. Nevertheless it is one line of code ( insert it in main.py here : https://github.com/careless25/lichess-bot/commit/b32c7c73ae47f8e072d8febb740575690b009042#diff-5bc02cefb3ea9e27f1a6776eabd1935dR131 ): if random.randint(0,100) < PLAY_BOOK_MOVE_PROBABILITY: best_move = get_book_move(board, engine_cfg) Of course you need to import random in the beginning of main.py ( and define PLAY_BOOK_MOVE_PROBABILITY ): import random PLAY_BOOK_MOVE_PROBABILITY = 90

By now I have a lichess-bot fork, that can do a few things:

https://github.com/lichapibot/lichess-bot

First, it finally integrates my game downloader and book building tool explained here:

https://lichess.org/forum/lichess-feedback/auto-updated-polyglot-book-from-your-games

With my tool I had a dilemma: use the big book or the book built from my own games? The advantage of the big book is that it is detailed, the advantage of my own book is that it is tailored to my actual opponents.

Yes, I could somehow merge books. There are tools for this. But this is another step, another thing to worry about. On top of all this, with a merged book I cannot tell if a move was played from the big book or my own book.

Solution: instead of a single book file, my fork lets you have a list of polyglot books. These books are visited in order. If the position is found in the first book, then fine, the move it is returned. If not, it goes to the next book. This is repeated for the whole list. ( This lets you have a clear preference order as well. )

The move finder function prints which book the move was found in ( this may be useful information ).

You can have the best of all worlds: an intact big book and a personalized, dynamically updated little one.

By now I have a lichess-bot fork, that can do a few things: https://github.com/lichapibot/lichess-bot First, it finally integrates my game downloader and book building tool explained here: https://lichess.org/forum/lichess-feedback/auto-updated-polyglot-book-from-your-games With my tool I had a dilemma: use the big book or the book built from my own games? The advantage of the big book is that it is detailed, the advantage of my own book is that it is tailored to my actual opponents. Yes, I could somehow merge books. There are tools for this. But this is another step, another thing to worry about. On top of all this, with a merged book I cannot tell if a move was played from the big book or my own book. Solution: instead of a single book file, my fork lets you have a list of polyglot books. These books are visited in order. If the position is found in the first book, then fine, the move it is returned. If not, it goes to the next book. This is repeated for the whole list. ( This lets you have a clear preference order as well. ) The move finder function prints which book the move was found in ( this may be useful information ). You can have the best of all worlds: an intact big book and a personalized, dynamically updated little one.

This topic has been archived and can no longer be replied to.