HaileyStorm commited on
Commit
5dcd8bc
1 Parent(s): 161498a

Update chess-gpt-eval/mainvs.py

Browse files
Files changed (1) hide show
  1. chess-gpt-eval/mainvs.py +14 -10
chess-gpt-eval/mainvs.py CHANGED
@@ -501,8 +501,10 @@ def play_games(
501
  while games_saved < max_games:
502
  print(f"\nGame {games_saved} of {max_games}\n")
503
 
504
- with open("gpt_inputs/prompt.txt", "r") as f:
505
- game_state = f.read()
 
 
506
  board = chess.Board()
507
 
508
  if book_opening:
@@ -538,7 +540,6 @@ def play_games(
538
 
539
  with open("game.txt", "w") as f:
540
  f.write(game_state)
541
- current_move_num = f"{board.fullmove_number if move_num_in_gamestate else ''}."
542
  total_moves += 1
543
  # I increment legal moves here so player_two isn't penalized for the game ending before its turn
544
  player_one_legal_moves += 1
@@ -546,8 +547,10 @@ def play_games(
546
 
547
  # this if statement may be overkill, just trying to get format to exactly match PGN notation
548
  if board.fullmove_number != 1:
549
- game_state += " "
550
- game_state += current_move_num
 
 
551
  #print(f"|{game_state}|")
552
  #print(f"{current_move_num}", end=" ")
553
 
@@ -556,7 +559,7 @@ def play_games(
556
  player_one_resignation,
557
  player_one_failed_to_find_legal_move,
558
  illegal_moves_one,
559
- ) = play_turn(player_one, board, game_state, player_one=True)
560
  player_one_illegal_moves += 1 if illegal_moves_one > 0 else 0
561
  player_one_illegal_attempts += illegal_moves_one
562
  if illegal_moves_one != 0:
@@ -574,7 +577,7 @@ def play_games(
574
  player_two_resignation,
575
  player_two_failed_to_find_legal_move,
576
  illegal_moves_two,
577
- ) = play_turn(player_two, board, game_state, player_one=False)
578
  player_two_illegal_moves += 1 if illegal_moves_two > 0 else 0
579
  player_two_illegal_attempts += illegal_moves_two
580
  if illegal_moves_two != 0:
@@ -655,7 +658,8 @@ MAX_MOVES = 999 # Due to nanogpt max input length of 1024
655
  recording_file = "logs/determine.csv" # default recording file. Because we are using list [player_ones], recording_file is overwritten
656
  player_ones = ["50M/adams.pt"]
657
  player_two_recording_name = "lc0_sweep" #"stockfish_sweep"
658
- move_num_in_gamestate = False
 
659
  book_opening = True
660
  random_opening = False
661
  random_opening_moves = 20
@@ -673,11 +677,11 @@ if __name__ == "__main__":
673
  # player_one = NanoGptPlayer(model_name=player_one_recording_name, move_num_in_gamestate=move_num_in_gamestate)
674
  # player_one_recording_name = "xformer_" + nanogpt_player
675
  player_one_recording_name = "mamba"
676
- player_one = MambaPlayer(model_name="50M/anneal/anneal_complete_round3.pt", move_num_in_gamestate=move_num_in_gamestate)
677
  #player_two = StockfishPlayer(skill_level=i, play_time=0.1)
678
  # player_two = LC0PLayer(skill=i)
679
 
680
- player_two = NanoGptPlayer(model_name="50M/stockfish_16layers_ckpt_with_optimizer.pt", move_num_in_gamestate=True)
681
  player_two_recording_name = "adam"
682
  # player_two = GPTPlayer(model="gpt-4")
683
  # player_two = GPTPlayer(model="gpt-3.5-turbo-instruct")
 
501
  while games_saved < max_games:
502
  print(f"\nGame {games_saved} of {max_games}\n")
503
 
504
+ #with open("gpt_inputs/prompt.txt", "r") as f:
505
+ # game_state = f.read()
506
+ game_state_with_move_num = ""
507
+ game_state_without_move_num = ""
508
  board = chess.Board()
509
 
510
  if book_opening:
 
540
 
541
  with open("game.txt", "w") as f:
542
  f.write(game_state)
 
543
  total_moves += 1
544
  # I increment legal moves here so player_two isn't penalized for the game ending before its turn
545
  player_one_legal_moves += 1
 
547
 
548
  # this if statement may be overkill, just trying to get format to exactly match PGN notation
549
  if board.fullmove_number != 1:
550
+ game_state_with_move_num += " "
551
+ game_state_without_move_num += " "
552
+ game_state_with_move_num += f"{board.fullmove_number}."
553
+ game_state_without_move_num += "."
554
  #print(f"|{game_state}|")
555
  #print(f"{current_move_num}", end=" ")
556
 
 
559
  player_one_resignation,
560
  player_one_failed_to_find_legal_move,
561
  illegal_moves_one,
562
+ ) = play_turn(player_one, board, game_state_with_move_num if player_one_move_num_in_gamestate else game_state_without_move_num, player_one=True)
563
  player_one_illegal_moves += 1 if illegal_moves_one > 0 else 0
564
  player_one_illegal_attempts += illegal_moves_one
565
  if illegal_moves_one != 0:
 
577
  player_two_resignation,
578
  player_two_failed_to_find_legal_move,
579
  illegal_moves_two,
580
+ ) = play_turn(player_two, board, game_state_with_move_num if player_two_move_num_in_gamestate else game_state_without_move_num, player_one=False)
581
  player_two_illegal_moves += 1 if illegal_moves_two > 0 else 0
582
  player_two_illegal_attempts += illegal_moves_two
583
  if illegal_moves_two != 0:
 
658
  recording_file = "logs/determine.csv" # default recording file. Because we are using list [player_ones], recording_file is overwritten
659
  player_ones = ["50M/adams.pt"]
660
  player_two_recording_name = "lc0_sweep" #"stockfish_sweep"
661
+ player_one_move_num_in_gamestate = False
662
+ player_two_move_num_in_gamestate = True
663
  book_opening = True
664
  random_opening = False
665
  random_opening_moves = 20
 
677
  # player_one = NanoGptPlayer(model_name=player_one_recording_name, move_num_in_gamestate=move_num_in_gamestate)
678
  # player_one_recording_name = "xformer_" + nanogpt_player
679
  player_one_recording_name = "mamba"
680
+ player_one = MambaPlayer(model_name="50M/anneal/anneal_complete_round3.pt", move_num_in_gamestate=player_one_move_num_in_gamestate)
681
  #player_two = StockfishPlayer(skill_level=i, play_time=0.1)
682
  # player_two = LC0PLayer(skill=i)
683
 
684
+ player_two = NanoGptPlayer(model_name="50M/stockfish_16layers_ckpt_with_optimizer.pt", move_num_in_gamestate=player_two_move_num_in_gamestate)
685
  player_two_recording_name = "adam"
686
  # player_two = GPTPlayer(model="gpt-4")
687
  # player_two = GPTPlayer(model="gpt-3.5-turbo-instruct")