private List <float> GetHardWeights(AIBoard board) { float p1spWeight = 1f; float p2spWeight = 1f; //Variables used in weight calculations. int playerOneSP = BoardAnalysis.FindShortestPath(board, true); int playerTwoSP = BoardAnalysis.FindShortestPath(board, true); int playerTwoNumWalls = CurrentBoard.GetPlayerTwoNumWalls(); int distanceBetweenPlayers = BoardAnalysis.FindDistanceBetween(CurrentBoard, CurrentBoard.GetPlayerOnePos(), CurrentBoard.GetPlayerTwoPos()); if (playerOneSP - playerTwoSP > 2) { p1spWeight = 5; } else if (playerOneSP < 5) { p1spWeight = 2; } List <float> w = new List <float> { p1spWeight, p2spWeight }; return(w); }
public WallDiffNode(AIBoard copy) { Board = new AIBoard(copy); Depth = 0; MoveMade = "rootnode"; Diff = BoardAnalysis.FindShortestPath(Board, true) - BoardAnalysis.FindShortestPath(Board, false); }
//Static evaluation function of the gameboard. private void EvaluateNode() { value = 0; //If a player won, assigns node proper value and then returns. if (EvaluateWinPossibility(ref value)) { } //Calculates factors of interest and calculates the value. else { int P1SP = BoardAnalysis.FindShortestPath(Board, true); int P2SP = BoardAnalysis.FindShortestPath(Board, false); int P1NumWalls = Board.GetPlayerOneNumWalls(); int P2NumWalls = Board.GetPlayerTwoNumWalls(); for (int i = 0; i < P2NumWalls; ++i) { value += wallValues[i]; } value += (weights[0] * P1SP - weights[1] * P2SP); } }
//If it is positive P2SP's path got that much shorter. public int CalcChangeInDiff() { Diff = BoardAnalysis.FindShortestPath(Board, true) - BoardAnalysis.FindShortestPath(Board, false); return(PreviousDiff - Diff); }