|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.sdr.calls.Evaluator
public abstract class Evaluator
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 Evaluator
s operate, they accumulate dancer movements
and actions in a DanceState
.
js> importPackage(net.cscott.sdr.calls.ast); 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 = AstNode.valueOf("(Seq (Apply (Expr _square start 'HEAD)))"); (Seq (Apply (Expr _square start 'HEAD))) js> e = new Evaluator.Standard(comp); undefined js> e.evaluateAll(ds); js> Breather.breathe(ds.currentFormation()).toStringDiagram("|"); |4B> 3Gv 3Bv 2G< | |4G> 1B^ 1G^ 2B<
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 (Expr anyone while others 'HEAD 'pair off 'nothing)) js> comp = new net.cscott.sdr.calls.ast.Seq(comp); (Seq (Apply (Expr anyone while others 'HEAD 'pair off 'nothing))) js> e = new Evaluator.Standard(comp); undefined js> e.evaluateAll(ds); js> Breather.breathe(ds.currentFormation()).toStringDiagram("|"); |4B> 3G< 3B> 2G< | |4G> 1B< 1G> 2B<
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.FOUR_SQUARE); undefined; js> ds.currentFormation().toStringDiagram("|"); |3Gv 3Bv | |1B^ 1G^ js> Evaluator.parseAndEval(ds, "boys walk girls dodge"); js> ds.currentFormation().toStringDiagram("|"); |1B^ 3Gv | |1G^ 3Bv js> Evaluator.parseAndEval(ds, "girls walk others dodge"); js> ds.currentFormation().toStringDiagram("|"); |1G^ 1B^ | |3Bv 3Gv js> Evaluator.parseAndEval(ds, "trade", "roll"); js> ds.currentFormation().toStringDiagram("|"); |1B> 1G< | |3G> 3B<
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.FOUR_SQUARE); undefined; js> ds.currentFormation().toStringDiagram("|"); |3Gv 3Bv | |1B^ 1G^ js> Evaluator.parseAndEval(ds, "square thru three and a half"); js> ds.currentFormation().toStringDiagram("|"); |3G< | |3B> | |1B< | |1G>
js> ds = new DanceState(new DanceProgram(Program.A1), Formation.SQUARED_SET); undefined; js> Evaluator.parseAndEval(ds, "heads pair off; do half of a pass thru"); js> ds = ds.cloneAndClear(); undefined js> ds.currentFormation().toStringDiagram("|"); |4B> 3B> | |3G< 2G< | |4G> 1G> | |1B< 2B< js> Evaluator.parseAndEval(ds, "fan the top") js> ds.currentFormation().toStringDiagram("|"); |1B^ 4Gv 3G^ 4Bv 2B^ 1Gv 2G^ 3Bv js> ds.movements(StandardDancer.COUPLE_1_BOY) [DancerPath[from=-1,-3,w,to=-6,-4,nw,[ROLL_RIGHT, SWEEP_LEFT],time=2,pointOfRotation=FOUR_DANCERS], DancerPath[from=-6,-4,nw,[ROLL_RIGHT, SWEEP_LEFT],to=-7,0,n,[ROLL_RIGHT, SWEEP_LEFT],time=2,pointOfRotation=FOUR_DANCERS]] js> ds.movements(StandardDancer.COUPLE_4_GIRL) [DancerPath[from=-1,-1,e,to=-1,0,n,[ROLL_LEFT, SWEEP_RIGHT],time=1 1/3,pointOfRotation=FOUR_DANCERS], DancerPath[from=-1,0,n,[ROLL_LEFT, SWEEP_RIGHT],to=-2,0,nw,[ROLL_LEFT, SWEEP_RIGHT],time=2/3,pointOfRotation=FOUR_DANCERS], DancerPath[from=-2,0,nw,[ROLL_LEFT, SWEEP_RIGHT],to=-3,1,w,[ROLL_LEFT, SWEEP_RIGHT],time=2/3,pointOfRotation=FOUR_DANCERS], DancerPath[from=-3,1,w,[ROLL_LEFT, SWEEP_RIGHT],to=-5,0,s,[ROLL_LEFT, SWEEP_RIGHT],time=1 1/3,pointOfRotation=FOUR_DANCERS]]
js> ds = new DanceState(new DanceProgram(Program.BASIC), Formation.FOUR_SQUARE); undefined; js> Evaluator.parseAndEval(ds, "pass thru") js> ds.currentFormation().toStringDiagram("|"); |1B^ 1G^ | |3Gv 3Bv js> ds.movements(StandardDancer.COUPLE_1_BOY) [DancerPath[from=-1,-1,n,to=-3,0,n,time=1,pointOfRotation=<null>], DancerPath[from=-3,0,n,to=-1,1,n,time=1,pointOfRotation=<null>]] js> ds.movements(StandardDancer.COUPLE_3_GIRL) [DancerPath[from=-1,1,s,to=-1,0,s,time=1,pointOfRotation=<null>], DancerPath[from=-1,0,s,to=-1,-1,s,time=1,pointOfRotation=<null>]]
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 | |
---|---|
static Evaluator |
breathedEval(Formation f,
Comp c)
Create an evaluator which breathes each formation to resolve collisions. |
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)
|
boolean |
hasSimpleExpansion()
Return true iff this Evaluator simply evaluates an Ast tree. |
static void |
parseAndEval(DanceState ds,
String... calls)
Convenience method for easy testing. |
Comp |
simpleExpansion()
Returns the equivalent simple expansion of the call, if it has one. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Evaluator()
Method Detail |
---|
public abstract Evaluator evaluate(DanceState ds)
Evaluator
which will do the remaining parts, or null if there are no
additional parts to evaluate.
ds
- The dynamic dance state. Accumulates dancer actions and
movements and tracks static dance information like the level of the
dance.
Evaluator
for the remaining parts, or null.public boolean hasSimpleExpansion()
public Comp simpleExpansion()
IllegalArgumentException
- if hasSimpleExpansion()
is
false.public String toString()
toString
in class Object
public final void evaluateAll(DanceState ds)
public static void parseAndEval(DanceState ds, String... calls)
public static Evaluator breathedEval(Formation f, Comp c)
|
sdr 0.7 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |