private bool runRandomSimulation(MctsNode node, Player invokingPlayer) { var board = (CheckerBoard)node.Board.Clone(); int turns = 0; while (board.GetGameStatus() == GameStatuses.Running && turns < MAX_DEPTH) { var availableMoves = getAvailableMoves(board, board.NextPlayer); if (availableMoves != null && availableMoves.Count() > 0) { var randomMove = listHelper.Random(availableMoves); board.MakeMove(randomMove, board.NextPlayer); } turns++; } if (board.GetGameStatus() != GameStatuses.Running && board.NextPlayer == invokingPlayer) { return(true); } else { return(false); } }
private double runRandomSimulation(MctsNode node, Player invokingPlayer) { var board = (CheckerBoard)node.Board.Clone(); int turns = 0; while (board.GetGameStatus() == GameStatuses.Running && turns < MAX_TURNS) { var availableMoves = getAvailableMoves(board, board.NextPlayer); if (availableMoves != null && availableMoves.Count() > 0) { var randomMove = listHelper.Random(availableMoves); board.MakeMove(randomMove, board.NextPlayer); } turns++; } if (board.GetGameStatus() != GameStatuses.Running && board.NextPlayer == invokingPlayer) { //Debug.WriteLine($"Finished in turns {turns}"); var res = (MAX_TURNS - turns) / ((double)MAX_TURNS / 2d); return(res); } else { return(-1d); } }