Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AZULSimu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiaofei Wang
AZULSimu
Commits
5c1a5c92
Commit
5c1a5c92
authored
5 years ago
by
Xiaofei Wang
Browse files
Options
Downloads
Patches
Plain Diff
上传新文件
parent
61ed4534
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
AZUL/run.py
+96
-0
96 additions, 0 deletions
AZUL/run.py
with
96 additions
and
0 deletions
AZUL/run.py
0 → 100644
+
96
−
0
View file @
5c1a5c92
# 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 {}%.
\n
player {}
'
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment