From 5c44cc45ad89fd5ef379891fea2d812a8131854c Mon Sep 17 00:00:00 2001
From: Xiaofei Wang <xiaofei@student.unimelb.edu.au>
Date: Wed, 11 Mar 2020 20:59:37 +1100
Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=B0=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
AZUL/Monitor.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 AZUL/Monitor.py
diff --git a/AZUL/Monitor.py b/AZUL/Monitor.py
new file mode 100644
index 0000000..6c7d4a2
--- /dev/null
+++ b/AZUL/Monitor.py
@@ -0,0 +1,63 @@
+from rewardBasedPlayer import get_max_difference
+
+
+class Monitor:
+ LIST = []
+
+ def __init__(self, move, values, act_id, round_id, brunches, move_len, times, nodes):
+ self.move = move
+ self.values = values
+ self.act_id = act_id
+ self.dv = get_max_difference(values, act_id)
+ self.round_id = round_id
+ self.decrease = False
+ self.move_len = move_len
+ self.times = times
+ self.nodes = nodes
+ #self.search_time = search_time
+ Monitor.LIST.append(self)
+
+ if len(Monitor.LIST) >= 2:
+ last_monitor = Monitor.LIST[-2]
+ if self.round_id == last_monitor.round_id:
+ self.action_id = last_monitor.action_id + 1
+ else:
+ self.action_id = 0
+ self.decrease = self.is_decrease(last_monitor)
+ else:
+ self.action_id = 0
+
+ self.brunches = brunches
+
+ def is_decrease(self, lm):
+ if self.dv < lm.dv-0.1:
+ return True
+ return False
+
+ def __str__(self):
+ # string = 'v:{:4} {:4} dv:{:4} r:{} a:{} b:{:3} {:3} d:{:5}'.format(
+ # string='r:{} a:{} b:{:3} {:3} l:{:2} t:{:4} n:{:4} d:{:5}'.format(
+ # string = 'b:{:3} {:3} l:{:2} t:{:4} n:{:4} d:{:1}'.format(
+ string = ' r:{} a:{} dv:{:5} b:{:3} {:3} l:{:2} t:{:4} n:{:4} d:{:1}'.format(
+ self.round_id,
+ self.action_id,
+ round(self.dv, 1),
+ self.brunches[0],
+ self.brunches[1],
+ self.move_len,
+ self.times,
+ self.nodes,
+ self.decrease
+ )
+ return string
+
+
+def MonitorsToString():
+ string = ''
+ for m in Monitor.LIST:
+ # string += ('\n' if m.action_id == 0 else '') + str(m)+'\t'
+ if m.decrease is True:
+ print("\033[0;31;47m{}\033[0m".format(str(m)))
+ else:
+ print("\033[0;30;47m{}\033[0m".format(str(m)))
+
--
GitLab