Spaces:
Running
Running
newest
Browse files- pages/Player_VS_AI.py +13 -11
pages/Player_VS_AI.py
CHANGED
@@ -42,16 +42,16 @@ from const import (
|
|
42 |
_MODEL_PATH
|
43 |
)
|
44 |
|
45 |
-
'''
|
46 |
-
from ai import (
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
)
|
51 |
-
|
52 |
-
gpt2 = load_model()
|
53 |
-
|
54 |
-
'''
|
55 |
|
56 |
|
57 |
# Utils
|
@@ -415,6 +415,7 @@ def gomoku():
|
|
415 |
top_five_acts = [act for act, prob in sorted_acts_probs[:5]]
|
416 |
top_five_probs = [prob for act, prob in sorted_acts_probs[:5]]
|
417 |
if response and session_state.ROOM.TURN == _BLACK: # human turn
|
|
|
418 |
print("Your turn")
|
419 |
# construction of clickable buttons
|
420 |
cur_move = (session_state.ROOM.current_move // _BOARD_SIZE, session_state.ROOM.current_move % _BOARD_SIZE)
|
@@ -458,7 +459,8 @@ def gomoku():
|
|
458 |
on_click=handle_click,
|
459 |
args=(i, j),
|
460 |
)
|
461 |
-
|
|
|
462 |
|
463 |
elif response and session_state.ROOM.TURN == _WHITE: # AI turn
|
464 |
message.empty()
|
|
|
42 |
_MODEL_PATH
|
43 |
)
|
44 |
|
45 |
+
# '''
|
46 |
+
# from ai import (
|
47 |
+
# BOS_TOKEN_ID,
|
48 |
+
# generate_gpt2,
|
49 |
+
# load_model,
|
50 |
+
# )
|
51 |
+
#
|
52 |
+
# gpt2 = load_model()
|
53 |
+
#
|
54 |
+
# '''
|
55 |
|
56 |
|
57 |
# Utils
|
|
|
415 |
top_five_acts = [act for act, prob in sorted_acts_probs[:5]]
|
416 |
top_five_probs = [prob for act, prob in sorted_acts_probs[:5]]
|
417 |
if response and session_state.ROOM.TURN == _BLACK: # human turn
|
418 |
+
start_time = time.time()
|
419 |
print("Your turn")
|
420 |
# construction of clickable buttons
|
421 |
cur_move = (session_state.ROOM.current_move // _BOARD_SIZE, session_state.ROOM.current_move % _BOARD_SIZE)
|
|
|
459 |
on_click=handle_click,
|
460 |
args=(i, j),
|
461 |
)
|
462 |
+
end_time = time.time()
|
463 |
+
print("Time used for human move: ", end_time - start_time)
|
464 |
|
465 |
elif response and session_state.ROOM.TURN == _WHITE: # AI turn
|
466 |
message.empty()
|