本文整理汇总了C#中FuryOfDracula.GameLogic.GameState.GetDistanceToClosestHunter方法的典型用法代码示例。如果您正苦于以下问题:C# GameState.GetDistanceToClosestHunter方法的具体用法?C# GameState.GetDistanceToClosestHunter怎么用?C# GameState.GetDistanceToClosestHunter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FuryOfDracula.GameLogic.GameState
的用法示例。
在下文中一共展示了GameState.GetDistanceToClosestHunter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChooseWhereToEvadeTo
public Location ChooseWhereToEvadeTo(GameState game)
{
var allLocations = Enumerations.GetAllLocations();
List<Location> locationsToExclude = new List<Location>();
foreach (Location location in allLocations)
{
if ((game.Map.TypeOfLocation(location) != LocationType.SmallCity && game.Map.TypeOfLocation(location) != LocationType.LargeCity) || game.HuntersAt(location).Any() || game.Dracula.TrailContains(location))
{
locationsToExclude.Add(location);
}
}
foreach (Location location in locationsToExclude)
{
allLocations.Remove(location);
}
List<int> distancesToNearestHunter = new List<int>();
foreach (Location location in allLocations)
{
distancesToNearestHunter.Add(game.GetDistanceToClosestHunter(location, true));
}
int totalDistanceWeights = 0;
for (int i = 0; i < distancesToNearestHunter.Count(); i++)
{
distancesToNearestHunter[i] *= distancesToNearestHunter[i];
totalDistanceWeights += distancesToNearestHunter[i];
}
int randomNumber = new Random().Next(0, totalDistanceWeights);
int count = 0;
int index = -1;
foreach (int distance in distancesToNearestHunter)
{
index++;
count += distance;
if (count > randomNumber)
{
break;
}
}
return allLocations[index];
}
示例2: ChooseDestinationAndPower
//.........这里部分代码省略.........
{
numberOfPossibleLocationsAfterMove.Add(currentNumberOfPossibleCurrentLocations);
}
else if (move.Power == Power.DoubleBack)
{
var doubleBackSlot = GetIndexOfLocationInTrail(move.Location, currentActualTrail);
var uniquePossibleDoubleBackLocations = new List<Location>();
foreach (var trail in PossibilityTree)
{
if (DoubleBackToPositionIsValidForTrail(game, trail, doubleBackSlot) && !uniquePossibleDoubleBackLocations.Contains(trail[doubleBackSlot].Location))
{
uniquePossibleDoubleBackLocations.Add(trail[doubleBackSlot].Location);
}
}
numberOfPossibleLocationsAfterMove.Add(uniquePossibleDoubleBackLocations.Count() - uniquePossibleDoubleBackLocations.Count(loc => game.HuntersAt(loc).Any()));
}
else if (move.Power == Power.WolfForm)
{
numberOfPossibleLocationsAfterMove.Add(uniquePossibleWolfFormLocations.Count() - uniquePossibleWolfFormLocations.Count(loc => game.HuntersAt(loc).Any()));
}
}
}
var numberOfMovesUntilDeadEnd = new List<int>();
var deadEndMoves = GetPossibleMovesThatLeadToDeadEnds(game, currentActualTrail, possibleMoves, numberOfMovesUntilDeadEnd);
int turnsUntilTrailCleared = GetNumberOfTurnsUntilTrailCleared(game);
int index;
int randomNumber;
List<PossibleTrailSlot> shortList;
switch (Strategy)
{
case Strategy.Sneaky:
var distancesFromNearestHunter = new List<int>();
var currentDistanceFromHunters = game.GetDistanceToClosestHunter(game.Dracula.CurrentLocation, true);
foreach (var move in possibleMoves)
{
if (move.Location != Location.Nowhere)
{
distancesFromNearestHunter.Add(game.GetDistanceToClosestHunter(move.Location, true));
GC.Collect();
}
else
{
distancesFromNearestHunter.Add(currentDistanceFromHunters);
}
}
var chancesToSelectMove = new List<int>();
index = -1;
foreach (var move in possibleMoves)
{
index++;
var deadEndIndex = deadEndMoves.FindIndex(m => m.Location == move.Location && m.Power == move.Power);
if (deadEndIndex > -1 && turnsUntilTrailCleared > numberOfMovesUntilDeadEnd[deadEndIndex])
{
chancesToSelectMove.Add(1);
}
else
{
chancesToSelectMove.Add((int)(Math.Pow(numberOfPossibleLocationsAfterMove[index] * distancesFromNearestHunter[index], CHANCETOSELECTSCALAR) * PercentageDifferenceInLikelihoodOfDraculaDeath(game.Dracula.Blood, move.Power)));
}
}
int totalCombinations = 0;
foreach (int i in chancesToSelectMove)
{
totalCombinations += i;
}
示例3: ChoosePortToGoToAfterStormySeas
public Location ChoosePortToGoToAfterStormySeas(GameState game)
{
var validPorts = game.Map.GetPortsAdjacentTo(game.Dracula.CurrentLocation);
if (!validPorts.Any())
{
return Location.Nowhere;
}
List<int> distances = new List<int>();
if (Strategy == Strategy.Sneaky)
{
int totalDistanceWeights = 0;
foreach (Location location in validPorts)
{
int distance = game.GetDistanceToClosestHunter(location, false);
distances.Add(distance * distance);
totalDistanceWeights += distances.Last();
}
int randomNumber = new Random().Next(0, totalDistanceWeights);
int count = 0;
int index = -1;
foreach (int dist in distances)
{
index++;
count += dist;
if (count > randomNumber)
{
return validPorts[index];
}
}
}
else if (Strategy == Strategy.Aggressive)
{
foreach (Location location in validPorts)
{
int distance = game.GetDistanceToClosestHunter(location, false);
}
int shortestDistance = distances.First();
foreach (int dist in distances)
{
if (dist < shortestDistance)
{
shortestDistance = dist;
}
}
List<Location> shortList = new List<Location>();
int index = -1;
foreach (Location port in validPorts)
{
index++;
if (distances[index] == shortestDistance)
{
shortList.Add(port);
}
}
return shortList[new Random().Next(0, shortList.Count())];
}
else if (Strategy == Strategy.FleeToCastleDracula)
{
foreach (Location location in validPorts)
{
int distance = game.DistanceByRoadOrSeaBetween(location, Location.CastleDracula, false);
}
int shortestDistance = distances.First();
foreach (int dist in distances)
{
if (dist < shortestDistance)
{
shortestDistance = dist;
}
}
List<Location> shortList = new List<Location>();
int index = -1;
foreach (Location port in validPorts)
{
index++;
if (distances[index] == shortestDistance)
{
shortList.Add(port);
}
}
return shortList[new Random().Next(0, shortList.Count())];
}
return validPorts[new Random().Next(0, validPorts.Count())];
}