Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixture of Experts MCTS (MoE MCTS) #216

Merged
merged 57 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f066178
- added game phase detection file
HelpstoneX Jun 22, 2023
e7b9f00
- changed openspiel git
HelpstoneX Jun 22, 2023
ebfa472
- changed openspiel git
HelpstoneX Jun 24, 2023
ae18d66
fixed phase ids
HelpstoneX Jun 24, 2023
8eb237f
added dataset creation option for specific phases
HelpstoneX Jun 24, 2023
738cd8d
Merge branch 'dataset_creation' of https://github.com/HelpstoneX/Craz…
HelpstoneX Jun 29, 2023
3b56cee
param changes in train_cnn.ipynb
HelpstoneX Jul 3, 2023
826f3b6
- fixed plys_to_end list to only include values for moves that really…
HelpstoneX Jul 4, 2023
b92a8a8
Merge branch 'dataset_creation'
HelpstoneX Jul 5, 2023
cdbe3ab
- changes to train_cnn to make it compatible
HelpstoneX Aug 3, 2023
ce89f69
updated fork
HelpstoneX Aug 10, 2023
e55c318
mcts phase integration working, some improvements missing
HelpstoneX Sep 14, 2023
a2a9a2c
- added phase_to_nets map to make sure the right net is used for each…
HelpstoneX Sep 20, 2023
0be67ff
- added game phase vector to created datasets
HelpstoneX Sep 27, 2023
9e9b009
minor fixes for weighted training
HelpstoneX Sep 27, 2023
1700818
- fixes and improvements to prs.py from cutechess-cli
HelpstoneX Sep 28, 2023
cb575ce
- changes for continuing training from tar file (pytorch)
HelpstoneX Oct 2, 2023
964a982
- added python file for training (exported notebook)
HelpstoneX Oct 2, 2023
c3a2a25
- added python file for executing cutechess shell commands
HelpstoneX Oct 3, 2023
d05228d
- added the option to specify additional eval sets (unweighted) to pa…
HelpstoneX Oct 7, 2023
87456f2
- minor changes
HelpstoneX Oct 7, 2023
4229a04
- minor changes for debugging
HelpstoneX Oct 7, 2023
e9bed77
- bugfix in train_cnn.py for additional dataloaders
HelpstoneX Oct 7, 2023
c13d0be
- bugfix in to correctly determine train iterations
HelpstoneX Oct 9, 2023
4a11bd8
- minor changese in prs.py
HelpstoneX Oct 14, 2023
614a4c9
- minor changes for chess 960
HelpstoneX Oct 14, 2023
5049a1e
- reverted mode and version back to 2 and 3
HelpstoneX Oct 14, 2023
d0cc5f4
fixed bug when executing isready multiple times consecutively while s…
HelpstoneX Oct 26, 2023
b47f44b
alternative bugfix attempt for linux
HelpstoneX Oct 27, 2023
57e9d7b
- temporary fix for chess960 wrong training representation
HelpstoneX Nov 1, 2023
982c650
- changes to incorporate 960 dataset analysis
HelpstoneX Dec 9, 2023
d18251b
chess960 input representation fix (c++ engine files still unadjusted …
HelpstoneX Dec 9, 2023
26cb920
- added plot generating notebooks to git (/etc folder)
HelpstoneX Dec 15, 2023
5e0df73
- added support for naive movecount phases
HelpstoneX Dec 17, 2023
f065280
- minor path fix in dataset_loader.py
HelpstoneX Dec 17, 2023
1a7ab6c
undone temporary fix for broken chess960 input representation
HelpstoneX Dec 19, 2023
69e002c
- added support for phases by movecount in c++ code (currently always…
HelpstoneX Jan 12, 2024
85167cd
- minor plotting adjustments
HelpstoneX Jan 17, 2024
2059aac
- adjusted run_cutechess_experiments.py to be able to do experiments …
HelpstoneX Mar 20, 2024
bf57009
- added documentation
HelpstoneX Apr 11, 2024
09c6810
- minor assertion change in train_cnn.py
HelpstoneX Apr 11, 2024
9d5fa1f
- cleaned code and removed sections that are not needed anymore
HelpstoneX Apr 20, 2024
336f785
- changed underscore naming to camelCase naming in several cases
HelpstoneX Apr 20, 2024
fa3dfe6
- added UCI option Game_Phase_Definition with options "lichess" and "…
HelpstoneX Apr 20, 2024
9c4d507
- added searchSettings to RawNetAgent to access selected gamePhaseDef…
HelpstoneX Apr 22, 2024
687ef8a
- aligned train_cnn.ipynb with code inside train_cnn.py
HelpstoneX Apr 22, 2024
65a302b
- cleaned cell outputs of main notebooks
HelpstoneX May 1, 2024
2fae83a
- further notebook output cleanings
HelpstoneX May 1, 2024
2917f78
- removed files unnecessary for pull request and reverted several fil…
HelpstoneX May 1, 2024
df97fac
- reverted .gitignore and Dockerfile to older state
HelpstoneX May 1, 2024
2fd46bb
- .gitignore update to different previous state
HelpstoneX May 1, 2024
6df0f5a
Merge branch 'master' into pull_request_preparation
QueensGambit May 2, 2024
4030367
Update crazyara.cpp
QueensGambit May 2, 2024
81e1a94
Update board.cpp
QueensGambit May 2, 2024
3cbb403
Add GamePhase get_phase to states
QueensGambit May 3, 2024
fabc465
Add GamePhase OpenSpielState::get_phase()
QueensGambit May 3, 2024
a4853f5
Update get_data_loader() to load dict instead
QueensGambit May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
- fixed plys_to_end list to only include values for moves that really…
… have been used

- added counter for games without positions for current phase
  • Loading branch information
HelpstoneX committed Jul 4, 2023
commit 826f3b650f84a973f5e97c42abe2dc369a1439b5
17 changes: 4 additions & 13 deletions DeepCrazyhouse/src/preprocessing/pgn_converter_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def get_planes_from_game(game, mate_in_one=False):
x = []
y_value = []
y_policy = []
plys_to_end = [] # save the number of plys until the end of the game for each position that was considered
board = game.board() # get the initial board state
# update the y value accordingly
if board.turn == chess.WHITE:
Expand All @@ -109,8 +110,7 @@ def get_planes_from_game(game, mate_in_one=False):
# you don't want to push the last move on the board because you had no movement policy to learn from in this case
# The moves get pushed at the end of the for-loop and is only used in the next loop.
# Therefore we can iterate over 'all' moves
plys = 0
for move in all_moves:
for plys, move in enumerate(all_moves):
board_occ = 0 # by default the positions hasn't occurred before
fen = board.fen()
# remove the halfmove counter & move counter from this fen to make repetitions possible
Expand Down Expand Up @@ -147,24 +147,15 @@ def get_planes_from_game(game, mate_in_one=False):
# add the next move defined in policy vector notation to the policy list
# the network always sees the board as if he's the white player, that's the move is mirrored fro black
y_policy.append(move_to_policy(next_move, mirror_policy=mirror_policy(board)))
plys_to_end.append(len(all_moves) - 1 - plys)

y_init *= -1 # flip the y_init value after each move
board.push(move) # push the next move on the board
plys += 1

plys_to_end = np.arange(plys)[::-1]

# check if there has been any moves
# check if there has been any moves and stack the lists
if x and y_value and y_policy:
x = np.stack(x, axis=0)
y_value = np.stack(y_value, axis=0)
y_policy = np.stack(y_policy, axis=0)
else:
#print("game.headers:")
#print(game.headers)
#print("len(all_moves)", len(all_moves))
#print("game", game)
return x, y_value, y_policy, plys_to_end
#raise Exception("The given pgn file's mainline is empty!")

return x, y_value, y_policy, plys_to_end
8 changes: 7 additions & 1 deletion DeepCrazyhouse/src/preprocessing/pgn_to_planes_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,13 @@ def export_pgn_batch(self, cur_part, game_idx_start, game_idx_end, pgn_sel, nb_w

logging.info("starting conversion to planes...")
t_s = time()
pool = Pool()
pool = Pool(processes=None) # If processes is None then the number returned by os.cpu_count() is used
x_dic = {}
y_value_dic = {}
y_policy_dic = {}
plys_to_end_dic = {}
metadata_dic = {}
num_games_without_fitting_moves = 0

if not os.path.exists(self._export_dir):
os.makedirs(self._export_dir)
Expand All @@ -520,6 +521,8 @@ def export_pgn_batch(self, cur_part, game_idx_start, game_idx_end, pgn_sel, nb_w
y_value_dic[game_idx] = y_value
y_policy_dic[game_idx] = y_policy
plys_to_end_dic[game_idx] = plys_to_end
else:
num_games_without_fitting_moves += 1
pool.close()
pool.join()
t_e = time() - t_s
Expand Down Expand Up @@ -547,6 +550,9 @@ def export_pgn_batch(self, cur_part, game_idx_start, game_idx_end, pgn_sel, nb_w
logging.debug("x.shape %s", x.shape)
logging.debug("y_value.shape %s", y_value.shape)
logging.debug("y_policy.shape %s", y_policy.shape)
logging.debug("plys_to_end.shape %s", plys_to_end.shape)
logging.debug("num_games_without_fitting_moves %s", num_games_without_fitting_moves)
assert x.shape[0] == y_value.shape[0] == y_policy.shape[0] == plys_to_end.shape[0]
# Save the dataset to a file
logging.info("saving the dataset to a file...")
# define the compressor object
Expand Down