Spaces:
Sleeping
Sleeping
TheYoBots commited on
Commit ·
bf1dd0a
1
Parent(s): ec1110a
Bump to v0.4.1
Browse files3 new additions
- Feature to accept challenges only from bots and not humans
- Fix 'Board state update'
- Replace search engine loop with simpler condition
- config.yml +1 -0
- conversation.py +1 -1
- lishogi-bot.py +4 -9
- model.py +2 -0
config.yml
CHANGED
|
@@ -27,6 +27,7 @@ challenge: # incoming challenges
|
|
| 27 |
concurrency: 100 # number of games to play simultaneously
|
| 28 |
sort_by: "best" # possible values: "best", "first"
|
| 29 |
accept_bot: true # accepts challenges coming from other bots
|
|
|
|
| 30 |
max_increment: 180 # maximum amount of increment to accaept a challenge. the max is 180. set to 0 for no increment
|
| 31 |
min_increment: 0 # minimum amount of increment to accept a challenge
|
| 32 |
variants: # shogi variants to accept
|
|
|
|
| 27 |
concurrency: 100 # number of games to play simultaneously
|
| 28 |
sort_by: "best" # possible values: "best", "first"
|
| 29 |
accept_bot: true # accepts challenges coming from other bots
|
| 30 |
+
only_bot: false # Enable this to accept challenges only from bots
|
| 31 |
max_increment: 180 # maximum amount of increment to accaept a challenge. the max is 180. set to 0 for no increment
|
| 32 |
min_increment: 0 # minimum amount of increment to accept a challenge
|
| 33 |
variants: # shogi variants to accept
|
conversation.py
CHANGED
|
@@ -20,7 +20,7 @@ class Conversation:
|
|
| 20 |
game.ping(60, 120)
|
| 21 |
self.send_reply(line, "Waiting 60 seconds...")
|
| 22 |
elif cmd == "name":
|
| 23 |
-
self.send_reply(line, "lishogi-bot v0.
|
| 24 |
elif cmd == "engine":
|
| 25 |
self.send_reply(line, "Fairy Stockfish 11.2")
|
| 26 |
elif cmd == "howto":
|
|
|
|
| 20 |
game.ping(60, 120)
|
| 21 |
self.send_reply(line, "Waiting 60 seconds...")
|
| 22 |
elif cmd == "name":
|
| 23 |
+
self.send_reply(line, "lishogi-bot v0.4.1")
|
| 24 |
elif cmd == "engine":
|
| 25 |
self.send_reply(line, "Fairy Stockfish 11.2")
|
| 26 |
elif cmd == "howto":
|
lishogi-bot.py
CHANGED
|
@@ -30,7 +30,7 @@ try:
|
|
| 30 |
except ImportError:
|
| 31 |
from http.client import BadStatusLine as RemoteDisconnected
|
| 32 |
|
| 33 |
-
__version__ = "0.
|
| 34 |
|
| 35 |
terminated = False
|
| 36 |
|
|
@@ -206,7 +206,8 @@ def play_game(li, game_id, control_queue, engine_factory, user_profile, config,
|
|
| 206 |
elif u_type == "gameState":
|
| 207 |
game.state = upd
|
| 208 |
moves = upd["moves"].split()
|
| 209 |
-
|
|
|
|
| 210 |
if not is_game_over(game) and is_engine_move(game, moves):
|
| 211 |
if config.get("fake_think_time") and len(moves) > 9:
|
| 212 |
delay = min(game.clock_initial, game.my_remaining_seconds()) * 0.015
|
|
@@ -257,13 +258,7 @@ def play_game(li, game_id, control_queue, engine_factory, user_profile, config,
|
|
| 257 |
li.abort(game.id)
|
| 258 |
break
|
| 259 |
except (HTTPError, ReadTimeout, RemoteDisconnected, ChunkedEncodingError, ConnectionError, ProtocolError) as e:
|
| 260 |
-
|
| 261 |
-
game_over = True
|
| 262 |
-
for ongoing_game in ongoing_games:
|
| 263 |
-
if ongoing_game["gameId"] == game.id:
|
| 264 |
-
game_over = False
|
| 265 |
-
break
|
| 266 |
-
if not game_over:
|
| 267 |
continue
|
| 268 |
else:
|
| 269 |
break
|
|
|
|
| 30 |
except ImportError:
|
| 31 |
from http.client import BadStatusLine as RemoteDisconnected
|
| 32 |
|
| 33 |
+
__version__ = "0.4.1"
|
| 34 |
|
| 35 |
terminated = False
|
| 36 |
|
|
|
|
| 206 |
elif u_type == "gameState":
|
| 207 |
game.state = upd
|
| 208 |
moves = upd["moves"].split()
|
| 209 |
+
if len(moves) > 0 and len(moves) != len(board.move_stack):
|
| 210 |
+
board = update_board(board, moves[-1])
|
| 211 |
if not is_game_over(game) and is_engine_move(game, moves):
|
| 212 |
if config.get("fake_think_time") and len(moves) > 9:
|
| 213 |
delay = min(game.clock_initial, game.my_remaining_seconds()) * 0.015
|
|
|
|
| 258 |
li.abort(game.id)
|
| 259 |
break
|
| 260 |
except (HTTPError, ReadTimeout, RemoteDisconnected, ChunkedEncodingError, ConnectionError, ProtocolError) as e:
|
| 261 |
+
if game.id in (ongoing_game["gameId"] for ongoing_game in li.get_ongoing_games()):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
continue
|
| 263 |
else:
|
| 264 |
break
|
model.py
CHANGED
|
@@ -33,6 +33,8 @@ class Challenge():
|
|
| 33 |
def is_supported(self, config):
|
| 34 |
if not config.get("accept_bot", False) and self.challenger_is_bot:
|
| 35 |
return False
|
|
|
|
|
|
|
| 36 |
variants = config["variants"]
|
| 37 |
tc = config["time_controls"]
|
| 38 |
inc_max = config.get("max_increment", 180)
|
|
|
|
| 33 |
def is_supported(self, config):
|
| 34 |
if not config.get("accept_bot", False) and self.challenger_is_bot:
|
| 35 |
return False
|
| 36 |
+
if config.get("only_bot", False) and ( not self.challenger_is_bot ):
|
| 37 |
+
return False
|
| 38 |
variants = config["variants"]
|
| 39 |
tc = config["time_controls"]
|
| 40 |
inc_max = config.get("max_increment", 180)
|