public Board Clone() { Board result = new Board(); result.CopyStateFrom(this); return(result); }
double GetWinrate(Move move) { if (_startingTestingBoard == null) { _startingTestingBoard = new Board(); } _startingTestingBoard.CopyStateFrom(_actualBoard); if (_startingTestingBoard.PlaceStone(move) == false) { return(-1); } UInt64 sim = 0; int wins = 0; while (sim < GameParameters.RandomSimulations) { int winner = PlaySimulation(); if (winner != 0) { sim++; if (winner == _actualBoard.ActivePlayer) { wins++; } } } return(sim > 0 ? (double)wins / sim : -1); }
public int PlaySimulation() { if (_testingBoard == null) { _testingBoard = new Board(); } _testingBoard.CopyStateFrom(_startingTestingBoard); int turnsSimulated = 0; while (turnsSimulated < GameParameters.GameDepth && _testingBoard.IsGameOver() == false) { turnsSimulated++; int moveCount = GetAvailableMoves(_testingBoard); Move pass = new Move(-1, -1); //добавить в список возможных ходов пас _availableMoves[moveCount++] = pass; _availableMoves.Shuffle(moveCount); for (int i = 0; i < moveCount; i++) { if (_testingBoard.PlaceStone(_availableMoves[i]) == true) { break; } } } int winner = _testingBoard.DetermineWinner(); return(winner); }
private int PlayRandomGame(UCTNode node) { _boardClone.CopyStateFrom(node.BoardState); int turnsSimulated = 0; while (turnsSimulated < GameParameters.GameDepth && _boardClone.IsGameOver() == false) { turnsSimulated++; Move m = new Move(-5, -5); do { m.row = RandomGen.Next(-1, GameParameters.BoardSize); m.column = RandomGen.Next(-1, GameParameters.BoardSize); } while (_boardClone.PlaceStone(m) == false); } int winner = _boardClone.DetermineWinner(); return(winner); }
public int PlaySimulation() { if (_testingBoard == null) { _testingBoard = new Board(); } _testingBoard.CopyStateFrom(_startingTestingBoard); int turnsSimulated = 0; while (turnsSimulated < GameParameters.GameDepth && _testingBoard.IsGameOver() == false) { turnsSimulated++; Move m = new Move(-1, -1); do { m.row = RandomGen.Next(-1, GameParameters.BoardSize); m.column = RandomGen.Next(-1, GameParameters.BoardSize); } while (_testingBoard.PlaceStone(m) == false); } int winner = _testingBoard.DetermineWinner(); return(winner); }
public Board Clone() { Board result = new Board(); result.CopyStateFrom(this); return result; }