80 likes | 386 Views
Greeps. A programming Competition. Greeps. Description Greeps Scenario (a .zip file) Project 1 : modify the Greeps class to increase your score in the competition On-line hint Greeps.java. Methods Provided. Creature class. Actor class getIntersectingObjects
E N D
Greeps A programming Competition
Greeps • Description • Greeps Scenario (a .zip file) • Project 1: modify the Greeps class to increase your score in the competition • On-line hint • Greeps.java
Methods Provided Creature class Actor class getIntersectingObjects (java.lang.Class cls) getOneIntersectingObject (java.lang.Class cls) getRotation() getWorld() getX() getY() setLocation(int x, int y) setRotation(int rotation … 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() Greep class act() checkFood() getAuthorName()
Turning public void act () { turn (5); }
Where 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 (????); }
Possible 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 water’s edge • Turn? • Move? • Leave a trail? • Follow a trail? • 2) At world’s edge • Turn? • Move? • Leave a trail? • Follow a trail? • At ship (after dropping tomatoes) • Turn? • Move? • Leave a trail? • Follow a trail?
What 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 @ midnight
Example 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