Package edu.uky.ai.path

# Class Map

java.lang.Object
edu.uky.ai.path.Map

All Implemented Interfaces:
  `java.lang.Iterable<Location>`

    public class Map
    extends java.lang.Object
    implements java.lang.Iterable<Location>

Represents a 2D space that may contain walls.

Author:
  Stephen G. Ware

- ## Field Summary

  Fields
  Modifier and Type | Field | Description
  --- | --- | ---
  `Sprite` | `flag` | The destination
  `int` | `height` | The height of the space
  `static Map` | `MAP_1` | An empty map
  `static Map` | `MAP_2` | A map with a simple wall
  `static Map` | `MAP_3` | A map with 2 walls
  `static Map` | `MAP_4` | A map with a long corridor leading to a dead end
  `static Map` | `MAP_5` | A map with a long dead end corridor on the top
  `static Map` | `MAP_6` | A map with a long, winding path that will fool greedy search
  `Sprite` | `robot` | The robot
  `int` | `width` | The width of the space

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `Map​(int width, int height, edu.uky.ai.path.Map.Wall... walls)` | Creates a new 2D space with a give number of walls.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `void` | `forEach​(java.util.function.Consumer<? super Location> consumer)` |
  `Location` | `getLocation​(int x, int y)` | Returns the `Location` object at the given coordinates.
  `Location` | `getLocation​(Sprite sprite)` | Returns the `Location` object at the position of a given `Sprite`.
  `java.util.Iterator<Location>` | `iterator()` |

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `spliterator`

- ## Field Details

  - ### width

    public final int width
    The width of the space

  - ### height

    public final int height
    The height of the space

  - ### robot

    public final Sprite robot
    The robot

  - ### flag

    public final Sprite flag
    The destination

  - ### MAP_1

    public static final Map MAP_1
    An empty map

  - ### MAP_2

    public static final Map MAP_2
    A map with a simple wall

  - ### MAP_3

    public static final Map MAP_3
    A map with 2 walls

  - ### MAP_4

    public static final Map MAP_4
    A map with a long corridor leading to a dead end

  - ### MAP_5

    public static final Map MAP_5
    A map with a long dead end corridor on the top

  - ### MAP_6

    public static final Map MAP_6
    A map with a long, winding path that will fool greedy search

- ## Constructor Details

  - ### Map

    public Map​(int width, int height, edu.uky.ai.path.Map.Wall... walls)
    Creates a new 2D space with a give number of walls.
    Parameters:
      `width` - the width of the space
      `height` - the height of the space
      `walls` - any walls the space contains

- ## Method Details

  - ### iterator

    public java.util.Iterator<Location> iterator()
    Specified by:
      `iterator` in interface `java.lang.Iterable<Location>`

  - ### forEach

    public void forEach​(java.util.function.Consumer<? super Location> consumer)
    Specified by:
      `forEach` in interface `java.lang.Iterable<Location>`

  - ### getLocation

    public Location getLocation​(int x, int y)
    Returns the `Location` object at the given coordinates.
    Parameters:
      `x` - the horizontal position
      `y` - the vertical position
    Returns:
      a `Location` object

  - ### getLocation

    public Location getLocation​(Sprite sprite)
    Returns the `Location` object at the position of a given `Sprite`.
    Parameters:
      `sprite` - the sprite
    Returns:
      a `Location` object at the same position