public override void GradeBoards(MoveRepresentationList list, BoardRepresentation initialBoard) { int race = 1; bool opponentFound = false; for (int i = 0; i < initialBoard.SquareCount() && race == 1; i++) { if (!opponentFound && initialBoard.GetPiecesAt(i) < 0) { opponentFound = true; } if (opponentFound && initialBoard.GetPiecesAt(i) > 0) { race = 0; } } for (int i = 0; i < list.Count(); i++) { int[] pubevalBoard = new int[28]; MoveRepresentation currentBoard = list.GetMoveRepresentation(i); for (int j = 0; j < currentBoard.SquareCount(); j++) { pubevalBoard[j] = currentBoard.GetPiecesAt(j); } pubevalBoard[26] = currentBoard.BearOffCountCurrent(); pubevalBoard[27] = currentBoard.BearOffCountOpponent(); double s = PubevalGrade(race, pubevalBoard); list.GetMoveRepresentation(i).AddScore(s); } }
public override LinguisticInputValue CreateLinguisticInputValue(BoardRepresentation board) { LinguisticInputValue result = new LinguisticInputValue(GetName(), 0); float r = 0.0f; for (int i = 1; i < 25; i++) { if (board.GetPiecesAt(i) == 1) { bool[,] possibleDices = new bool[6, 6]; for (int x = 0; x < 6; x++) { for (int y = 0; y < 6; y++) { possibleDices[x, y] = false; } } for (int j = 0; j < i; j++) { if (board.GetPiecesAt(j) < 0) { CalculateHitProbability(i, j, board, possibleDices); } } int waysToBeHit = 0; for (int x = 0; x < 6; x++) { for (int y = 0; y < 6; y++) { if (possibleDices[x, y]) { waysToBeHit++; } } } float p = (((float)waysToBeHit) / 36.0f) * 100; r += ((24.0f - ((float)i - 1)) / 24.0f) * p; } } if (r > 50.0f) { r = 50.0f; } result.CrispValue = (int)Math.Round(r, 0); return(result); }
public override LinguisticInputValue CreateLinguisticInputValue(BoardRepresentation board) { LinguisticInputValue result = new LinguisticInputValue(GetName(), 0); for (int i = 7; i < 26; i++) { if (board.GetPiecesAt(i) > 0) { result.CrispValue += board.GetPiecesAt(i); } } return(result); }
private int Race(BoardRepresentation currentBoard) { int race = 1; bool opponentFound = false; for (int j = 0; j < currentBoard.SquareCount() && race == 1; j++) { if (!opponentFound && currentBoard.GetPiecesAt(j) < 0) { opponentFound = true; } if (opponentFound && currentBoard.GetPiecesAt(j) > 0) { race = 0; } } return(race); }
public override LinguisticInputValue CreateLinguisticInputValue(BoardRepresentation board) { bool opponentFound = false; LinguisticInputValue result = new LinguisticInputValue(GetName(), 0); for (int i = 0; i < 26; i++) { if (board.GetPiecesAt(i) < 0) { opponentFound = true; } if (board.GetPiecesAt(i) > 0 && opponentFound) { result.CrispValue = 1; break; } } return(result); }
private void SetRaceInput(BoardRepresentation board, float[] input) { for (int i = 0; i < input.Length; i++) { input[i] = 0.0f; } for (int i = 0; i < 26; i++) { m_OwnBoardView[i] = board.GetPiecesAt(i); m_OppBoardView[25 - i] = -board.GetPiecesAt(i); } int idx = 0; idx = SetBoard(m_OwnBoardView, input, idx); idx = SetRaceBeardOff(m_OwnBoardView, input, idx); idx = SetHalfRaceInput(m_OwnBoardView, input, idx); idx = SetHalfRaceInput(m_OppBoardView, input, idx); }
public override LinguisticInputValue CreateLinguisticInputValue(BoardRepresentation board) { LinguisticInputValue result = new LinguisticInputValue(GetName(), 0); int ownPips = 0; for (int i = 0; i < 26; i++) { if (board.GetPiecesAt(i) > 0) { ownPips += i * board.GetPiecesAt(i); } } int opponentPips = 0; for (int i = 0; i < 26; i++) { if (board.GetPiecesAt(i) < 0) { opponentPips += (25 - i) * (-board.GetPiecesAt(i)); } } int r = opponentPips - ownPips; if (r > 50) { r = 50; } if (r < -50) { r = -50; } result.CrispValue = r; return(result); }
public bool Double() { if (IsAgentPlaying(m_BgGame.CurrentOpponentPlayer) && (m_BgGame.CurrentOpponentPlayer == m_BgGame.GetCubeOwner() || m_BgGame.GetCubeOwner() == BgPlayer.None)) { BoardRepresentation currentBoard = new BoardRepresentation(m_BgGame); int[] flippedPattern = new int[currentBoard.SquareCount()]; for (int i = 0; i < currentBoard.SquareCount(); i++) { flippedPattern[25 - i] = -currentBoard.GetPiecesAt(i); } BoardRepresentation flippedBoard = new BoardRepresentation(flippedPattern); int evaluator = m_GUI.SelectedEvaluator(); if (evaluator >= 0) { return(m_Plugins[evaluator].Double(flippedBoard)); } } return(false); }
public override LinguisticInputValue CreateLinguisticInputValue(BoardRepresentation board) { int currentConsecutiveOwned = 0; LinguisticInputValue result = new LinguisticInputValue(GetName(), 0); for (int i = 1; i < 25; i++) { if (board.GetPiecesAt(i) > 1) { currentConsecutiveOwned++; if (currentConsecutiveOwned > result.CrispValue) { result.CrispValue = currentConsecutiveOwned; } } else { currentConsecutiveOwned = 0; } } return(result); }
private float[] BoardToNetworkInput(BoardRepresentation currentBoard) { int Idx = 0; float[] board = new float[196]; for (int i = 1; i < 25; i++) { int pieces = currentBoard.GetPiecesAt(i); if (pieces == 0) { board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces == 1) { board[Idx++] = 1; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces == 2) { board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces == 3) { board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces > 3) { board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = (pieces - 3) / 2.0f; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces == -1) { board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 1; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces == -2) { board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 0; board[Idx++] = 0; } else if (pieces == -3) { board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 0; } else if (pieces < -3) { board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 0; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = 1; board[Idx++] = (-pieces - 3) / 2.0f;; } } board[Idx++] = currentBoard.GetPiecesAt(25) / 2.0f; board[Idx++] = -currentBoard.GetPiecesAt(0) / 2.0f; board[Idx++] = currentBoard.BearOffCountCurrent() / 15.0f; board[Idx++] = -currentBoard.BearOffCountOpponent() / 15.0f; return(board); }
public void CalculateHitProbability(int position, int hitFrom, BoardRepresentation board, bool[,] hittingDices) { int distance = position - hitFrom; for (int i = 1; i <= 6; i++) { for (int j = 1; j <= 6; j++) { if (distance == i || distance == j) { if (board.GetPiecesAt(0) == 0) { hittingDices[i - 1, j - 1] = true; } else if (board.GetPiecesAt(0) < 0 && hitFrom == 0) { hittingDices[i - 1, j - 1] = true; } else if (board.GetPiecesAt(0) == -1 && hitFrom != 0) { if (distance == i && board.GetPiecesAt(j) < 2) { hittingDices[i - 1, j - 1] = true; } else if (distance == j && board.GetPiecesAt(i) < 2) { hittingDices[i - 1, j - 1] = true; } } else if (i == j && (board.GetPiecesAt(0) == -1 || board.GetPiecesAt(0) == -2 || board.GetPiecesAt(0) == -3) && board.GetPiecesAt(i) < 2) { hittingDices[i - 1, j - 1] = true; } } else if (distance == i + j) { if (board.GetPiecesAt(0) == 0) { if (board.GetPiecesAt(hitFrom + i) < 2 || board.GetPiecesAt(hitFrom + j) < 2) { hittingDices[i - 1, j - 1] = true; } } else if (board.GetPiecesAt(0) == -1 && hitFrom == 0) { if (board.GetPiecesAt(hitFrom + i) < 2 || board.GetPiecesAt(hitFrom + j) < 2) { hittingDices[i - 1, j - 1] = true; } } else if (i == j && (board.GetPiecesAt(0) == -1 || board.GetPiecesAt(0) == -2) && board.GetPiecesAt(i) < 2) { if (board.GetPiecesAt(hitFrom + i) < 2) { hittingDices[i - 1, j - 1] = true; } } else if (i == j && board.GetPiecesAt(0) == -3 && hitFrom == 0 && board.GetPiecesAt(i) < 2) { hittingDices[i - 1, j - 1] = true; } } else if (i == j && (distance == 3 * i || distance == 4 * i)) { if (board.GetPiecesAt(0) == 0) { if (distance == 3 * i) { if (board.GetPiecesAt(hitFrom + i) < 2 && board.GetPiecesAt(hitFrom + (i * 2)) < 2) { hittingDices[i - 1, j - 1] = true; } } if (distance == 4 * i) { if (board.GetPiecesAt(hitFrom + i) < 2 && board.GetPiecesAt(hitFrom + (i * 2)) < 2 && board.GetPiecesAt(hitFrom + (i * 3)) < 2) { hittingDices[i - 1, j - 1] = true; } } } else if ((board.GetPiecesAt(0) == -1 && hitFrom == 0)) { if (distance == 3 * i) { if (board.GetPiecesAt(hitFrom + i) < 2 && board.GetPiecesAt(hitFrom + (i * 2)) < 2) { hittingDices[i - 1, j - 1] = true; } } if (distance == 4 * i) { if (board.GetPiecesAt(hitFrom + i) < 2 && board.GetPiecesAt(hitFrom + (i * 2)) < 2 && board.GetPiecesAt(hitFrom + (i * 3)) < 2) { hittingDices[i - 1, j - 1] = true; } } } else if ((board.GetPiecesAt(0) == -2 && hitFrom == 0)) { if (distance == 3 * i) { if (board.GetPiecesAt(hitFrom + i) < 2 && board.GetPiecesAt(hitFrom + (i * 2)) < 2) { hittingDices[i - 1, j - 1] = true; } } } else if (board.GetPiecesAt(0) == -1 && hitFrom != 0 && board.GetPiecesAt(i) < 2) { if (distance == 3 * i) { if (board.GetPiecesAt(hitFrom + i) < 2 && board.GetPiecesAt(hitFrom + (i * 2)) < 2) { hittingDices[i - 1, j - 1] = true; } } } } } } }
public override LinguisticInputValue CreateLinguisticInputValue(BoardRepresentation board) { LinguisticInputValue result = new LinguisticInputValue(GetName(), -board.GetPiecesAt(0)); return(result); }