From 5c1a5c921a9cf934b75b0c259c2b3d789f8e107c Mon Sep 17 00:00:00 2001
From: Xiaofei Wang <xiaofei@student.unimelb.edu.au>
Date: Wed, 11 Mar 2020 21:00:55 +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/run.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100644 AZUL/run.py

diff --git a/AZUL/run.py b/AZUL/run.py
new file mode 100644
index 0000000..d46b3e0
--- /dev/null
+++ b/AZUL/run.py
@@ -0,0 +1,96 @@
+# Written by Michelle Blom, 2019
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+#
+import random
+import time
+
+
+from model import GameRunner,Player
+
+# from iplayer import InteractivePlayer
+#
+from naive_player import NaivePlayer
+
+from rewardBFSPlayer import BFS_Player
+# from MI_PlayerSimuSave import MI_PlayerSimuSave
+# from MI_PlayerPro import MI_Player
+from newMct import MI_PlayerNew
+from state_monitor import get_special_action, get_search_time
+from randomPlayer import RandomPlayer
+# from simuallMCT import MI_PlayerAll
+
+if __name__ == '__main__':
+
+    ROUND = 10
+    PLAYERS_NUM = 2
+
+    win = [0]*4
+    mark_sum = [0]*4
+    result = []
+
+    #players_name=['MI_Player', 'MI_PlayerSimuSave']
+    players_name=['MI_PlayerNew', 'BFS_Player']
+    #players_name=['BFS_Player', 'NaivePlayer']
+    #players_name=['BFS_Player', 'MI_Player']
+    #players_name=['MI_PlayerNew', 'NaivePlayer']
+    #players_name=['RandomPlayer', 'NaivePlayer']
+    #players_name=['MI_PlayerNew', 'MI_Player']
+    #players_name=['BFS_Player', 'MI_PlayerNew']
+    #players_name=['MI_Player', 'InteractivePlayer']
+    players = [eval(players_name[0])(0), eval(players_name[1])(1)]
+    players_reverse = [eval(players_name[1])(0), eval(players_name[0])(1)]
+    # players.extend([NaivePlayer(i) for i in range(len(players), PLAYERS_NUM)])
+    # players_reverse.extend([NaivePlayer(i) for i in range(len(players), PLAYERS_NUM)])
+
+    SEED = []
+    for i in range(ROUND//2+1):
+        SEED.append(random.randrange(99999))
+    SEED = [27719]
+    print('seeds:', SEED)
+    start = time.time()
+    for i in range(ROUND):
+        print('NEW GAME')
+        #print('seed:', SEED[i//2])
+        ps = players if i%2==0 else players_reverse
+        #gr = GameRunner(ps, SEED[i//2])
+        gr = GameRunner(ps, SEED[0])
+        activity = gr.Run(True)
+
+        resultList = [activity[0][0], activity[1][0]] if i%2==0 else [activity[1][0], activity[0][0]]
+        resultList.extend([activity[i][0] for i in range(len(players), PLAYERS_NUM)])
+
+
+        for j in range(PLAYERS_NUM):
+            print("{} score is {}".format(players_name[j], resultList[j]))
+
+        result.append(resultList)
+        print(result)
+        print('time cost:', time.time()-start)
+        print('games:', i+1)
+        print()
+
+    for n in range(len(result)):
+        for i in range(PLAYERS_NUM):
+            if result[n][i] == max(result[n]):
+                win[i]+=1
+            mark_sum[i]+=result[n][i]
+
+    for i in range(PLAYERS_NUM):
+        print("{} has win {} times for {} times. Winning rate is {}%.\nplayer {}'s average mark:{}".format(
+            players_name[i], win[i], ROUND, round(win[i]/ROUND*100,2), i+1, mark_sum[i]/ROUND
+        ))
+
+    print(get_special_action())
+    print(get_search_time())
\ No newline at end of file
-- 
GitLab