public void addResultToAMAFChilds(BackpropagationContainer result) { if (result == null) { throw new ArgumentNullException("CLASS: MctsNode, METHOD: addResultToAMAFChilds - the given result is null!"); } if (result.pathToResult == null || _childNodes == null) { return; } foreach (MctsNode child in _childNodes) { foreach (IMove move in result.pathToResult) { if (phasingPlayer != move.playerWhoDoesTheMove) { continue; } if (child.move.isEqualTo(move)) { child.addResultAMAF(result.gameResult); } } } }
private static BackpropagationContainer mctsSearch(IMctsableGameState gameState, MctsNode node) { if (!node.areChildNodesExpanded) { if (node.playouts == 0) { return(defaultPolicy(gameState)); } node.expandNode(); } MctsNode bestNode = MctsNode.childSelection(node, _DEFAULT_EXPLORATION_CONSTANT); gameState.makeMove(bestNode.move); BackpropagationContainer result; if (!gameState.isGameOver()) { result = mctsSearch(gameState, bestNode); } else { result = new BackpropagationContainer(gameState.getResultOfTheGame(), null); } bestNode.addResult(result.gameResult); bestNode.addResultToAMAFChilds(result); if (result.pathToResult != null) { result.addMoveToPath(bestNode.move); } return(result); }