Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 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));
     }
 }