sdr 0.3

net.cscott.sdr.calls
Class GeneralFormationMatcher

java.lang.Object
  extended by net.cscott.sdr.calls.GeneralFormationMatcher

public abstract class GeneralFormationMatcher
extends Object

GeneralFormationMatcher produces a FormationMatch given an input Formation and a goal TaggedFormation. This can be used to make Selectors out of TaggedFormations, via the makeSelector(net.cscott.sdr.calls.TaggedFormation) method.

Author:
C. Scott Ananian

Constructor Summary
GeneralFormationMatcher()
           
 
Method Summary
static FormationMatch doMatch(Formation input, TaggedFormation goal, boolean allowUnmatchedDancers, boolean usePhantoms)
          Attempt to match the input formation against the goal formation; you can have multiple rotated copies of the goal formation in the input.
static Selector makeSelector(TaggedFormation goal)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralFormationMatcher

public GeneralFormationMatcher()
Method Detail

makeSelector

public static Selector makeSelector(TaggedFormation goal)

doMatch

public static FormationMatch doMatch(Formation input,
                                     TaggedFormation goal,
                                     boolean allowUnmatchedDancers,
                                     boolean usePhantoms)
                              throws NoMatchException
Attempt to match the input formation against the goal formation; you can have multiple rotated copies of the goal formation in the input. Allow dancers who are not part of copies of the goal formation if allowUnmatchedDancers is true; allow copies of the goal formation with phantoms in them if usePhantoms is true. Returns the best such match (ie, most copies of the goal formation).

Parameters:
input - An untagged formation to match against.
goal - A tagged goal formation
allowUnmatchedDancers - allow dancers in the input formation not to match dancers in (copies of) the goal
usePhantoms - allow dancers in the goal formation not to match dancers in the input
Returns:
the match result
Throws:
NoMatchException - if there is no way to match the goal formation with the given input
Tests:
A successful match with no phantoms or unmatched dancers:
js> GeneralFormationMatcher.doMatch(Formation.SQUARED_SET,
  >                                 FormationList.COUPLE,
  >                                 false, false)
     AAv

BB>       CC<

     DD^
AA:
   3B^  3G^
 [3B: BEAU; 3G: BELLE]
BB:
   4B^  4G^
 [4B: BEAU; 4G: BELLE]
CC:
   2B^  2G^
 [2B: BEAU; 2G: BELLE]
DD:
   1B^  1G^
 [1B: BEAU; 1G: BELLE]
A successful match with some unmatched dancers:
js> GeneralFormationMatcher.doMatch(FormationList.RH_TWIN_DIAMONDS,
  >                                 FormationList.RH_MINIWAVE,
  >                                 true, false)
AA>  BB>

CC^  DDv

EE<  FF<
AA:
   ^
BB:
   ^
CC:
   ^    v
 [ph: BEAU; ph: BEAU]
DD:
   ^    v
 [ph: BEAU; ph: BEAU]
EE:
   ^
FF:
   ^
When possible, symmetry is preserved in the result:
js> GeneralFormationMatcher.doMatch(FormationList.PARALLEL_RH_WAVES,
  >                                 FormationList.RH_MINIWAVE,
  >                                 false, false)
AA^  BBv

CC^  DDv
AA:
   ^    v
 [ph: BEAU; ph: BEAU]
BB:
   ^    v
 [ph: BEAU; ph: BEAU]
CC:
   ^    v
 [ph: BEAU; ph: BEAU]
DD:
   ^    v
 [ph: BEAU; ph: BEAU]

sdr 0.3

Copyright © 2006-2009 C. Scott Ananian