Skip to content

Commit

Permalink
Send bots information about their opponents
Browse files Browse the repository at this point in the history
MarkZH committed Feb 13, 2020
1 parent 72d5eb1 commit 7b481f6
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions engine_wrapper.py
Original file line number Diff line number Diff line change
@@ -41,6 +41,9 @@ def search(self, board, wtime, btime, winc, binc):
def print_stats(self):
pass

def opponent_info(self, game):
pass

def name(self):
return self.engine.name

@@ -125,6 +128,12 @@ def print_stats(self):
def get_stats(self):
return self.get_handler_stats(self.engine.info_handlers[0].info, ["depth", "nps", "nodes", "score"])

def opponent_info(self, game):
name = game.opponent.name
rating = game.opponent.rating
title = game.opponent.title if game.opponent.title else "none"
player_type = "computer" if title == "BOT" else "human"
self.engine.setoption({"UCI_Opponent": "{} {} {} {}".format(title, rating, player_type, name)})

class XBoardEngine(EngineWrapper):

@@ -214,3 +223,10 @@ def name(self):
return self.engine.features.get("myname")
except:
return None

def opponent_info(self, game):
title = game.opponent.title + " " if game.opponent.title else ""
self.engine.opponent_name(title + game.opponent.name)
self.engine.rating(game.me.rating, game.opponent.rating)
if game.opponent.title == "BOT":
self.engine.computer()
1 change: 1 addition & 0 deletions lichess-bot.py
Original file line number Diff line number Diff line change
@@ -136,6 +136,7 @@ def play_game(li, game_id, control_queue, engine_factory, user_profile, config,
game = model.Game(initial_state, user_profile["username"], li.baseUrl, config.get("abort_time", 20))
board = setup_board(game)
engine = engine_factory(board)
engine.opponent_info(game)
conversation = Conversation(game, engine, li, __version__, challenge_queue)

logger.info("+++ {}".format(game))

0 comments on commit 7b481f6

Please sign in to comment.