Presentation is loading. Please wait.

Presentation is loading. Please wait.

Greeps A programming Competition. Greeps Description Greeps Scenario (a.zip file) Project 1: modify the Greeps class to increase your score in the competition.

Similar presentations


Presentation on theme: "Greeps A programming Competition. Greeps Description Greeps Scenario (a.zip file) Project 1: modify the Greeps class to increase your score in the competition."— Presentation transcript:

1 Greeps A programming Competition

2 Greeps Description Greeps Scenario (a.zip file) Project 1: modify the Greeps class to increase your score in the competition Project 1 On-line hint Greeps.java

3 Methods Provided Greep class act() checkFoodcheckFood() getAuthorNamegetAuthorName() Actor class getIntersectingObjects (java.lang.Class cls) getOneIntersectingObject (java.lang.Class cls) getRotationgetRotation() getWorldgetWorld() getXgetX() getYgetY() setLocationsetLocation(int x, int y) setRotationsetRotation(int rotation … atShipatShip() atWateratWater() atWorldEdgeatWorldEdge() carryingTomatocarryingTomato() dropTomatodropTomato() getFlaggetFlag(int flagNo) getMemorygetMemory() loadTomatoloadTomato() movemove() randomChancerandomChance(int percent) removeTomatoremoveTomato() seePaintseePaint(java.lang.String color) setFlagsetFlag(int flagNo, boolean val) setMemorysetMemory(int val) spitspit(java.lang.String color) turnturn(int angle) turnHometurnHome() Creature class

4 Turning public void act () { turn (5); }

5 Where the action is: act () Current plan if (carryingTomato()) { if(atShip()) { dropTomato(); } else { turnHome(); move(); } else { move(); checkFood(); } Possible problems reaching the world boundary reaching water Possible changes if(atWater() || atWorldEdge()) { turn (????); }

6 Possible States and Strategies With Respect to the Tomatoes 1)Holding a tomato Go home (and leave a trail?) 2)Not holding nor near a tomato Search for tomatoes (follow a trail?) 3)At a pile of tomatoes Wait there until they are gone? With Respect to obstacles/location 1)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? 3)At ship (after dropping tomatoes) Turn? Move? Leave a trail? Follow a trail?

7 What To Do 1.Devise a strategy – What to do in each state – How to use “spit” (3 colors) – How to use memory (1 int variable) 2.Implement your strategy as a program – Be prepared to make changes – Report your progress 3.Test and refine your program – Turn in final program Due Today Due Next Class Due Next Tuesday @ midnight

8 Example Error Messages 1.‘;’ expected 2.cannot find symbol - method Move() 3.turn(int) in Creature cannot be applied to (int,int) 4.turn(int) in Creature cannot be applied to (double) 5.act() in Greep cannot override act() in Creature; attempting to use incompatible return type


Download ppt "Greeps A programming Competition. Greeps Description Greeps Scenario (a.zip file) Project 1: modify the Greeps class to increase your score in the competition."

Similar presentations


Ads by Google