1 / 7

Grid World Part 3

Grid World Part 3. A closer look at the world. Class interactions. Location class. (0,0) is top left of grid (row, column) Constants for direction Location.NORTH Constants for common turn angles Location.LEFT, Location.HALF_RIGHT are -90 and 45. Location Methods.

glennis
Download Presentation

Grid World Part 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grid World Part 3 A closer look at the world

  2. Class interactions

  3. Location class • (0,0) is top left of grid • (row, column) • Constants for direction • Location.NORTH • Constants for common turn angles • Location.LEFT, Location.HALF_RIGHT are -90 and 45

  4. Location Methods • public Location(int r, int c) • public int getRow() • public int getCol() • public Location getAdjacentLocation(int direction) • public int getDirectionToward(Location target) • .equals(Location other) • .compareTo(Location other) closest to upper left corner goes first

  5. Grid Interface • Implemented by BoundedGrid and UnboundedGrid • boolean isValid(Location loc) • E put(Location loc, E obj) • Put object at location and return previous inhabitant or null • E remove(Location loc) • E get(Location loc) • ArrayList<Location> getOccupiedLocations() • int getNumRows() • int getNumCols()

  6. Grid continued • Methods to collect info about surroundings • ArrayList<Location> getValidAdjacentLocations(Location loc) • ArrayList<Location> getEmptyAdjacentLocations(Location loc) • ArrayList<Location> getOccupiedAdjacentLocations(Location loc) • ArrayList<Actor> getNeighbors(Location loc)

More Related