sdr 0.5

net.cscott.sdr.calls.transform
Class Evaluator

java.lang.Object
  extended by net.cscott.sdr.calls.transform.Evaluator
Direct Known Subclasses:
BasicList.LRMEvaluator, Evaluator.EvaluatorChain, Evaluator.Standard

public abstract class Evaluator
extends Object

An Evaluator represents a current dance context. Evaluators are usually stacked: the standard evaluator might call down into a child evaluator for the "tandem" concept, for example, which will then reinvoke the standard evaluator to evaluate "trade". Evaluators keep a continuation context, since each call to evaluate(net.cscott.sdr.calls.DanceState) does only "one part" of a call — the remaining parts go in the continuation.

As the Evaluators operate, they accumulate dancer movements and actions in a DanceState.

Author:
C. Scott Ananian
Tests:
Simplest invocation: "heads start" from squared set.
js> importPackage(net.cscott.sdr.calls);
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined;
js> ds.currentFormation().toStringDiagram("|");
|     3Gv  3Bv
|
|4B>            2G<
|
|4G>            2B<
|
|     1B^  1G^
js> comp = CallDB.INSTANCE.parse(ds.dance.program, "heads start");
(Apply heads start)
js> comp = new net.cscott.sdr.calls.ast.Seq(comp);
(Seq (Apply heads start))
js> e = new Evaluator.Standard(comp);
net.cscott.sdr.calls.transform.Evaluator$Standard@166cb16
js> e.evaluateAll(ds);
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|4B>  3Gv  3Bv  2G<
|
|4G>  1B^  1G^  2B<
"Heads pair off" from squared set -- this is a bit of a hack, it should eventually be "heads start, heads (pair off)" or some such.
js> importPackage(net.cscott.sdr.calls);
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined;
js> ds.currentFormation().toStringDiagram("|");
|     3Gv  3Bv
|
|4B>            2G<
|
|4G>            2B<
|
|     1B^  1G^
js> comp = CallDB.INSTANCE.parse(ds.dance.program, "heads pair off");
(Apply heads pair off)
js> comp = new net.cscott.sdr.calls.ast.Seq(comp);
(Seq (Apply heads pair off))
js> e = new Evaluator.Standard(comp);
net.cscott.sdr.calls.transform.Evaluator$Standard@166cb16
js> e.evaluateAll(ds);
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|4B>  3G<  3B>  2G<
|
|4G>  1B<  1G>  2B<
More complex calls from facing couples.
js> importPackage(net.cscott.sdr.calls);
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.FOUR_SQUARE); undefined;
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|3Gv  3Bv
|
|1B^  1G^
js> Evaluator.parseAndEval(ds, "boys walk girls dodge");
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|1B^  3Gv
|
|1G^  3Bv
js> Evaluator.parseAndEval(ds, "girls walk others dodge");
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|1G^  1B^
|
|3Bv  3Gv
js> Evaluator.parseAndEval(ds, "trade", "roll");
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|1B>  1G<
|
|3G>  3B<
Recursive evaluation with fractionalization, left concept, breathing, etc:
js> importPackage(net.cscott.sdr.calls);
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.FOUR_SQUARE); undefined;
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|3Gv  3Bv
|
|1B^  1G^
js> Evaluator.parseAndEval(ds, "square thru three and a half");
js> Breather.breathe(ds.currentFormation()).toStringDiagram("|");
|3G<
|
|3B>
|
|1B<
|
|1G>

Nested Class Summary
static class Evaluator.EvaluatorChain
          Chains multiple evaluators together.
static class Evaluator.Standard
          This is the standard top level evaluator.
 
Constructor Summary
Evaluator()
           
 
Method Summary
abstract  Evaluator evaluate(DanceState ds)
          Do "one part" of the continuation, and return an Evaluator which will do the remaining parts, or null if there are no additional parts to evaluate.
 void evaluateAll(DanceState ds)
           
static void parseAndEval(DanceState ds, String... calls)
          Convenience method for easy testing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Evaluator

public Evaluator()
Method Detail

evaluate

public abstract Evaluator evaluate(DanceState ds)
Do "one part" of the continuation, and return an Evaluator which will do the remaining parts, or null if there are no additional parts to evaluate.

Parameters:
ds - The dynamic dance state. Accumulates dancer actions and movements and tracks static dance information like the level of the dance.
Returns:
An Evaluator for the remaining parts, or null.

evaluateAll

public final void evaluateAll(DanceState ds)

parseAndEval

public static void parseAndEval(DanceState ds,
                                String... calls)
Convenience method for easy testing.


sdr 0.5

Copyright © 2006-2009 C. Scott Ananian