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); } }
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)); } }