Class ChiralityAndCompassParticle
Implementation of the chirality agreement and compass alignment
algorithms described in https://arxiv.org/abs/2105.05071v1.
Both chirality and compasses can be random at initialization.
Both phases use the following basic procedure:
-
Find out which neighbors agree with the particle's chirality/compass direction
and setup the pin configuration to contain all of these neighbors in one
partition set. This establishes the regional circuit.
-
Beep on the regional circuit if there is a neighbor particle that does not have
the same chirality/compass direction. If no particle has beeped in this round,
there is only one region and the algorithm can terminate.
-
Let all candidates in the region perform a coin toss. All particles in the
region observe the result, which can be HEADS, TAILS, or FAILED.
If the result is FAILED, all candidates that tossed TAILS withdraw their
candidacy. All boundary particles send the coin toss result to their neighbors
that are not part of the region.
-
Regions merge as follows: A region that tossed TAILS tries to merge into
a neighboring region that has tossed anything other than TAILS. The
boundary particles beep in reserved rounds if their neighboring region is
a candidate for a merge. If a candidate exists, the first round in which a
beep was sent determines how the merge can be performed. If no beeps are
sent, no neighbor region was eligible and the next iteration starts. If
a merge is performed, all candidates in the region withdraw.
The algorithm is split into 7 individual rounds per iteration for the
chirality agreement phase and 11 rounds per iteration for the compass
alignment phase.
Inheritance
ChiralityAndCompassParticle
Assembly: .dll
Syntax
public class ChiralityAndCompassParticle : ParticleAlgorithm
Constructors
ChiralityAndCompassParticle(Particle)
Declaration
public ChiralityAndCompassParticle(Particle p)
Parameters
Fields
beepedForHeads
Declaration
private ParticleAttribute<bool> beepedForHeads
Field Value
chir0CandColor
Declaration
private static readonly Color chir0CandColor
Field Value
chir0CircuitColor
Declaration
private static readonly Color chir0CircuitColor
Field Value
chir0NoCandColor
Declaration
private static readonly Color chir0NoCandColor
Field Value
chir1CandColor
Declaration
private static readonly Color chir1CandColor
Field Value
chir1CircuitColor
Declaration
private static readonly Color chir1CircuitColor
Field Value
chir1NoCandColor
Declaration
private static readonly Color chir1NoCandColor
Field Value
chiralityAgreementPhase
Declaration
private ParticleAttribute<bool> chiralityAgreementPhase
Field Value
coinTossResult
Declaration
public ParticleAttribute<CoinTossResult> coinTossResult
Field Value
compCandColors
Declaration
private static readonly Color[] compCandColors
Field Value
compNoCandColor
Declaration
private static readonly Color[] compNoCandColor
Field Value
compassOffset
Declaration
private ParticleAttribute<Direction> compassOffset
Field Value
finished
Declaration
private ParticleAttribute<bool> finished
Field Value
firstActivation
Declaration
private ParticleAttribute<bool> firstActivation
Field Value
hasRegionalCircuit
Declaration
private ParticleAttribute<bool> hasRegionalCircuit
Field Value
heads
Declaration
private ParticleAttribute<bool> heads
Field Value
isCandidate
Declaration
private ParticleAttribute<bool> isCandidate
Field Value
mergeOffset
Declaration
private ParticleAttribute<int> mergeOffset
Field Value
nbrOffsets
Declaration
private ParticleAttribute<int>[] nbrOffsets
Field Value
nbrs
Declaration
private ParticleAttribute<bool>[] nbrs
Field Value
realChirality
Declaration
public ParticleAttribute<bool> realChirality
Field Value
realCompassDir
Declaration
public ParticleAttribute<Direction> realCompassDir
Field Value
reverseChirality
Declaration
private ParticleAttribute<bool> reverseChirality
Field Value
round
Declaration
private ParticleAttribute<int> round
Field Value
Properties
GenerationMethod
Declaration
public static string GenerationMethod { get; }
Property Value
Name
Declaration
public static string Name { get; }
Property Value
PinsPerEdge
The number of pins on each edge.
This number must be the same constant for all
particles.
Declaration
public override int PinsPerEdge { get; }
Property Value
Overrides
Methods
Activate0()
Declaration
Activate1()
Declaration
Activate10()
Declaration
private void Activate10()
Activate2()
Declaration
Activate3()
Declaration
Activate4()
Declaration
Activate5()
Declaration
Activate6()
Declaration
Activate7To9()
Declaration
private void Activate7To9()
ActivateBeep()
This is the second part of the main activation logic of the
particle. It is called exactly once in each round, after the
movements scheduled in ActivateMove() have been
executed, and should contain the algorithm code that
implements the look-compute-beep cycle.
Inside of this method, particles are allowed to change their
pin configuration and send beeps and messages on the updated
configuration.
Note that beeps and messages sent in the current round will
be readable in both the ActivateMove() and
ActivateBeep() calls in the next round.
Declaration
public override void ActivateBeep()
Overrides
ActivateMove()
This is one part of the main activation logic of the particle.
It is called exactly once in each round and should contain the
algorithm code that implements the look-compute-move cycle.
After the movements are executed, ActivateBeep()
is called within the same round.
Inside of this method, particles are allowed to release bonds,
define which bonds should be marked, and schedule movements.
Only the last movement operation scheduled in this method will
be applied.
Declaration
public override void ActivateMove()
Overrides
CompassAlignmentUpdateMergeBeep(int)
Declaration
private void CompassAlignmentUpdateMergeBeep(int offset)
Parameters
Type |
Name |
Description |
int |
offset |
|
Init(bool, Direction)
Declaration
public void Init(bool realChirality, Direction realCompassDir)
Parameters
Type |
Name |
Description |
bool |
realChirality |
|
Direction |
realCompassDir |
|
IsFinished()
Checks whether this particle has finished its algorithm.
Override this method to return true
when a particle
is done executing the algorithm. Once all particles in the
system are finished, the simulation will stop automatically.
When a particle's state results in this method returning
true
, its activation methods should not change its
state any more.
Declaration
public override bool IsFinished()
Returns
Type |
Description |
bool |
true if and only if this particle has
finished its algorithm.
|
Overrides
SetColor()
Declaration
ToNewDir(Direction)
Translates the given original local direction
into the corresponding direction in the new
system according to the current compass offset
and chirality.
Declaration
private Direction ToNewDir(Direction dir)
Parameters
Type |
Name |
Description |
Direction |
dir |
The original local direction
to be translated.
|
Returns
Type |
Description |
Direction |
The new local direction that corresponds
to the given original direction
dir with the current compass
offset and chirality inversion applied.
|
TossCoin()
Declaration
Returns