lichess-bot-devs/lichess-bot

Nooby question - specifically, what changes are needed in enginewrapper.py to get an homemade engine connected?

vibranium21 opened this issue · 19 comments

Nooby question - specifically, what changes are needed in enginewrapper.py to get an homemade engine connected?

Also, I seem to be having import could not be resolved issues?

You shouldn't change anything in engine_wrapper.py. You should only change strategies.py. Can you send your custom code that you have in strategies.py or engine_wrapper.py?

Wow, I thought you were supposed to edit in enginewrapper. What should I add in strategies.py for a simple python engine? What would you recommend for the import not resolved?

You should change the search function. There are many example engines like RandomMove. Change engine_wrapper.py to the default one and add your code to strategies.py. Then if you still have the problem send your code in strategies.py, so I can see what causes the error. Also, can you run lichess-bot with python lichess-bot.py -v -l log.txt and upload the log?

def search(self, board: chess.Board):
player_color = board.side_to_move
best_move = Minimax_Get_Move(board, 4, player_color, -20000, math.inf )
return best_move
Is this all I need?

Yes, just change player_color = board.side_to_move to player_color = board.turn and put the code inside a class.

[06/09/23 13:37:33] INFO Backing off play_game(...) for 0.4s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)
INFO Backing off play_game(...) for 0.7s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)
[06/09/23 13:37:35] INFO Backing off play_game(...) for 3.5s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)
[06/09/23 13:37:38] INFO Backing off play_game(...) for 7.9s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)
[06/09/23 13:37:47] INFO Backing off play_game(...) for 3.5s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)
[06/09/23 13:37:51] INFO Backing off play_game(...) for 7.8s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)
[06/09/23 13:37:59] INFO Backing off play_game(...) for 55.7s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application)

Have you seen this problem before?

Have you put protocol: "homemade" and name: "YOUR CLASS NAME" in config.yml? Can you send your logs from the start of lichess-bot when run with -v?

I did not have name as class name, that could possibly be the issue. But the engine uses uci.

If your engine isn't an executable and is connected to lichess-bot through strategies.py then the protocol is "homemade".

I switched it to homemade but I am still getting the INFO Backing off play_game(...) for 88.7s (OSError: [WinError 193] %1 is not a _common.py:105
valid Win32 application) error

Run lichess-bot with python lichess-bot.py -v -l log.txt. When you get the error close lichess-bot and upload log.txt, so I can look into it.

In strategies.py add:

from movegeneration import Minimax_Get_Move

class Engine(ExampleEngine):
    def search(self, board: chess.Board, *args: Any) -> PlayResult:
        player_color = board.turn
        best_move = Minimax_Get_Move(board, 4, player_color, -20000, math.inf )
        return best_move

Then in config.yml change:
name: movegeneration.py to name: Engine

What about the engines directory?

Nothing will happen if you change it, so there is no reason to.

https://github.com/AttackingOrDefending/lichess-bot/tree/vibranium
I fixed all the errors. Download it, rename config.yml.default to config.yml, add your token and it should be working.

tysm for doing this and putting up with my lack of lichess-bot experience