Definitions
SquareDanceReasoning.COUPLE_DISTANCE
— ConstantCOUPLE_DISTANCE is the distance between (the center reference points of) two dancers standing side by side, face to face, or back to back.
SquareDanceReasoning.FORMATION_ROLES
— ConstantFORMATION_ROLES maps SquareDanceFormations to Roles.
SquareDanceReasoning.FULL_CIRCLE
— ConstantFULL_CIRCLE represents a change in direction of 360 degrees.
SquareDanceReasoning.ROLE_FORMATIONS
— ConstantROLE_FORMATIONS maps from a Role to the formations that can identify it.
SquareDanceReasoning.AllPresent
— TypeAllPresent(::SDSquare)
AllPresent
is a fact that is asserted to the knowledgebase by SDSquareHasAttendanceRule
when all of the Dancer
s in an SDSquare
are present.
It can be used as a trigger for rules that depend on all Dancer
s having an associated DancerState
.
SquareDanceReasoning.AndRoll
— TypeAndRoll(; role=EveryOne())
CallerLab Plus call.
Timing: CallerLab: 2.
SquareDanceReasoning.Attendance
— TypeAttendance(::SDSquare)
Attendance
is a fact in the knowledgebase that keeps track of how many DancerState
s in a square are present.
This is necessary because tests like encroached_on
can only provide a correct result if all of the DanecerState
s are available for consideration.
When all of the Dancer
s of s set have DancerState
s, then Attendance
emits an AllPresent
fact.
Note that Attendance
contains mutable data - but once an Attendance
is created, only the values in its present
field are changed.
SquareDanceReasoning.AttendanceRule
— TypeAttendanceRule
AttendanceRule is the rule that updates an Attendance as new DancerState
s are asserted to the knowledgebase, and ultimately asserts AllPresent
.
SquareDanceReasoning.BackToBack
— TypeBackToBack represents a formation of two dancers with their backs facing each other.
SquareDanceReasoning.BackToBackCouples
— TypeBackToBackCouples is a formation that includes two Couple
formations that have their backs to each other.
SquareDanceReasoning.BackToBackCouplesRule
— TypeBackToBackCouplesRule is the rule for identifying the BackToBackCouples formation.
SquareDanceReasoning.Balance
— TypeBalance(; role=Everyone(), time=2)
Implements the Balance square dance call, except that dancers just jiggle in place. Maybe it should be renamed _Identify.
SquareDanceReasoning.BeforeEightChain
— TypeBeforeEightChain is a formation of eight dancers (four couples) lined up, and is the starting formation for the "eight chain thru" call. It can result from doing "centers pass thru" from a FacingTandemCouples formation.
→←→←
→←→←
SquareDanceReasoning.BeforeEightChainRule
— TypeBeforeEightChainRule is the rule for recognizing BeforeEightChain formations.
SquareDanceReasoning.BeforeTradeBy
— TypeBeforeTradeBy is a formation of eight dancers (four couples) lined up, and is the starting formation for the call "trade by". It can result from doing a "centers pass thru" from a BeforeEightChain formation.
←→←→
←→←→
SquareDanceReasoning.BeforeTradeByRule
— TypeBeforeTradeByRule is the rule for recognizing BeforeTradeBy formations.
SquareDanceReasoning.Bounds
— TypeBounds(dss::Vector{DancerState};
margin = COUPLE_DISTANCE / 2)
represents the bounding rectangle surrounding the specified DancerState
s. If margin
is 0 then Bounds surrounds just the centers of the dancers.
By default, margin
is COUPLE_DISTANCE / 2
so that Bounds describes the space actually occupied by the dancers.
SquareDanceReasoning.BoxOfFour
— TypeBoxOfFour is the abstract supertype for RHBoxOfFour and LHBoxOfFour.
SquareDanceReasoning.BoxOfFourRule
— TypeBoxOfFourRule is the rule for identifying right or left handed "box circulate" formations.
SquareDanceReasoning.CSSKeyframesAnimation
— TypeCSSKeyfraneomesAnimation
As the method argument to animate
, uses the CSS keyframes to animte SVG.
In my, and others's experience, can't get rotation to work.
SquareDanceReasoning.CallEngineDebugContext
— TypeCallEngineDebugContext(source_location, relpath, token)
A CallEngineDebugContext can be passed to some functions via the dbgctx
keyword argument to provide debugging support.
Do not use the constructor directly, instead use @CallEngineDebugContext
, which will automatically provide a source location.
SquareDanceReasoning.CallSchedule
— TypeCallSchedule(start_time)
CallSchedule maintains the schedule of the ScheduledCall
s that are to be performed. The results of expand_parts
are added to the schedule while calls are being executed. The call engine (see do_schedule
) runs until the schedule is empty.
SquareDanceReasoning.CanDoCall
— TypeCanDoCall(preference, call::SquareDanceCall, formation::SquareDanceFormation)
CanDoCall represents that call
can be performed from formation
, and doing so has the specified preference.
SquareDanceReasoning.CatchConflictingDancerStates
— TypeCatchConflictingDancerStates
Throws an error if there are two different DancerState
s that concern the same Dancer.
SquareDanceReasoning.CircleOfEight
— TypeCircleOfEight represents eight dancers in a circle facing inward.
SquareDanceReasoning.CircleOfEightFormationRule
— TypeCircleOfEightFormationRule is the rule for recognizing eight dancers in a circle: CircleOfEight
.
SquareDanceReasoning.Collision
— TypeCollision notes that two dancers are occupying the same space.
SquareDanceReasoning.ColumnOfFour
— TypeColumnOfFour(lead::Tandem, tail::Tandem, centers::Tandem)
Represents a column of four dancers, each facing the back of the dancer in front of them.
SquareDanceReasoning.ColumnOfFourRule
— TypeColumnOfFourRule is the rule for identifying ColumnOfFour
formations.
SquareDanceReasoning.CompletedDoublePassThru
— TypeCompletedDoublePassThru is a formation of eight dancers (four couples) lined up, and is the ending formation for the call "double pass thru". It can result from doing a "centers pass thru" from a TradeBy formation.
←←→→
←←→→
SquareDanceReasoning.CompletedDoublePassThruRule
— TypeCompletedDoublePassThruRule is the rule for rtecognizing CompletedDoublePassThru formations.
SquareDanceReasoning.Couple
— TypeCouple(beau::DancerState, belle::DancerState)
Couple represents a formation of two dancers both facing the same direction.
SquareDanceReasoning.CourtesyTurn
— TypeCourtesyTurn(; role=Everyone())
CallerLab Basic-1 call.
Timing: CallerLab: 4.
SquareDanceReasoning.Dancer
— TypeDancer(couple_number::Int, ::Gender)
Dancer represents a dancer.
SquareDanceReasoning.DancerState
— TypeDancerState(dancer, time, direction, down, left)
DancerState(previoous::DancerSTate, time, direction, down, left)
represents the location and facing direction of a single dancer at a moment in time.
time
is a number defining a temporal ordering. It could represent a number of beats, for example.
DancerState is also the single dancer SquareDanceFormation
.
SquareDanceReasoning.DancerStatesNotNewestException
— TypeDancerStatesNotNewestException
An exception which can be signaled by the call engine if the DancerStates being considered for a call are not the newest DancerStates for their Dancers.
SquareDanceReasoning.Dosado
— TypeDosado(; role=Everyone(), handedness=RightHanded())
CallerLab Basic1 call.
Timing: Callerlab: 6, unless coming from and returnuing to a squared set, in which case 8.
SquareDanceReasoning.DotBackend
— TypeDotBackend(directory, title)
Provides a subtype of ContainmentGraphBackend that uses GraphViz Dot.
SquareDanceReasoning.EightDancerFormation
— TypeEightDancerFormation is the abstract supertype of all square dance formations involving eight dancers.
SquareDanceReasoning.FaceLeft
— TypeFaceLeft(; role=Everyone(), time=2)
CallerLab Basic 1 square dance call causing dancers to turn 1/4 to their left. The timing defaults to 2 since, according to Taminations, two beats is the duration for QuarterIn and QuarterOut.
Timing: CallerLab does not soecify timing. Assume 1. Can be specified as a parameter.
SquareDanceReasoning.FaceRight
— TypeFaceRight(; role=Everyone(), time=2)
CallerLab Basic 1 square dance call causing dancers to turn 1/4 to their right. The timing defaults to 2 since, according to Taminations, two beats is the duration for QuarterIn and QuarterOut.
Timing: CallerLab does not soecify timing. Assume 1. Can be specified as a parameter.
SquareDanceReasoning.FaceToFace
— TypeFaceToFace represents a formation of two dancers facing each other.
SquareDanceReasoning.FacingCouples
— TypeFacingCouples is a formation that includes two Couple
formations that are facing each other.
SquareDanceReasoning.FacingCouplesRule
— TypeFacingCouplesRule is the rule for identifying the FacingCouples formation.
SquareDanceReasoning.FacingTandemCouples
— TypeFacingTandemCouples is a formation of eight dancers (four couples) lined up, and is the starting formation for the "double pass thru" call. This formation is more commonly known as "Double Pass Thru".
→→←←
→→←←
SquareDanceReasoning.FacingTandemCouplesRule
— TypeFacingTandemCouplesRule is the rule for recognizing the FacingTandemCouples formation.
SquareDanceReasoning.FormationContainedIn
— TypeFormationContainedIn(contained, container)
A fact in the knowledgebase that says that contained
is a sub-formation of container
.
SquareDanceReasoning.FormationContextRole
— TypeFormationContextRole
is the abstract supertype for square dance roles which are defined by a dancer's context in a particular formation.
SquareDanceReasoning.FourDancerFormation
— TypeFourDancerFormation is the abstract supertype of all square dance formations involving four dancers.
SquareDanceReasoning.Gal
— TypeGal()
The gal gender, represented by a circle in our SVG diagrams.
SquareDanceReasoning.Gender
— TypeGender represents the gender of a dancer, which might be Guy, Gal or Unspecified.
Unspecified
exists for when we want to emphasize gender agnosticism in a diagram.
Gender equality: Guy() == Guy()
, Gal() == Gal()
, otherwise not equal.
Use opposite
to get the opposite gender.
SquareDanceReasoning.Guy
— TypeGuy()
The guy gender, represented by a square in our SVG diagrams.
SquareDanceReasoning.Handedness
— TypeHandedness
square dance formations have a handedness, one of RightHanded(), LeftHanded() or NoHandedness().
opposite
of a handedness returns the other handedness. NoHandednessis its own opposite.
SquareDanceReasoning.Hinge
— TypeHinge(; role=Everyone(), tile=2)
CallerLab Mainstream call.
Timing: CallerLab: 2.
SquareDanceReasoning.InvertedLineOfFour
— TypeInvertedLineOfFour represents an inverted line of four formation with a Couple in the center connecting two MiniWaves.
SquareDanceReasoning.InvertedLineOfFourRule
— TypeInvertedLineOfFourRule is the rule for identifying InvertedLineOfFour
formations.
SquareDanceReasoning.LHBoxOfFour
— TypeLHBoxOfFour represents a left handed "box circulate" formation.
SquareDanceReasoning.LHMiniWave
— TypeLHMiniWave represents a left handed wave of two dancers.
SquareDanceReasoning.LHWaveOfEight
— TypeLHWaveOfEight represents a right handed wave of eight dancers.
SquareDanceReasoning.LHWaveOfFour
— TypeLHWaveOfFour represents a left handed wave of four dancers.
SquareDanceReasoning.LineOfFour
— TypeLineOfFour represents a line of four dancerrs all facing in the same direction.
SquareDanceReasoning.LineOfFourRule
— TypeLineOfFourRule is the rule for iderntifying a LineOfFour
formation.
SquareDanceReasoning.MiniWave
— TypeMiniWave is the abstract supertype for all two dancer waves.
SquareDanceReasoning.NQuarterTag
— TypeNQuarterTag is the abstract supertype for QuarterTag and ThreeQuarterTag formations.
SquareDanceReasoning.NoCallOptionsForCall
— TypeNoCallOptionsForCall
An exception which can be signalled by the call engine when get_call_options
can't identify any formations from which a call can be performed.
SquareDanceReasoning.ObverseRole
— TypeObverseRole(::role)
For roles like CoupleNumbers or DesignatedDancers we can't determine the obverse until we know all of the dancers involved. This serves as a "place holder" until we can determine which dancers have the role that is obverse to the specified Role
.
SquareDanceReasoning.OneByFourFormation
— TypeOneByFourFormation is the abstract supertype for 1 by 4 "lines". Concrete supertypes are expected to have a centers
field.
SquareDanceReasoning.OriginalPartnerRule
— TypeOriginalPartnerRule is a rule that identifies the original partners of a square dance set.
SquareDanceReasoning.OriginalPartners
— TypeOriginalPartners(guy::Dancer, gal::Dancer)
OriginalPartners is a fact in the knowledge base that identifies the original partners in a square.
SquareDanceReasoning.PartnerHinge
— TypePartnerHinge(; role=Everyone(), tile=2)
CallerLab Advanced-1 call.
Timing: CallerLab: 2.
SquareDanceReasoning.PassThru
— TypePassThru(; role=Everyone())
CallerLab Basic 1 call.
Timing: CallerLab: 2.
PassThru
is only proper from FaceToFace
or from RHMiniWave
(because of the "Ocean Wave Rule"). For LHMiniWave
, use StepThru
.
SquareDanceReasoning.PullBy
— TypePullBy(; role=Everyone(), handedness=RightHanded())
CallerLab Basic 1 call.
Timing: CallerLab doesn't specify timing, but since the timing for PassThru
is 2, assume the same for PullBy
.
SquareDanceReasoning.PureSVGAnimation
— TypePureSVGAnimation
As the method argument to animate
, use pure SVG animate
animation. Various sources suggest that SVG animate
is deprecated, but it works.
SquareDanceReasoning.QTWCT
— TypeQTWCT is an intermediate result to sypport the rules for recognizing QuarterTag and ThreeQuarterTag.
SquareDanceReasoning.QTWCTRule
— TypeQTWCTRule is a rule that provides a precursor fact for QuarterTagRule and ThreeQuarterTagRule.
SquareDanceReasoning.QuarterIn
— TypeQuarterIn(; role=Everyone())
CalllerLab Advanced 1 call.
Timing: CallerLab: 2.
SquareDanceReasoning.QuarterOut
— TypeQuarterOut(; role=Everyone())
CalllerLab Advanced 1 call.
Timing: CallerLab: 2.
SquareDanceReasoning.QuarterTag
— TypeQuarterTag represents a quarter tag formation.
SquareDanceReasoning.QuarterTagRule
— TypeQuarterTagRule is the rule for identifying QuarterTag
formations.
SquareDanceReasoning.RHBoxOfFour
— TypeRHBoxOfFour represents a right handed "box circulate" formation.
SquareDanceReasoning.RHMiniWave
— TypeRHMiniWave represents a right handed wave of two dancers.
SquareDanceReasoning.RHWaveOfEight
— TypeRHWaveOfEight represents a right handed wave of eight dancers.
SquareDanceReasoning.RHWaveOfFour
— TypeRHWaveOfFour represents a right handed wave of four dancers.
SquareDanceReasoning.Respirator
— TypeRespirator(::Vector{DancerState))
Respirator is a device for assisting breating. It performs the bookkeeping associed with tracking the current location of each dancer as adjusted by the breathing algorithm without creating new DancerState
s.
SquareDanceReasoning.Role
— TypeRole
is the abstract supertype for all square dance role types.
SquareDanceReasoning.SDRKnowledgeBase
— TypeSDRKnowledgeBase(label)
The type for the root node of our knowledgebase.
SquareDanceReasoning.SDSquare
— TypeSDSquare(dancers)
SDSquare represents the dancers in a square.
make_square(number_of_couples)
will return an SDSquare
.
SDSquare is a fact that can be asserted to the knowledge base to inform it that the dancers form a square.
other_dancers(::SDSquare, dancers)
returns the set of Dancer
s that are in the SDSquare but are not in dancers
.
SquareDanceReasoning.SDSquareHasAttendanceRule
— TypeSquareDanceFormationRule
A rule that ensures that there is an Attendance
fact for every SDSquare
fact.
SquareDanceReasoning.ScheduledCall
— TypeScheduledCall(when, ::SquareDanceCall)
ScheduledCall associates a SquareDanceCall
with the time it should be performed.
SquareDanceReasoning.SlideThru
— TypeSlideThru(; role=Everyone())
CallerLab Mainstream call.
Timing: CallerLab: 4.
SquareDanceReasoning.SquareDanceCall
— TypeSquareDanceCall
For each call, a struct is defined that is a subtype of SquareDanceCall
.
For each call and each formation it can be done from, a can_do_from
method should be defined. If the "Ocean Wave Rule" applies, then a can_do_from
method should be defined for that case.
For each call and each formation it can be performed from, either a perform
or an expand_parts
method should be defined.
SquareDanceReasoning.SquareDanceFormation
— TypeSquareDanceFormation is the abstract supertype of all square dance formations.
Each concrete subtype can be callled to get an iterator over all of the DancerState
s of the formation.
SquareDanceReasoning.SquareDanceFormationRule
— TypeSquareDanceFormationRule
the group for all rules relating to square dance formations.
SquareDanceReasoning.SquareDanceRule
— TypeSquareDanceRule is the abstract supertype for all rules defined in this package.
SquareDanceReasoning.SquareHasDancers
— TypeSquareHasDancers is a convenience rule for asserting the Dancer
s from a SDSquare
.
SquareDanceReasoning.SquareThru
— TypeSquareThru(; role, handedness, count)
CallerLab Basic 1 square dance call.
Timing: count=1: 2, count=2: 5, count=3: 7 or 8, count=4: 10.
SquareDanceReasoning.SquaredSet
— TypeSquaredSet(couples1::FacingCouples, couples2::FacingCouples)
SquaredSet represents a squared set of eight dancers.
SquareDanceReasoning.SquaredSetFormationRule
— TypeSquaredSetFormationRule is the rule for identifying a SquaredSet
.
SquareDanceReasoning.Star
— TypeStar represents four dancers holding either right or left hands together in their center. All are facing either clockwise or counterclockwise.
SquareDanceReasoning.StarRule
— TypeStarRule is the rule for recognizing right or left handed stars.
SquareDanceReasoning.StarThru
— TypeStarThru(; role=Everyone())
CallerLab Basic-1 call.
Timing: CallerLab: 4.
SquareDanceReasoning.StepThru
— TypeStepThru(; role=Everyone())
CallerLab Basic 1 square dance call that goes from MiniWave to BackToBack.
Timing: CallerLab doesn't spoecify a timing, but since the specified timing for PassThru
is 2 and StepThru
must be simpler, assume 1.
SquareDanceReasoning.StepToAWave
— TypeStepToAWave(; role=Everyone(), handedness=RightHanded())
CallerLab Basic 2 square dance call that goes from FaceToFace to a MiniWave of the specified handedness. The first half of PassThru
.
Timing: 2.
SquareDanceReasoning.Tandem
— TypeTandem(leaderLLDancerState, trailer::DancerState)
Tandem repreents a formation of two dancers where the trailer
is facing the back of the leader
.
SquareDanceReasoning.TandemCouples
— TypeTandemCouples is a formation for two Couples in Tandem.
SquareDanceReasoning.TandemCouplesRule
— TypeTandemCouplesRule is the rule for identifying the TandemCouples formation.
SquareDanceReasoning.TemporalFact
— TypeTemporalFact
Abstract supertype for any facts that have a temporal dependence.
SquareDanceReasoning.ThreeQuarterTag
— TypeThreeQuarterTag represents a three quarter tag formation.
SquareDanceReasoning.ThreeQuarterTagRule
— TypeThreeQuarterTagRule is the rule for identifying ThreeQuarterTag
formations.
SquareDanceReasoning.TimeBounds
— TypeTimeBounds()
Returns an empty TimeBounds interval.
SquareDanceReasoning.Trade
— TypeTrade(; role=Everyone(), time=2)
CallerLab Basic call.
Timing: CallerLab: MiniWave: 3, Couple: 4
SquareDanceReasoning.TwoDancerFormation
— TypeTwoDancerFormation is the abstract supertype of all square dance formations involving two dancers.
SquareDanceReasoning.TwoDancerFormationsRule
— TypeTwoDancerFormationsRule
TwoDancerFormationsRule is the rule for identifying all two dancer formations: Couple
, FaceToFace
, BackToBack
, Tandem
, RHMiniWave
, and LHMiniWave
.
SquareDanceReasoning.TwoDifferentCouples
— TypeTwoDifferentCouples
TwoDifferentCouples is a preliminary fact that supports the rules for finding FacingCouples, BackToBackCouples and TandemCouples.
SquareDanceReasoning.TwoFacedLine
— TypeTwoFacedLine represents a two faced line formation.
SquareDanceReasoning.TwoFacedLineRule
— TypeTwoFacedLineRule is the rule for identifying TwoFacedLine
formations.
SquareDanceReasoning.UTurnBack
— TypeUTurnBack(; role=Everyone())
CallerLab Basic1 call.
Timing: CallerLab: 2.
SquareDanceReasoning.UniversalRole
— TypeUniversalRole
is the abstract type for those roles which might apply regardless of what formation the daners are in.
SquareDanceReasoning.Unspecified
— TypeUnspecified
Unspecified gender is provided just for gender neutral diagraming, where it appears as a square with rounded corners. It is not supported widely through this codebase. For example original partner and original corner are do not support it.
Note that
Unspecified() != Unspecified()
and
opposite(Unspecified())
returns Unspecified()
.
SquareDanceReasoning.UnsynchronizedDancersException
— TypeUnsynchronizedDancersException
An exception which can be signaled by the call engine if the relevant DancerStates are not symchronized to one another.
SquareDanceReasoning.WaveOfEight
— TypeWaveOfEight is the abstract supertype for right and left handed waves of eight dancers.
SquareDanceReasoning.WaveOfEightRule
— TypeWaveOfEightRule is the rule for identifying waves of eight dancers: RHWaveOfEight
and LHWaveOfEight
.
SquareDanceReasoning.WaveOfFour
— TypeWaveOfFour is the abstract supertype for right and left handed waves of four dancers.
SquareDanceReasoning.WaveOfFourRule
— TypeWaveOfFourRule is the rule for identifying waves of four dancers: RHWaveOfFour
and LHWaveOfFour
.
SquareDanceReasoning._BackToAWave
— Type_BackToAWave(; role=Everyone(), handedness=RightHanded())
Primitive square dance call that goes from BackToBack to a MiniWave of the specified handedness. The third quarter of Dosado
.
Timing: 1.
SquareDanceReasoning._EndAt
— Type_EndAt(f::TwoDancerFormation, time=0, swap=true)
Primitive square dance call that causes the dancer to end at the starting location of the other dancer.
If swap
is false
then the dancer ends in its own starting location instead of that of the other dancer.
SquareDanceReasoning._FaceOriginalCorner
— Type_FaceOriginalCorner(; role=Everyone(), time=0)
Primitive square dance call which causes a dancer to face its original corner.
Timing: as specified in the parameter.
SquareDanceReasoning._FaceOriginalPartner
— Type_FaceOriginalPartner(; role=Everyone(), time=0)
Primitive square dance call which causes a dancer to face its original partner.
Timing: as specified in the parameter.
SquareDanceReasoning._FinishTrade
— Type_FinishTrade(; role=Everyone, time=2)
a primitive call that represents the second half of Trade
from a [Couple
](@ref).
SquareDanceReasoning._GenderedRoll
— Type_GenderedRoll(; role=Everyone(), time=2)
The second part of calls like StarThru and SlideThru. Guy turn one quarter to the right, Gal turn one quarter to the left.
Timing: as specified in the parameter. Defaults to 2. CallerLab says the timing for StarThru is 4, so thisseems reasonable.
SquareDanceReasoning._Meet
— Type_Meet(; role=Everyone(), duration=0)
Facing dancers move forward until they are close together.
Consider a call like PassThru where the dancers might be close together or some distance apart (like in a squared set). PassThru uses _EndAt to put the dancers in each others previous locations. What if we want the Heads of a squared set to end up in the middle. We have the dancers _Meet first.
SquareDanceReasoning._Rest
— Type_Rest(; role=Everyone(), time)
Primitive square dance call causing dancers to rest in place for the specified time.
Timing: as specified in the parameter.
SquareDanceReasoning._UnStepToAWave
— Type_UnStepToAWave(; role=Everyone())
Primitive square dance call that goes from a MiniWave to FaceToFace. The first half of PassThru
.
Timing: 2. Persimably should have the same timing as StepToAWave
Base.isless
— MethodBase.isless(::Dancer, ::Dancer)::Bool
Provides a total ordering for dancers.
SquareDanceReasoning.advance_schedule_by
— Methodadvance_schedule_by(sched::CallSchedule, delta)
Move every entry in the schedule forward by delta
.
SquareDanceReasoning.animate
— Methodanimate(method::AnimationMethod, output_file, dancer_states; bpm=40)
Returns an SVG document fragment that animates the motion of the Dancer
s in dancer_states
.
If output_file
ends in ".svg" then the document fragment is written to that file. output_file
is still needed so that the relative path to the dancer symbols file canbe determined.
dancer_states
should have the most recent DancerState
for each Dancer
. the previous
property of each DancerState
is used to determine the Dancer
's motion.
bpm
or "beats per minute" provides a time scale for the animation. Assuming each unit of time
in a DancerState
is a single beat, bpm
is used to calculate the total duration of one cycle through the animation.
SquareDanceReasoning.apply_motion
— Methodapply_motion(rsp::Respirator, movement::Dict{Dancer, Vector})
Update rsp
to reflect the Dancer movement specified in movement
.
SquareDanceReasoning.as_text
— Functionas_text(call)
Return a textual description of the call as a String.
SquareDanceReasoning.back_to_a_wave
— Methodback_to_a_wave(f::BackToBack, time_delta, h::Union{RightHanded, LeftHanded})::FaceToFace
The back to back dancers back up to firm a miniwave of the specified handedness.
Breating should be done separately.
SquareDanceReasoning.backward
— Methodbackward(ds::DancerState, distance, time_delta)::DancerState
Move the Dancer
identified by ds
backward (based on ds.direction) the specified distance by returning a new dancer state.
SquareDanceReasoning.behind
— Methodbehind(focus::DancerState, other::DancerState)::Bool
returns true if other
is behind focus
.
SquareDanceReasoning.breathe
— Methodbreathe(playmates::Vector{<:TwoDancerFormation}, everyone::Vector{DancerState})::Vector{DancerState}
Moves the dancers apart such that those that have collided no longer overlap.
playmates
is used to inform what direction colliders should be moved in such that playmates are not separated.
everyone
includes all DancerStates that are to be affected.
SquareDanceReasoning.bump_out
— Methodbump_out(bounds::Bounds, amount)
Returns a new Bounds object that is expanded at each edge by amount
.
SquareDanceReasoning.bump_out
— Methodbump_out(bounds::Bounds)
Returns a new Bounds object that is expanded by COUPLE_DISTANCE / 2
on each edge so that instead of encompassing the centers of each Dancer
it encompasses whole dancers.
SquareDanceReasoning.call_schedule_isless
— Methodcall_schedule_isless(call1::ScqareDanceCall, call2::SquareDanceCall)
We need some way to control the scheduleing order of zero duration calls like _EndAt.
This is kind of a kludge but I've not thought of anything better.
SquareDanceReasoning.can_do_from
— Methodcandofrom(::SquareDanceCall, ::SquareDanceFormation)::Int
Determins if the specified call can be performed from the specified formation. A return value of 0 means the call is not appropriate (or not currently supported). Otherwise the return value is a preference level with a higher value indicating more preferable. For example UTurnBack from Couple is more preferable to UTurnBack from DancerState, even though both would be applicable.
SquareDanceReasoning.can_roll
— Methodcan_roll(ds::DancerState)
Determine whether the modifier "and roll" can be applied to the DancerState. If the dancer can roll then can_roll
returns a signed rotation value.
This is not useful for "and roll as if you could".
SquareDanceReasoning.canonicalize
— Methodcanonicalize(direction)
canonicalizes the direction to be between 0 and 1.
SquareDanceReasoning.canonicalize_signed
— Methodcanonicalize_signed(direction)
canonicalizes the direction to be between -1//2 and 1//2.
SquareDanceReasoning.center
— Methodcenter(dss)
returns the center of the specified DancerState
s as a two element Vector of down and left coordinates.
SquareDanceReasoning.collateral_file_relpath
— Methodcollateral_file_relpath(resource_name, html_file_destination)
Returns the path to the named resource in the environment of html_file_destination
.
resource_name
is one of the keys of HTML_COLLATERAL_FILES
.
html_file_destination
is the absolute path of the XML or HTML file that is referring to the resource.
SquareDanceReasoning.collisions
— Methodcollisions(::Respirator)
Returns an iterator over the current collisions in the Respirator
.
SquareDanceReasoning.containment_graph
— Methodcontainment_graph(kb::SDRKnowledgeBase, title, backend::ContainmentGraphBackend)
Visualizes the containment graph for the formations in kb
.
title
is a title for the graph. It might be used as the base of a file name.
backend
says how to visualize the graph.
SquareDanceReasoning.copy_html_collateral_files
— Methodcopy_html_collateral_files()
Copies each of the files identified in HTMLCOLLATERALFILES to each of the directories listed in TARGET_LOCATIONS.
SquareDanceReasoning writes XML and HTML files to various locations. Some of those locations are only accessible in certain circumstances. For example, The package source code hierarchy is not available to documentation foles delivered to the gh-pages branch. copy_html_collateral_files
copies the files to where they might be needed. collateral_file_relpath
is used to file the most appropriate
Use collateral_file_relpath
to get the best reference location for a resource file.
SquareDanceReasoning.corner_couple_number
— Methodcorner_couple_number(::Dancer)
Returns the couple number of the dancer's corner. Since this function has no way of knowing the number of daners in the "square", the value returned nmight require numeric rapping.
SquareDanceReasoning.current_location
— Methodcurrent_location(r::Respirator, d::Dancer)
returns the current location of the Dancer
as recorded in the Respirator
.
SquareDanceReasoning.dancer_state_roles
— Methoddancer_state_roles(formation::SquareDanceFormatio)::AbstractDict{DancerState, Set{Role}}
Returns a dictionary mapping DancerState
to a list of Role
s that the DancerState
holds in the specified formation
.
SquareDanceReasoning.dancer_states
— Methoddancer_states(formation)::Vector{DancerState}
Returns a list of the DancerState
s in the formation, in no particular order.
SquareDanceReasoning.direction
— Functiondirection(formation)
If all of the dancers of formation are facing in the same direction then return that direction. Otherwise get a no such method error.
SquareDanceReasoning.direction
— Methoddirection(focus, other)
returns the absolute direction that other
is from the point of view of focus
. Either argument can be a DancerState or a localtion represented as a two element Vector.
SquareDanceReasoning.distance
— Methoddistance(p1, p2)
returns the distance between the two points represented by vectors.
SquareDanceReasoning.do_call
— Methoddo_call(kb::SDRKnowledgeBase, call::SquareDanceCall; dbgctx = nothing)::SDRKnowledgeBase
Perform the specified square dance call and return an updated knowledgebase. do_call
is the entry point into the call engine.
SquareDanceReasoning.dotescape
— Methoddotescape(::AbstractString)::AbstractString
Escape an ID
in the GraphViz Dot language. 'ID' is the fundamental token in Dot.
SquareDanceReasoning.earliest
— Methodearliest(ds::DancerState)
Returns the earliest DancerState in the specified DancerState
's previous
chain.
SquareDanceReasoning.elt
— Methodelt(f, tagname::AbstractString, things...)
elt(tagname::AbstractString, things...)
Return an XML element. f
is called with a single argument: either an XML.AbstractXMLNode or a Pair describing an XML attribute to be added to the resulting element.
SquareDanceReasoning.encroached_on
— Methodencroached_on(formations, kb)
Returns true if any of the other contemporary DancerState
s in the knowledge base are within the Bounds
of the specified formations
.
SquareDanceReasoning.expand
— Methodexpand(bounds::Bounds, ::DancerState)::Bounds
bounds
is modified to encompass the additional DancerState
.
SquareDanceReasoning.expand
— Methodexpand(tb::TimeBounds, ds::DancerState)::TimeBounds
expands tb
to encompass the time of the specified DancerState
s.
SquareDanceReasoning.expand_parts
— Methodexpand_parts(::SquareDanceCall, ::SquareDanceFormation, ::ScheduledCall)
Returns either the ScheduledCall itself, if it has no expansion, or a vector of a ScheduledCall
for each part.
The ScheduledCall
's when
field is the starting time for the call. The pats in the expansion can have their times offset from that.
SquareDanceReasoning.find_collisions
— Methodfind_collisions(dss::Vector{DancerState})::Vector{Collision}
Find the DancerState
s that have collided with each other.
SquareDanceReasoning.fixed
— Methodfixed(x)
truncates ludicrously small floating point numbers.
SquareDanceReasoning.formation_svg
— Methodformation_svg(f::SquareDanceFormation, symbol_uri_base; id=nothing)
Returns an SVG element that illustrates the formation.
symbol_uri_base
is a relative URL to the SVG symbols file. See collateral_file_relpath
.
If id
is specified, it will be the XML Id of the drawing.
If margin is specified, its the additional space that surrounds the formation.
SquareDanceReasoning.forward
— Methodforward(ds::DancerState, distance, time_delta)::DancerState
Move the Dancer
identified by ds
forward (based on ds.direction) the specified distance by returning a new dancer state.
SquareDanceReasoning.fraction
— Methodfraction(tb::TimeBounds, t)
return where t
falls within tb
as a fraction. For t == tb.min
the result would be 0. For t == tb.max
the result would be 100.
SquareDanceReasoning.grid_arrangement
— Method grid_arrangement(dancers::Vector{Dancer}, dancer_indices::Array{<:Integer, 2}, dancer_directions::Array{Rational, 2})
Returns a two dimensional array of DancerState
s such that the dancers are arranged in a rectangular grid of the specified dimensions.
dancers
is a vector of Dancer
s indexed by dancer_indices
. A dancer index can be 0 to indicate that there is no dancer in that positriion.
dancer_indices
and dancer_directions
are Arrays of the same dimensions. This determiines the dimensions of the resulting grid.
Alternatively, dancer_directions can be a Vector of strings of the Unicode arrow characters ←, ↑, →, or ↓, with the space character serving as a placeholder where there is no dancer.
The two indices of each array correspond to the down
and left
coordinates respectively.
SquareDanceReasoning.handedness
— Functionhandedness(formation)
returns the handedness of a square dance formation: one of RightHanded(), LeftHanded() or NoHandedness()
SquareDanceReasoning.history
— Methodhistory(f, ds::DancerState)
Calls f on ds
and all of its previous
DancerStates in chronological order.
SquareDanceReasoning.in_bounds
— Methodin_bounds(bounds::Bounds, ds::DancerState)::Bool
Returns true if the specified DancerState it located within bounds
.
in_bounds(Bounds([ds]), ds) == true
SquareDanceReasoning.in_front_of
— Methodin_front_of(focus::DancerState, other::DancerState)::Bool
returns true if other
is in front of focus
.
SquareDanceReasoning.is_original_head
— Methodis_original_head(::Dancer)::Bool
returns true if the dancer was originally in a head position.
SquareDanceReasoning.is_original_side
— Methodis_original_side(::Dancer)::Bool
returns true if the dancer was originally in a side position.
SquareDanceReasoning.jitter
— Methodjitter(ds::DancerState, time_delta)::DancerState
Adds noise to the position and facing direction of the DancerState. This allows us to test whether our formation recognition rules are sensitive to such noise.
SquareDanceReasoning.latest_dancer_states
— Methodlatest_dancer_states(kb)::Dict{Dancer, DancerState}
Return a Dict that provides the latest DancerState
for each Dancer
.
SquareDanceReasoning.left_of
— Methodleft_of(focus::DancerState, other::DancerState)::Bool
returns true if other
is to the left of focus
.
SquareDanceReasoning.leftward
— Methodleftward(ds::DancerState, distance, time_delta)::DancerState
Move the Dancer
identified by ds
to the left (based on ds.direction) by the specified distance by returning a new dancer state.
SquareDanceReasoning.make_kb
— Methodmake_kb(kb::SDRKnowledgeBase)
Makes a copy of the knowledge base, but without any TemporalFact
s.
SquareDanceReasoning.make_kb
— Methodmake_kb()
Creates SquareDanceReasoning knowledge base with no facts, but with all rules installed.
SquareDanceReasoning.make_showcase_index_file
— Methodmake_showcase_index_file()
Writes an index file for the choreography Showcase docs directory.
SquareDanceReasoning.make_square
— Methodmake_square(number_of_couples::Int)::SDSquare
Returns an SDSquare with the specified number of couples.
SquareDanceReasoning.merge_sorted_iterators
— Methodmerge_sorted_iterators(iters)
Merges the contents of the sorted iterables into a single iterator producing those unique elements in order.
SquareDanceReasoning.motion_for_collision
— Methodmotion_for_collision(rsp::Respirator, collision, movement::Dict{Dancer, Vector})
Compute the motions required to resolve the specified collision and add it to movement
. Does not apply those motions yet. movement
is a Dict mapping Dancer to motion vector.
SquareDanceReasoning.move
— Methodmove(r::Respirator, d::Dancer, down, left)
Applies the relative down
and left
motion to the Dancer
.
SquareDanceReasoning.near
— Methodnear(::DancerState, ::DancerState)
returns true if the two DancerStates are for different dancers and are close enough together (within DANCERNEARDISTANCE).
SquareDanceReasoning.obverse
— Functionobverse(::Role)::Role
Each role has an obverse
role. (I didn't want to overload opposite
). At a given time a dancer either has role
or role
's obverse.
SquareDanceReasoning.opposite
— Methodopposite(direction)
returns the direction opposite to the given one.
SquareDanceReasoning.opposite
— Methodopposite(::Gender)::Gender
Returns the opposite Gender. Unspecified()
is its own opposite.
SquareDanceReasoning.other_dancers
— Methodother_dancers(square::SDSquare, dancers)
Returns the dancers from square
that are not listed in the dancers
argument.
SquareDanceReasoning.pass_by
— Methodpass_by(mw::MiniWave, time_delta)::BackToBack
Dancers in a MiniWave
pass by each other to end BackToBack.
SquareDanceReasoning.percentage
— Methodpercentage(tb::TimeBounds, t)
return where t
falls within tb
as a percentage. For t == tb.min
the result would be 0. For t == tb.max
the result would be 100.
SquareDanceReasoning.perform
— Functionperform(::SquareDanceCall, ::SquareDanceFormation, ::SDRKnowledgeBase)::SquareDanceFormation
Performs the call on the specified formation and returns the new formation.
SquareDanceReasoning.playmate
— Functionplaymate(ds::Dancer, f::TwoDancerFormation)::Union{Nothing, Dancer}
If the Dancer
is part of the formation then return the other Dancer
in the formation, otherwise return nothing
.
SquareDanceReasoning.quarter_left
— Methodquarter_left(direction)
returns the direction that's a quarter turn left from the given direction.
SquareDanceReasoning.quarter_right
— Methodquarter_right(direction)
returns the direction that's a quarter turn right from the given direction.
SquareDanceReasoning.restricted_to
— Methodrestricted_to(call)::Role
Returns the role that call
has been restricted to.
Each subtype of SquareDanceCall must have either a role
field or a restricted_to
method.
SquareDanceReasoning.resultingDancerStates
— MethodresultingDancerStates(rsp::Respirator)
Returns new DancerState
s which have had the computed breathing applied to them.
SquareDanceReasoning.revolve
— Methodrevolve(ds::DancerState, center, new_direction, time_delta)::DancerState
Revolves the Dancer
identified by ds
around center
(a two element Vector of down
and left
coordinates) until the Dancer
's new facing direction is new_direction
. A new DancerState
is returned. time_delta
is the duration of the revolution operation.
SquareDanceReasoning.right_of
— Methodright_of(focus::DancerState, other::DancerState)::Bool
returns true if other
is to the right of focus
.
SquareDanceReasoning.rightward
— Methodrightward(ds::DancerState, distance, time_delta)::DancerState
Move the Dancer
identified by ds
to the right (based on ds.direction) by the specified distance by returning a new dancer state.
SquareDanceReasoning.rotate
— Methodrotate(ds::DancerState, rotation, time_delta)::DancerState
Rotates the dancer idntified by the DancerState
in place by rotation.
SquareDanceReasoning.schedule
— Methodschedule(sched::CallSchedule, call::SquareDanceCall, at)
Enters call
into sched
so that it will be performed at the specified time at
.
SquareDanceReasoning.show_formation_containment
— Methodshow_formation_containment(kb::SDRKnowledgeBase)
For debugging, show the memory of the FormationContainedInMemoryNode.
SquareDanceReasoning.showcase
— Methodshowcase(filename::String, title::String, initial_kb, choreography::Vector{SquareDanceCall}; inhibit_call_engine_logging = true; dbgctx = nothing)
Writes a markdown file named filename
in the choreography Showcase documentation directory.
title
is the title string for the document.
initial_kb
is the knowledgebase containing the formations that choreography
starts from.
choreography
is a vector of the calls to be performed.
If inhibit_call_engine_logging
is true then teh usual call engine logging will be suppressed.
If provided, dbgctx
should be a CallEngineDebugContext
.
SquareDanceReasoning.square_up
— Methodsquare_up(dancers; initial_time = 0)
returns a list of DancerState
s for the initial squared set.
SquareDanceReasoning.step_to_a_wave
— Methodstep_to_a_wave(f::FaceToFace, time_delta, h::Handedness)::MiniWave
The face to face dancers move up to make a right or left handed miniwave.
Breating should be done separately.
SquareDanceReasoning.supported_roles
— Methodsupported_roles(formation)
Returns a list of the Role
s that are supported by formation
.
SquareDanceReasoning.those_with_role
— Methodthose_with_role(::SquareDanceFormation, ::Role)
For the specified formation, returns DancerState
s whose dancers fill the specified role.
SquareDanceReasoning.timeof
— Methodtimeof(::SquareDanceFormation)
Returns the valuie of the time
field, which should be the same for all DancerSTate
in the formation.
SquareDanceReasoning.un_step_to_a_wave
— Methodun_step_to_a_wave(f::MiniWave, time_delta)::FaceToFace
The face to face dancers move up to make a right or left handed miniwave.
Breating should be done separately.
SquareDanceReasoning.unit_vector
— Methodunit_vector(direction)
Returns a unit vector pointing in direction
, which is specified as a fraction of a full circle.
SquareDanceReasoning.update_from
— Functionupdate_from(formation::SquareDanceFormation, newest::Vector{DancerState})
Return a new formation of the same type as formation
but with its component DancerState
s taken from newest
, matching by Dancer
.
SquareDanceReasoning.@CallEngineDebugContext
— Macro@CallEngineDebugContext(relpath, token)
Creates a CallEngineDebugContext
with an appropriate source locator.