Skip to content

feat: Implement Serialize for MCTSBot (#1257)#1466

Open
SH20RAJ wants to merge 2 commits intogoogle-deepmind:masterfrom
SH20RAJ:feat/mcts-serialize
Open

feat: Implement Serialize for MCTSBot (#1257)#1466
SH20RAJ wants to merge 2 commits intogoogle-deepmind:masterfrom
SH20RAJ:feat/mcts-serialize

Conversation

@SH20RAJ
Copy link
Contributor

@SH20RAJ SH20RAJ commented Jan 30, 2026

Implements Serialize and Deserialize for MCTSBot (Issue #1257).

  • Added Serialize/Deserialize to MCTSBot
  • Enabled mcts_test in CMakeLists.txt
  • Added unit verification for serialization

- Added MaxGameStringLength to Game class in spiel.h
- Exposed in python bindings (pyspiel.cc)
- Implemented for Kuhn Poker
- Fixed compilation errors in spiel.h and bridge.cc (MutexLock)
- Added unit test
- Added Serialize/Deserialize to MCTSBot
- Enabled mcts_test in CMakeLists.txt (was missing)
- Added unit test for serialization verifying determinism
@lanctot
Copy link
Collaborator

lanctot commented Jan 30, 2026

This one has a similar problem as the other: it includes changes from two other PRs. Each PR should be independently.

Please remove the files that are not part of the MCTS serialization.

One suggestion: when you are creating new branches, branch directly from master, not from a different non-master branch.

@alexunderch
Copy link
Contributor

@SH20RAJ no need to recreate the PR, you did branching wrong, unfortunately, should've branched from master but not your active branches;

  1. create a dedicated branch from master
  2. cherry-pick necessary for the PR commits

hint: https://stackoverflow.com/a/9339460

@SH20RAJ
Copy link
Contributor Author

SH20RAJ commented Feb 23, 2026

Thanks @lanctot and @alexunderch for the guidance! I'm still getting the hang of the workflow here. I will fix the branch by creating a clean branch from master and cherry-picking the relevant commits for MCTS serialization, then force-push to update this PR to isolate the changes. I'll get that done soon!

Comment on lines +468 to +482
std::string MCTSBot::Serialize() const {
std::ostringstream os;
os << uct_c_ << "\n";
os << max_simulations_ << "\n";
os << max_nodes_ << "\n";
os << solve_ << "\n";
os << max_utility_ << "\n";
os << dirichlet_alpha_ << "\n";
os << dirichlet_epsilon_ << "\n";
os << dont_return_chance_node_ << "\n";
os << verbose_ << "\n";
os << static_cast<int>(child_selection_policy_) << "\n";
os << rng_; // Serialization of mt19937
return os.str();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't save the tree? I think I'm missing something. What's the motivation of serializing an MCTS bot if you don't save the tree?

@lanctot lanctot added the waiting Waiting to hear back from contributor (tests failed or thread reply / code update required) label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting Waiting to hear back from contributor (tests failed or thread reply / code update required)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants