From 5d0d375db8e1cff6cb9f4d57d040fa8f796bf2dd Mon Sep 17 00:00:00 2001 From: Tilps Date: Sat, 6 Feb 2021 14:12:44 +1100 Subject: [PATCH] Fix crash applying moves without a built tree. (#1518) --- src/mcts/node.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mcts/node.cc b/src/mcts/node.cc index c1870843e1..4c9d0a853c 100644 --- a/src/mcts/node.cc +++ b/src/mcts/node.cc @@ -622,7 +622,12 @@ void NodeTree::MakeMove(Move move) { break; } } - if (new_head == nullptr) throw Exception("Invalid move!"); + // If the node has edges populated and new_head is null then an illegal move + // was attempted. This is not compatible with solid children implementation + // of ReleaseChildren, so abort here. + if (current_head_->HasChildren() && new_head == nullptr) { + throw Exception("Invalid move!"); + } move = board.GetModernMove(move); current_head_->ReleaseChildrenExceptOne(new_head); new_head = current_head_->child_.get();