Presentation is loading. Please wait.

Presentation is loading. Please wait.

GridWorld Part 4 Meet the Critters.

Similar presentations


Presentation on theme: "GridWorld Part 4 Meet the Critters."— Presentation transcript:

1 GridWorld Part 4 Meet the Critters

2 Critter’s act() if (getGrid() == null) return;
ArrayList<Actor> actors = getActors(); processActors(actors); ArrayList<Location> moveLocs = getMoveLocations(); Location loc = selectMoveLocation(moveLocs); makeMove(loc);

3 getActors() Gets all neighbors
Override to get Actors from different locations

4 processActors() Eats surrounding Actors unless they’re a Rock or a Critter Use instanceOf if (!(a instanceof Rock) && !(a instanceof Critter)) a.removeSelfFromGrid(); Override to Add Not eat Eat differently

5 getMoveLocations() Returns empty neighbors
Override to get possible locations differently Locations that are not empty

6 selectMoveLocation(ArrayList)
Randomly picks a location from ArrayList<Location> Override to select by other method

7 makeMove(Location) Moves to the new Location Override to
Leave something in previous spot turn

8 Extending Critter

9 Chameleon Critter Overrides processActors makeMove
If there is a neighbor, Matches their color makeMove Turn in direction that it’s moving

10 CrabCritter Overrides getActors getMoveLocations() makeMove
Only look front, front right, and front left getMoveLocations() Returns empty locations to the right and left makeMove Will randomly turn left or right if it doesn’t move


Download ppt "GridWorld Part 4 Meet the Critters."

Similar presentations


Ads by Google