uwcse.sim
Class SmartFish

java.lang.Object
  |
  +--uwcse.sim.OilThing
        |
        +--uwcse.sim.Fish
              |
              +--uwcse.sim.SmartFish
All Implemented Interfaces:
Thing

class SmartFish
extends Fish

SmartFish swim around intelligently and eat algae and reproduce.


Inner Class Summary
(package private)  class SmartFish.CellData
          This class is used to represent data about neighboring cells.
 
Fields inherited from class uwcse.sim.Fish
algaeEaten
 
Fields inherited from class uwcse.sim.OilThing
alive, rand, world, x, y
 
Constructor Summary
SmartFish(WorldModel wm, int x, int y)
          Create a new smart fish.
 
Method Summary
 void action()
          Basically checks neighbors and eats algae, reproducing after 6 or more are eaten.
 void displayOn(uwcse.graphics.GWindow g)
          Display as red oval.
 
Methods inherited from class uwcse.sim.Fish
interact
 
Methods inherited from class uwcse.sim.OilThing
checkNeighbors, getX, getY, isAlive, kill, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmartFish

public SmartFish(WorldModel wm,
                 int x,
                 int y)
Create a new smart fish.
Method Detail

displayOn

public void displayOn(uwcse.graphics.GWindow g)
Display as red oval.
Overrides:
displayOn in class Fish

action

public void action()
Basically checks neighbors and eats algae, reproducing after 6 or more are eaten. The smarts are in how it moves afterwards: it checks cells to the north, south, east, west, and local, and moves towards the cell with the greatest number of algae.
Overrides:
action in class Fish