Behavior.java
1 package pep; 2 3 import hlt.*; 4 5 /** 6 * A behavior defines how a ship will behave given a particular game state 7 */ 8 public abstract class Behavior { 9 10 enum Type { 11 DEPOSITOR, HARVESTER, SCRUBBER, SCOUT, BLOCKER 12 } 13 14 /** 15 * @param currentBehavior The current behavior of this ship 16 * @return @return True if this ship meets the criteria to take on this behavior 17 */ 18 public abstract boolean meetsCriteria(Ship ship, Type currentBehavior, Game game); 19 20 /** 21 * @return The target position for this ship 22 */ 23 public abstract Position getTarget(Ship ship, Game game); 24 25 /** 26 * @return The type enum of this behavior 27 */ 28 public abstract Type getType(); 29 30 /** 31 * @return True if this behavior seeks low movement cost 32 */ 33 public abstract boolean minimizesCost(); 34 35 @Override 36 public String toString(){ 37 Type type = getType(); 38 if (type == Behavior.Type.HARVESTER){ 39 return "HARVESTER"; 40 } else if (type == Behavior.Type.DEPOSITOR){ 41 return "DEPOSITOR"; 42 } else if(type == Behavior.Type.SCRUBBER){ 43 return "SCRUBBER"; 44 } else if (type == Behavior.Type.SCOUT) { 45 return "SCOUT"; 46 } else if (type == Behavior.Type.BLOCKER) { 47 return "BLOCKER"; 48 } 49 return "NONE"; 50 } 51 }