protected override void Evaluate(SearchNode searchNode, GameState gameState) { if (gameState.IsGameOver) { if (gameState.PlayerToMoveNext == PlayerType.You) { searchNode.Evaluation = double.NegativeInfinity; } else { searchNode.Evaluation = double.PositiveInfinity; } } else { MetricsWeightings weightings = gameState.OpponentIsInSameCompartment ? WeightingsInSameCompartment : WeightingsInSeparateCompartment; double evaluation = weightings.NumberOfCellsReachableByPlayerFactor * (gameState.NumberOfCellsReachableByYou - gameState.NumberOfCellsReachableByOpponent) + weightings.TotalDegreesOfCellsReachableByPlayerFactor * (gameState.TotalDegreesOfCellsReachableByYou - gameState.TotalDegreesOfCellsReachableByOpponent) + weightings.NumberOfCellsClosestToPlayerFactor * (gameState.NumberOfCellsClosestToYou - gameState.NumberOfCellsClosestToOpponent) + weightings.TotalDegreesOfCellsClosestToPlayerFactor * (gameState.TotalDegreesOfCellsClosestToYou - gameState.TotalDegreesOfCellsClosestToOpponent) + weightings.NumberOfComponentBranchesInTreeFactor * (gameState.NumberOfComponentBranchesInYourTree - gameState.NumberOfComponentBranchesInOpponentsTree) + weightings.SumOfDistancesFromThisPlayerOnClosestCellsFactor * (gameState.SumOfDistancesFromYouOnYourClosestCells - gameState.SumOfDistancesFromOpponentOnOpponentsClosestCells) + weightings.SumOfDistancesFromOtherPlayerOnClosestCellsFactor * (gameState.SumOfDistancesFromOpponentOnYourClosestCells - gameState.SumOfDistancesFromYouOnOpponentsClosestCells) + weightings.ChamberValueFactor * (gameState.ChamberValueForYou - gameState.ChamberValueForOpponent); searchNode.Evaluation = evaluation; } }
protected BaseNegaMaxSolverWithMetricsWeightings(MetricsWeightings weightingsInSameCompartment, MetricsWeightings weightingsInSeparateCompartment) { WeightingsInSameCompartment = weightingsInSameCompartment; WeightingsInSeparateCompartment = weightingsInSeparateCompartment; }