Spaces:
Sleeping
Sleeping
AttackingOrDefending commited on
Commit ·
522f652
1
Parent(s): 6a55b6d
Print stats (#11)
Browse filesSupport ‘!eval’ command in game chat.
- conversation.py +1 -1
- engine_ctrl.py +2 -1
- engine_wrapper.py +20 -15
conversation.py
CHANGED
|
@@ -20,7 +20,7 @@ class Conversation:
|
|
| 20 |
|
| 21 |
def command(self, line, game, cmd):
|
| 22 |
if cmd == "commands" or cmd == "help":
|
| 23 |
-
self.send_reply(line, "Supported commands: !name, !wait (only applicable at the start of the game), !howto, !queue")
|
| 24 |
elif cmd == "wait" and game.is_abortable():
|
| 25 |
game.ping(60, 120)
|
| 26 |
self.send_reply(line, "Waiting 60 seconds...")
|
|
|
|
| 20 |
|
| 21 |
def command(self, line, game, cmd):
|
| 22 |
if cmd == "commands" or cmd == "help":
|
| 23 |
+
self.send_reply(line, "Supported commands: !eval, !name, !wait (only applicable at the start of the game), !howto, !queue")
|
| 24 |
elif cmd == "wait" and game.is_abortable():
|
| 25 |
game.ping(60, 120)
|
| 26 |
self.send_reply(line, "Waiting 60 seconds...")
|
engine_ctrl.py
CHANGED
|
@@ -215,5 +215,6 @@ class Engine:
|
|
| 215 |
info["score"]["lowerbound"] = lowerbound
|
| 216 |
if upperbound:
|
| 217 |
info["score"]["upperbound"] = upperbound
|
|
|
|
| 218 |
else:
|
| 219 |
-
logger.error("Unexpected engine response to go: %s %s" % (command, arg))
|
|
|
|
| 215 |
info["score"]["lowerbound"] = lowerbound
|
| 216 |
if upperbound:
|
| 217 |
info["score"]["upperbound"] = upperbound
|
| 218 |
+
self.info = info
|
| 219 |
else:
|
| 220 |
+
logger.error("Unexpected engine response to go: %s %s" % (command, arg))
|
engine_wrapper.py
CHANGED
|
@@ -54,18 +54,11 @@ class EngineWrapper:
|
|
| 54 |
def quit(self):
|
| 55 |
self.engine.kill_process()
|
| 56 |
|
| 57 |
-
def print_handler_stats(self
|
| 58 |
-
|
| 59 |
-
if stat in info:
|
| 60 |
-
logger.info("{}: {}".format(stat, info[stat]))
|
| 61 |
-
|
| 62 |
-
def get_handler_stats(self, info, stats):
|
| 63 |
-
stats_str = []
|
| 64 |
-
for stat in stats:
|
| 65 |
-
if stat in info:
|
| 66 |
-
stats_str.append("{}: {}".format(stat, info[stat]))
|
| 67 |
|
| 68 |
-
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
class USIEngine(EngineWrapper):
|
|
@@ -129,11 +122,23 @@ class USIEngine(EngineWrapper):
|
|
| 129 |
def stop(self):
|
| 130 |
self.engine.kill_process()
|
| 131 |
|
| 132 |
-
def print_stats(self):
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
def get_stats(self):
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
def get_opponent_info(self, game):
|
| 139 |
name = game.opponent.name
|
|
|
|
| 54 |
def quit(self):
|
| 55 |
self.engine.kill_process()
|
| 56 |
|
| 57 |
+
def print_handler_stats(self):
|
| 58 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
def get_handler_stats(self):
|
| 61 |
+
pass
|
| 62 |
|
| 63 |
|
| 64 |
class USIEngine(EngineWrapper):
|
|
|
|
| 122 |
def stop(self):
|
| 123 |
self.engine.kill_process()
|
| 124 |
|
| 125 |
+
def print_stats(self, stats=None):
|
| 126 |
+
if stats is None:
|
| 127 |
+
stats = ['score', 'depth', 'nodes', 'nps']
|
| 128 |
+
info = self.engine.info
|
| 129 |
+
for stat in stats:
|
| 130 |
+
if stat in info:
|
| 131 |
+
logger.info("{}: {}".format(stat, info[stat]))
|
| 132 |
|
| 133 |
+
def get_stats(self, stats=None):
|
| 134 |
+
if stats is None:
|
| 135 |
+
stats = ['score', 'depth', 'nodes', 'nps']
|
| 136 |
+
info = self.engine.info
|
| 137 |
+
stats_str = []
|
| 138 |
+
for stat in stats:
|
| 139 |
+
if stat in info:
|
| 140 |
+
stats_str.append("{}: {}".format(stat, info[stat]))
|
| 141 |
+
return stats_str
|
| 142 |
|
| 143 |
def get_opponent_info(self, game):
|
| 144 |
name = game.opponent.name
|