private bool TryChooseChildForExecute(out MCTS <T> chosenChild) { this.EnsureChildren(); int unvisited = 0; double maxUct = double.NegativeInfinity; chosenChild = null; var visits = this._visits; foreach (var child in this._children) { if (!child._complete) { double childUCT; if (child._visits == 0) { if (random.Next(++unvisited) == 0) { chosenChild = child; } } else if (unvisited == 0 && maxUct < ((childUCT = child.GetUct(visits))) ) { maxUct = childUCT; chosenChild = child; } } } return(chosenChild != null); }
private bool TryChooseChildForTryHandleSkipLevels(out MCTS <T> chosenChild) { this.EnsureChildren(); chosenChild = this._children.Where( (child) => !child.skipLevelsHandled ).RandomOrDefault(); return(chosenChild != null); }