package stoppers; import java.lang.*; import java.io.*; import main.BetterTokenizer; import main.Cell; import main.GeneralInput; import main.Model; public class SimpleStop extends Object { float lastTime, stopTime; float score = 0, cumScore = 0; Model model; float Cutoff = 0; // No arg constructor for instantiating by name public SimpleStop() { stopTime = 1; } public SimpleStop(float stop_time) { stopTime = stop_time; } public void init(Model model) { this.model = model; } public void initCells() {} // set model initial conditions to what this stopper wants. override this for each stopper public void setCutoff(float c) { Cutoff = c; } public float getScore() { return score; } /* prototype methods that are overridden in FPStripeStop */ public float computeStripeScore() { return 0f; } public void setEvaluating(boolean emode) { } public float getHowStable() { return 100f; } public boolean didPass() { if(score < Cutoff) return true; else return false; } public boolean didPass(float s) { if(s < Cutoff) return true; else return false; } public void reset() { score = 0f; cumScore=0f; lastTime=0f; } public float getStopTime() { return stopTime; } public void setStopTime(float newtime) { stopTime = newtime; } public boolean stop(float time) { if(time >= stopTime) return true; else return false; } public void loadParameters(BetterTokenizer tokenizer) throws Exception { GeneralInput.indent++; String info = GeneralInput.findNextIDToken(tokenizer); while(!info.equals("endStopper")) { loadParameter(info, tokenizer); info = GeneralInput.findNextIDToken(tokenizer); } GeneralInput.indent--; } protected void loadParameter(String info, BetterTokenizer tokenizer) throws Exception { if(info.equals("StopTime")) {GeneralInput.nextToken(tokenizer); stopTime = (float)tokenizer.nval; } else if(info.equals("Cutoff")) { GeneralInput.nextToken(tokenizer); Cutoff = (float)tokenizer.nval; } else System.out.println("Unrecognized token <" + info + "> while loading stopper"); } /** This function is called when a cam file is being set up. See ModelIterator for more information. */ public void saveOutputTags(PrintWriter ps, String inset) { ps.println(inset + "&Score\tnumber"); } /** This function is called to save information to a cam file. See ModelIterator for more information. */ public void saveOutput(PrintWriter ps, String inset) { ps.println(inset + "&Score\t" + score); } }