当前位置: 首页>>代码示例>>C#>>正文


C# Location.Equals方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:Lapixx,项目名称:CS-UU-KI1,代码行数:70,代码来源:MyBot.cs

示例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));
 }
开发者ID:Lapixx,项目名称:CS-UU-KI1,代码行数:10,代码来源:MyBot.cs


注:本文中的Ants.Location.Equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。