Spaces:
Sleeping
Sleeping
sjz
commited on
Commit
•
6d4d507
1
Parent(s):
2f21cdd
fix AI win bug
Browse files
Gomoku_MCTS/__init__.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from .mcts_pure import MCTSPlayer as MCTSpure
|
2 |
from .mcts_alphaZero import MCTSPlayer as alphazero
|
3 |
-
from .dueling_net import PolicyValueNet
|
4 |
-
|
5 |
import numpy as np
|
6 |
|
7 |
|
|
|
1 |
from .mcts_pure import MCTSPlayer as MCTSpure
|
2 |
from .mcts_alphaZero import MCTSPlayer as alphazero
|
3 |
+
# from .dueling_net import PolicyValueNet
|
4 |
+
from .policy_value_net_pytorch import PolicyValueNet
|
5 |
import numpy as np
|
6 |
|
7 |
|
Gomoku_MCTS/__pycache__/__init__.cpython-38.pyc
CHANGED
Binary files a/Gomoku_MCTS/__pycache__/__init__.cpython-38.pyc and b/Gomoku_MCTS/__pycache__/__init__.cpython-38.pyc differ
|
|
pages/Player_VS_AI.py
CHANGED
@@ -332,11 +332,15 @@ def gomoku():
|
|
332 |
# session_state.ROOM.BOARD[gpt_i][gpt_j] = session_state.ROOM.TURN
|
333 |
session_state.ROOM.COORDINATE_1D.append(gpt_i * _BOARD_SIZE + gpt_j)
|
334 |
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
340 |
|
341 |
# construction of clickable buttons
|
342 |
for i, row in enumerate(session_state.ROOM.BOARD.board_map):
|
@@ -354,7 +358,7 @@ def gomoku():
|
|
354 |
on_click=forbid_click
|
355 |
)
|
356 |
else:
|
357 |
-
if session_state.USE_AIAID and i * _BOARD_SIZE + j in top_five_acts:
|
358 |
# enable click for other cells available for human choices
|
359 |
prob = top_five_probs[top_five_acts.index(i * _BOARD_SIZE + j)]
|
360 |
BOARD_PLATE[i][j].button(
|
|
|
332 |
# session_state.ROOM.BOARD[gpt_i][gpt_j] = session_state.ROOM.TURN
|
333 |
session_state.ROOM.COORDINATE_1D.append(gpt_i * _BOARD_SIZE + gpt_j)
|
334 |
|
335 |
+
if not session_state.ROOM.BOARD.game_end()[0]:
|
336 |
+
copy_mcts = deepcopy(session_state.ROOM.MCTS.mcts)
|
337 |
+
_, acts, probs, simul_mean_time = copy_mcts.get_move_probs(session_state.ROOM.BOARD)
|
338 |
+
sorted_acts_probs = sorted(zip(acts, probs), key=lambda x: x[1], reverse=True)
|
339 |
+
top_five_acts = [act for act, prob in sorted_acts_probs[:5]]
|
340 |
+
top_five_probs = [prob for act, prob in sorted_acts_probs[:5]]
|
341 |
+
else:
|
342 |
+
top_five_acts = []
|
343 |
+
top_five_probs = []
|
344 |
|
345 |
# construction of clickable buttons
|
346 |
for i, row in enumerate(session_state.ROOM.BOARD.board_map):
|
|
|
358 |
on_click=forbid_click
|
359 |
)
|
360 |
else:
|
361 |
+
if session_state.USE_AIAID and i * _BOARD_SIZE + j in top_five_acts and not session_state.ROOM.BOARD.game_end()[0]:
|
362 |
# enable click for other cells available for human choices
|
363 |
prob = top_five_probs[top_five_acts.index(i * _BOARD_SIZE + j)]
|
364 |
BOARD_PLATE[i][j].button(
|