lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
772 stars 449 forks source link

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

Closed vibranium21 closed 1 year ago

vibranium21 commented 1 year ago

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

AttackingOrDefending commented 1 year ago

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?

vibranium21 commented 1 year ago

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?

AttackingOrDefending commented 1 year ago

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?

vibranium21 commented 1 year ago

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?

AttackingOrDefending commented 1 year ago

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

vibranium21 commented 1 year ago

[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)

vibranium21 commented 1 year ago

Have you seen this problem before?

AttackingOrDefending commented 1 year ago

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?

vibranium21 commented 1 year ago

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

AttackingOrDefending commented 1 year ago

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

vibranium21 commented 1 year ago

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

AttackingOrDefending commented 1 year ago

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.

vibranium21 commented 1 year ago

log.txt

AttackingOrDefending commented 1 year ago

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

vibranium21 commented 1 year ago

What about the engines directory?

AttackingOrDefending commented 1 year ago

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

AttackingOrDefending commented 1 year ago

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.

vibranium21 commented 1 year ago

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