本文整理汇总了C#中IGameState.GetIsVisible方法的典型用法代码示例。如果您正苦于以下问题:C# IGameState.GetIsVisible方法的具体用法?C# IGameState.GetIsVisible怎么用?C# IGameState.GetIsVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGameState
的用法示例。
在下文中一共展示了IGameState.GetIsVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTurn
// DoTurn is run once per turn
public override void DoTurn(IGameState state)
{
//For assigning jobs to and keeping track of ants
List<Route> foodRoutes = new List<Route>();
List<Location> foodLocations = state.FoodTiles;
//Keep track of food and which ants are delegated to foodfinding
List<Location> foodTargets = new List<Location>();
List<Location> foodAnts = new List<Location>();
//If map has not been set yet, add a new map
if (map == null)
{
//Create a new map
map = new Map(state.Width, state.Height);
}
//Add all locations to unseen tiles set, run once
if (unseenTiles == null)
{
unseenTiles = new List<Location>();
for (int row = 0; row < state.Width; row++)
{
for (int col = 0; col < state.Height; col++)
{ unseenTiles.Add(new Location(row, col)); }
}
}
//Remove any tiles that can be seen, run each turn
int count = unseenTiles.Count;
for (int i = 0; i < count; i++)
{
//Check if each tile in unseentiles is visible or not
if (state.GetIsVisible(unseenTiles[i]))
{
//Add the tile info to the map
map.AddLocation(unseenTiles[i], state);
//If visible, remove. Then put i back 1 and lower count by 1
unseenTiles.RemoveAt(i);
i--;
count--;
}
}
//To prevent stepping on your own hills
foreach (AntHill myHill in state.MyHills)
{
orders.Add(myHill); //Now the hills always count as occupied
}
if (state.TimeRemaining > 10)
{
//Create a route from each ant to each food
foreach (Location food in foodLocations)
{
foreach (Ant ant in state.MyAnts)
{
int distance = state.GetDistance(ant, food);
Route route = new Route(ant, food, distance);
foodRoutes.Add(route);
}
}
//Sort routes on distance (Note: This took waaay too long to figure out)
foodRoutes.Sort(delegate(Route r1, Route r2)
{
return r1.CompareTo(r2);
});
foreach (Route route in foodRoutes)
{
//Check if food has ant sent to it already
//Check if ant has been sent already
//If not, sent ant to food if move is possible
if (!foodTargets.Contains(route.GetEnd)
&& !foodAnts.Contains(route.GetStart)
&& DoMoveLocation(route.GetStart, route.GetEnd, state))
{
foodTargets.Add(route.GetEnd);
foodAnts.Add(route.GetStart);
}
// check if we have time left to calculate more orders
if (state.TimeRemaining < 10) break;
}
}
//Add new hills to the list of enemy hills
foreach (Location enemyHill in state.EnemyHills)
if (!enemyHills.Contains(enemyHill)) enemyHills.Add(enemyHill);
//Attack enemy hills
if (state.TimeRemaining > 10)
{
List<Route> hillRoutes = new List<Route>();
foreach (Location hillLoc in enemyHills)
{
foreach (Location antLoc in state.MyAnts)
{
//Check for all the ants whether
if (!orders.Contains(antLoc))
{
int distance = state.GetDistance(antLoc, hillLoc);
Route route = new Route(antLoc, hillLoc, distance);
hillRoutes.Add(route);
//.........这里部分代码省略.........
示例2: WalkThatWay
// Local planning (for individual ant)
public void WalkThatWay(Ant a, IGameState state)
{
if (heatMap.GetCell(a) > 0.1f)
heatMap.UpdateCell(a, -0.1f);
string key = LocationToKey(a);
if (!currentTasks.ContainsKey(key))
{
if (state.MyAnts.Count / 8 > martinSheen.Count && timRobbins.Count > 0)
{
Location martin = timRobbins[timRobbins.Count - 1];
timRobbins.RemoveAt(timRobbins.Count - 1);
martinSheen.Add(martin);
currentTasks.Add(key, new CurrentTask(Task.Guaaard, martin));
}
else if (state.MyAnts.Count >= armySize)
{
return;
}
else
{
LogShit("Shitjeweet.txt", currentStep + " added or something youknowyourself");
currentTasks.Add(key, new CurrentTask(Task.Roaming, a));
}
}
CurrentTask task = currentTasks[key];
task.from = a;
task.resolved = false;
if (task.task != Task.Terminating && task.task != Task.Guaaard)
{
foreach (Location e in theirHills)
{
if (state.GetDistance(a, e) <= raidRadius)
{
task.hill = e;
task.task = Task.Terminating;
break;
}
}
}
if (task.task == Task.Terminating)
{
if (task.hill.Equals(a))
{
theirHills.Remove(task.hill);
heatMap.ResetCell(task.hill);
}
if (!theirHills.Contains(task.hill))
{
task.task = Task.Roaming;
task.roam = a;
}
}
if (task.task == Task.Dinner)
{
if (task.food.Equals(a) || (state[task.food.Row, task.food.Col] != Tile.Food && state.GetIsVisible(task.food)))
{
task.task = Task.Roaming;
yummies.Remove(task.food);
}
}
if (task.task == Task.Roaming)
{
Location f = SearchFood(a, state);
if (f != null)
{
task.food = f;
task.task = Task.Dinner;
yummies.Add(f);
}
if (task.roam.Equals(a) || !state.GetIsPassable(task.roam) || state.GetDistance(a, task.roam) <= arrivalRadius)
{
heatMap.UpdateCell(task.roam, -5f);
task.roam = GetNewDestination(a, state);
if (task.roam == null)
{
task.to = task.from;
return;
}
}
}
List<Location> avoid = new List<Location>();
avoid.AddRange(state.MyHills);
avoid.AddRange(martinSheen);
if (task.task == Task.Guaaard)
avoid.Remove(task.roam);
Location tgt = null;
switch (task.task)
{
case Task.Roaming: tgt = task.roam; break;
//.........这里部分代码省略.........