Show that this resolves from all RH ocean waves, and compute
statistics.
js> importPackage(net.cscott.sdr.calls);
js> // create all possible RH ocean waves (modulo rotation)
js> FormationList = FormationList.js(this); undefined;
js> const SD = StandardDancer;
js> f = FormationList.PARALLEL_RH_WAVES; undefined
js> f = f.mapStd([SD.COUPLE_2_BOY, SD.COUPLE_2_GIRL,
> SD.COUPLE_1_GIRL, SD.COUPLE_1_BOY]
> ); f.toStringDiagram()
2B^ 2Gv 1G^ 1Bv
3B^ 3Gv 4G^ 4Bv
js> fs = [pp.permute(f) for each (pp in Iterator
> (Permutation.generate(Permutation.IDENTITY8)))]; fs.length
96
js> dss = [new DanceState(new DanceProgram(Program.PLUS), f)
> for each (f in fs)]; undefined;
js> // look at first step from each formation
js> s = [DWResolver.resolveStep(ff) for each (ff in fs)]; s.slice(0,5)
Trade,Hinge,Hinge,Acey Deucey,Half Tag
js> // compute number of calls until resolve for each starting formation
js> // we could memoize intermediate results, but we're lazy.
js> function dance(ds, steps, verbose) {
> if (steps > 30) throw new Error("Doesn't resolve!");
> // get next call from current formation
> let nextCall = DWResolver.resolveStep(ds.currentFormation());
> if (verbose) print(nextCall);
> if (nextCall == "Right and Left Grand") return (steps+1);
> net.cscott.sdr.calls.Evaluator.parseAndEval(ds, nextCall);
> // keep dancing.
> return dance(ds, steps+1, verbose);
> }
js> nums = [dance(ds, 0) for each (ds in dss)]; nums.slice(0,5)
2,2,5,4,5
js> // the minimum ought to be one: from some formation, a RLG is possible
js> Math.min.apply(null, nums)
1
js> // and the largest number of calls to resolve is:
js> max = Math.max.apply(null, nums)
8
js> // average:
js> let [sum,count] = [0,0]
js> nums.map(function(e) { sum+=e; count+=1; }); (sum/count).toFixed(2);
4.92
js> // formations which require the maximum number of calls:
js> // (the first here is a 'sides lead right, swing thru 1 1/4,
js> // spin chain and exchange the gears')
js> for (let i=0; i<nums.length; i++)
> if (nums[i]==max) print(i+":\n"+fs[i].toStringDiagram()+"\n");
30:
2B^ 2Gv 1B^ 3Gv
1G^ 3Bv 4G^ 4Bv
45:
3B^ 2Bv 3G^ 4Gv
2G^ 1Gv 4B^ 1Bv
80:
3G^ 2Bv 2G^ 3Bv
1B^ 4Gv 4B^ 1Gv
95:
3G^ 2Gv 2B^ 3Bv
1B^ 4Bv 4G^ 1Gv
js> // emit one of the 'longest resolves'
js> ds = new DanceState(new DanceProgram(Program.PLUS), fs[30]); undefined;
js> dance(ds, 0, true); undefined;
Hinge
Swing Thru
Swing Thru
Acey Deucey
Trade
Swing Thru
Swing Thru
Right and Left Grand