本文整理汇总了C#中Ants.Location.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Location.Equals方法的具体用法?C# Location.Equals怎么用?C# Location.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ants.Location
的用法示例。
在下文中一共展示了Location.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveConflict
// 2nd pass collision avoidance
public bool ResolveConflict(Location loc, Location caller, Location origin, IGameState state)
{
if (LocationToKey(loc) == "32,72")
LogShit("aaaaaaaa.txt", "Derp @ 32,72 in step " + currentStep);
if (!currentTasks.ContainsKey(LocationToKey(loc)))
LogShit("aaaaaaaa.txt", "loc = " + LocationToKey(loc) + "caller = " + LocationToKey(caller) + "origin = " + LocationToKey(origin));
CurrentTask task = currentTasks[LocationToKey(loc)];
task.resolving++;
if(loc.Equals(task.to))
{
LogShit("Shitjeweet.txt", "A");
PerformMove(task, task.to, state);
task.resolving = 0;
return false;
}
else if (nextTasks.ContainsKey(LocationToKey(task.to))) // Destination taken
{
LogShit("Shitjeweet.txt", "B");
PerformMove(task, task.from, state);
task.resolving = 0;
return false;
}
else if (!currentTasks.ContainsKey(LocationToKey(task.to))) // Destination free
{
LogShit("Shitjeweet.txt", "C");
PerformMove(task, task.to, state);
task.resolving = 0;
return true;
}
else if (currentTasks[LocationToKey(loc)].to.Equals(caller)) // Ant at loc wants to loc of caller and vice versa
{
LogShit("Shitjeweet.txt", "D");
task.warp = true;
PerformMove(task, caller, state);
currentTasks[LocationToKey(caller)].warp = true;
task.resolving = 0;
return true;
}
else if (task.to.Equals(origin) && caller != null) // Loop detected to original caller (possible)
{
LogShit("Shitjeweet.txt", "E");
PerformMove(task, task.to, state);
task.resolving = 0;
return true;
}
else if (task.resolving > 1) // Loop detected (futurally possible)
{
LogShit("Shitjeweet.txt", "F");
// Resolve directly?
task.resolving = 0;
return false;
}
else if (ResolveConflict(task.to, loc, origin, state)) // Check if destination will be free
{
LogShit("Shitjeweet.txt", "G");
bool notWarp = !task.warp;
PerformMove(task, task.to, state);
task.resolving = 0;
return notWarp;
}
else
{
LogShit("Shitjeweet.txt", "H");
if (caller == null)
PerformMove(task, task.from, state);
task.resolving = 0;
return false;
}
}
示例2: PerformMove
// Move ant
public void PerformMove(CurrentTask task, Location to, IGameState state)
{
if (!to.Equals(task.from) && !task.warp)
IssueOrder(task.from, ((List<Direction>)state.GetDirections(task.from, task.to))[0]);
task.warp = false;
task.resolved = true;
nextTasks.Add(LocationToKey(to), task);
currentTasks.Remove(LocationToKey(task.from));
}