import finch.Finch; public abstract class FinchMetaAbstract extends FinchAction { protected FinchData finchData; protected String filter; protected String filterTerminal; protected double scaleFactor; protected double minScale; protected int conditionType; protected int loopType; // Constants used to specify the conditional type public static final int conditionAll = 0; public static final int conditionNoObstacle = 1; public static final int conditionLeftObstacle = 2; public static final int conditionRightObstacle = 3; public static final int conditionBothObstacle = 4; public static final int conditionLevel = 5; public static final int conditionBeakUp = 6; public static final int conditionBeakDown = 7; public static final int conditionUpsideDown = 8; // Array of strings containing the names of the conditions public static final String[] conditionTypes = new String[]{"All", "No Obstacle", "Left Obstacle", "Right Obstacle", "Both Obstacle", "Level", "Beak Up", "Beak Down", "Upside Down"}; // Constants used to define the loop type public static final int loopIf = 0; public static final int loopNotIf = 1; public static final int loopWhile = 2; public static final int loopNotWhile = 3; // Array of strings containing the names of the loop types public static final String[] loopTypes = new String[]{"If", "If Not", "While", "While Not"}; /** * Meta-action constructor * * @param name Action name * @param priority Action priority * @param finchData A reference to the FinchData object * @param filter A name filter used to define the actions in the master * action list that are executed when this meta action is executed * @param filterTerminal A name filter used to define the actions in the master * action list that are executed when this meta action is in a terminal state * @param conditionType Type of conditional used to decide whether the "filter" * are to be executed * @param loopType Type of looping structure used for this meta action * @param scaleFactor The scale factor determines how much smaller the * individual "filter" and "filterTerminal" actions are when they are executed * @param minScale The scale at which we have reached the terminal condition */ public FinchMetaAbstract(String name, int priority, FinchData finchData, String filter, String filterTerminal, int conditionType, int loopType, double scaleFactor, double minScale) { super(name, priority); this.finchData = finchData; this.filter = filter; this.filterTerminal = filterTerminal; this.conditionType = conditionType; this.loopType = loopType; this.scaleFactor = scaleFactor; this.minScale = minScale; } /** * Filter Accessor * * @return String describing the action name to be executed from the master list */ public String getFilter(){ return(filter); } /** * Terminal filter accessor * * @return String describing the action name to be executed from the master list * when the terminal state is reached. * */ public String getFilterTerminal(){ return(filterTerminal); } /** * Condition type accessor * * @return An integer representing the condition type */ public int getConditionType(){ return(conditionType); } /** * Loop type accessor * * @return An integer representing the loop type * */ public int getLoopType(){ return(loopType); } /** * Scale factor accessor * * @return A double ([0..1]) that is the scale factor used in the recursive step * */ public double getScaleFactor(){ return(scaleFactor); } /** * Minimum scale accessor * * @return A double ([0 ..1]) that represents the cut-off scale for the * terminal condition */ public double getMinScale(){ return(minScale); } /** * Given the specified condition Type and loop Type, determine whether the * condition is met. * * @param myFinch A reference to the Finch object * @param conditionType A description of the condition type (determines the * test to be performed with the Finch). * @param loopType A description of the type of loop that is being executed * (of relevance here is whether the condition is NOT'ed) * @return A boolean that is true if the condition is met and false otherwise. * * TODO:implement */ protected abstract boolean testCondition(Finch myFinch, int conditionType, int loopType); /** * Execute the meta action. *