Title: Greeps
1Greeps
- A programming Competition
2Greeps
- Description
- Greeps Scenario (a .zip file)
- Project 1 modify the Greeps class to increase
your score in the competition - On-line hint
- Greeps.java
3Methods Provided
Actor class getIntersectingObjects
(java.lang.Class cls) getOneIntersectingObject
(java.lang.Class cls) getRotation()
getWorld() getX() getY() setLocation(int x,
int y) setRotation(int rotation
Creature class
- Greep class
- act()
- checkFood()
- getAuthorName()
atShip() atWater() atWorldEdge()
carryingTomato() dropTomato()
getFlag(int flagNo) getMemory() loadTomato()
move() randomChance(int percent)
removeTomato() seePaint(java.lang.String color)
setFlag(int flagNo, boolean val)
setMemory(int val) spit(java.lang.String color)
turn(int angle) turnHome()
4Turning
public void act () turn (5)
5Where the action is act ()
Current plan
Possible problems
if (carryingTomato()) if(atShip())
dropTomato()
else turnHome()
move()
else move()
checkFood()
reaching the world boundary reaching water
Possible changes
if(atWater() atWorldEdge()) turn
(????)
6Possible States and Strategies
- With Respect to the Tomatoes
- Holding a tomato
- Go home (and leave a trail?)
- Not holding nor near a tomato
- Search for tomatoes (follow a trail?)
- At a pile of tomatoes
- Wait there until they are gone?
- With Respect to obstacles/location
- At waters edge
- Turn?
- Move?
- Leave a trail?
- Follow a trail?
- 2) At worlds edge
- Turn?
- Move?
- Leave a trail?
- Follow a trail?
- At ship (after dropping tomatoes)
- Turn?
- Move?
- Leave a trail?
- Follow a trail?
7What To Do
- Devise a strategy
- What to do in each state
- How to use spit (3 colors)
- How to use memory (1 int variable)
- Implement your strategy as a program
- Be prepared to make changes
- Report your progress
- Test and refine your program
- Turn in final program
Due Today
Due Next Class
Due Next Tuesday _at_ midnight
8Example Error Messages
- expected
- cannot find symbol - method Move()
- turn(int) in Creature cannot be applied to
(int,int) - turn(int) in Creature cannot be applied to
(double) - act() in Greep cannot override act() in Creature
attempting to use incompatible return type