コード例 #1
0
ファイル: Heuristic.cs プロジェクト: s151607/CoronAI
        private static bool SimulateMove(WorldState state, Action.Directions direction)
        {
            Location newAgentLocation = Location.RelativeLocation(state.agentLocation, direction);

            if (state.Walls.TryGetValue(newAgentLocation, out Location wallLocation))
            {
                return(false);
            }
            else
            {
                state.agentLocation = newAgentLocation;
                return(true);
            }
        }
コード例 #2
0
ファイル: Location.cs プロジェクト: s151607/CoronAI
 public static Location RelativeLocation(Location location, Action.Directions direction)
 {
     if (direction.Equals(Action.Directions.North))
     {
         return(new Location(location.x, location.y - 1));
     }
     else if (direction.Equals(Action.Directions.South))
     {
         return(new Location(location.x, location.y + 1));
     }
     else if (direction.Equals(Action.Directions.West))
     {
         return(new Location(location.x - 1, location.y));
     }
     else if (direction.Equals(Action.Directions.East))
     {
         return(new Location(location.x + 1, location.y));
     }
     else
     {
         return(new Location(location.x, location.y));
     }
 }