HaileyStorm
commited on
Commit
•
b086bf5
1
Parent(s):
3d56e39
Update chess-gpt-eval/main.py
Browse files- chess-gpt-eval/main.py +17 -5
chess-gpt-eval/main.py
CHANGED
@@ -179,6 +179,7 @@ def record_results(
|
|
179 |
player_two: Player,
|
180 |
game_state: str,
|
181 |
player_one_illegal_moves: int,
|
|
|
182 |
player_two_illegal_moves: int,
|
183 |
player_one_legal_moves: int,
|
184 |
player_two_legal_moves: int,
|
@@ -189,6 +190,7 @@ def record_results(
|
|
189 |
player_two_failed_to_find_legal_move: bool,
|
190 |
total_moves: int,
|
191 |
illegal_moves: int,
|
|
|
192 |
):
|
193 |
unique_game_id = generate_unique_game_id()
|
194 |
|
@@ -222,6 +224,7 @@ def record_results(
|
|
222 |
player_one_score = -1e10
|
223 |
player_two_score = -1e10
|
224 |
|
|
|
225 |
info_dict = {
|
226 |
"game_id": unique_game_id,
|
227 |
"transcript": game_state,
|
@@ -242,6 +245,10 @@ def record_results(
|
|
242 |
"player_two_failed_to_find_legal_move": player_two_failed_to_find_legal_move,
|
243 |
"game_title": f"{player_one_title} vs. {player_two_title}",
|
244 |
"number_of_moves": board.fullmove_number,
|
|
|
|
|
|
|
|
|
245 |
"time_taken": total_time,
|
246 |
"total_moves": total_moves,
|
247 |
"illegal_moves": illegal_moves,
|
@@ -428,9 +435,11 @@ def play_game(
|
|
428 |
board = chess.Board()
|
429 |
|
430 |
if random_opening_seed:
|
431 |
-
game_state, board = initialize_game_with_opening(game_state, board)
|
432 |
-
|
|
|
433 |
player_one_illegal_moves = 0
|
|
|
434 |
player_two_illegal_moves = 0
|
435 |
player_one_legal_moves = 0
|
436 |
player_two_legal_moves = 0
|
@@ -469,7 +478,8 @@ def play_game(
|
|
469 |
player_one_failed_to_find_legal_move,
|
470 |
illegal_moves_one,
|
471 |
) = play_turn(player_one, board, game_state, player_one=True)
|
472 |
-
player_one_illegal_moves
|
|
|
473 |
if illegal_moves_one != 0:
|
474 |
player_one_legal_moves -= 1
|
475 |
if (
|
@@ -485,7 +495,7 @@ def play_game(
|
|
485 |
player_two_failed_to_find_legal_move,
|
486 |
illegal_moves_two,
|
487 |
) = play_turn(player_two, board, game_state, player_one=False)
|
488 |
-
player_two_illegal_moves
|
489 |
if illegal_moves_two != 0:
|
490 |
player_two_legal_moves -= 1
|
491 |
if (
|
@@ -512,6 +522,7 @@ def play_game(
|
|
512 |
player_two,
|
513 |
game_state,
|
514 |
player_one_illegal_moves,
|
|
|
515 |
player_two_illegal_moves,
|
516 |
player_one_legal_moves,
|
517 |
player_two_legal_moves,
|
@@ -522,6 +533,7 @@ def play_game(
|
|
522 |
player_two_failed_to_find_legal_move,
|
523 |
total_moves,
|
524 |
illegal_moves,
|
|
|
525 |
)
|
526 |
if isinstance(player_one, StockfishPlayer):
|
527 |
player_one.close()
|
@@ -542,7 +554,7 @@ move_num_in_gamestate = False
|
|
542 |
if __name__ == "__main__":
|
543 |
for nanogpt_player in player_ones:
|
544 |
for i in range(1): #range(11):
|
545 |
-
num_games =
|
546 |
# player_one = GPTPlayer(model="gpt-3.5-turbo-instruct")
|
547 |
# player_one = LocalLlamaPlayer(model_name="meta-llama/Llama-2-7b-hf")
|
548 |
# player_one = LocalLoraLlamaPlayer("meta-llama/Llama-2-7b-hf", "/workspace/axolotl/lora2-out")
|
|
|
179 |
player_two: Player,
|
180 |
game_state: str,
|
181 |
player_one_illegal_moves: int,
|
182 |
+
player_one_illegal_attempts: int,
|
183 |
player_two_illegal_moves: int,
|
184 |
player_one_legal_moves: int,
|
185 |
player_two_legal_moves: int,
|
|
|
190 |
player_two_failed_to_find_legal_move: bool,
|
191 |
total_moves: int,
|
192 |
illegal_moves: int,
|
193 |
+
opening_moves: int
|
194 |
):
|
195 |
unique_game_id = generate_unique_game_id()
|
196 |
|
|
|
224 |
player_one_score = -1e10
|
225 |
player_two_score = -1e10
|
226 |
|
227 |
+
played_moves = player_one_illegal_moves + player_one_legal_moves
|
228 |
info_dict = {
|
229 |
"game_id": unique_game_id,
|
230 |
"transcript": game_state,
|
|
|
245 |
"player_two_failed_to_find_legal_move": player_two_failed_to_find_legal_move,
|
246 |
"game_title": f"{player_one_title} vs. {player_two_title}",
|
247 |
"number_of_moves": board.fullmove_number,
|
248 |
+
"p1_illegal_attempts": player_one_illegal_attempts,
|
249 |
+
"p1_avg_attempts_per_illegal": 0 if player_one_illegal_moves == 0 else player_one_illegal_attempts / float(player_one_illegal_moves),
|
250 |
+
"p1_illegal_attemtps_pct": 1.0 if played_moves == 0 else player_one_illegal_attempts / float(player_one_illegal_attempts + player_one_legal_moves),
|
251 |
+
"p1_illegal_moves_pct": 1.0 if played_moves == 0 else player_one_illegal_moves / float(played_moves),
|
252 |
"time_taken": total_time,
|
253 |
"total_moves": total_moves,
|
254 |
"illegal_moves": illegal_moves,
|
|
|
435 |
board = chess.Board()
|
436 |
|
437 |
if random_opening_seed:
|
438 |
+
game_state, board, opening_moves = initialize_game_with_opening(game_state, board)
|
439 |
+
else:
|
440 |
+
opening_moves = 0
|
441 |
player_one_illegal_moves = 0
|
442 |
+
player_one_illegal_attempts = 0
|
443 |
player_two_illegal_moves = 0
|
444 |
player_one_legal_moves = 0
|
445 |
player_two_legal_moves = 0
|
|
|
478 |
player_one_failed_to_find_legal_move,
|
479 |
illegal_moves_one,
|
480 |
) = play_turn(player_one, board, game_state, player_one=True)
|
481 |
+
player_one_illegal_moves += 1 if illegal_moves_one > 0 else 0
|
482 |
+
player_one_illegal_attempts += illegal_moves_one
|
483 |
if illegal_moves_one != 0:
|
484 |
player_one_legal_moves -= 1
|
485 |
if (
|
|
|
495 |
player_two_failed_to_find_legal_move,
|
496 |
illegal_moves_two,
|
497 |
) = play_turn(player_two, board, game_state, player_one=False)
|
498 |
+
player_two_illegal_moves += 1 if illegal_moves_two > 0 else 0
|
499 |
if illegal_moves_two != 0:
|
500 |
player_two_legal_moves -= 1
|
501 |
if (
|
|
|
522 |
player_two,
|
523 |
game_state,
|
524 |
player_one_illegal_moves,
|
525 |
+
player_one_illegal_attempts,
|
526 |
player_two_illegal_moves,
|
527 |
player_one_legal_moves,
|
528 |
player_two_legal_moves,
|
|
|
533 |
player_two_failed_to_find_legal_move,
|
534 |
total_moves,
|
535 |
illegal_moves,
|
536 |
+
opening_moves
|
537 |
)
|
538 |
if isinstance(player_one, StockfishPlayer):
|
539 |
player_one.close()
|
|
|
554 |
if __name__ == "__main__":
|
555 |
for nanogpt_player in player_ones:
|
556 |
for i in range(1): #range(11):
|
557 |
+
num_games = 312 #265 #265 instead of 250 for duplicates (for lc0, stockfish doesn't need it)
|
558 |
# player_one = GPTPlayer(model="gpt-3.5-turbo-instruct")
|
559 |
# player_one = LocalLlamaPlayer(model_name="meta-llama/Llama-2-7b-hf")
|
560 |
# player_one = LocalLoraLlamaPlayer("meta-llama/Llama-2-7b-hf", "/workspace/axolotl/lora2-out")
|