Search Results for

    Show / Hide Table of Contents

    Class SubroutineTest2Particle

    Tests the subroutine mechanism by electing a leader on every boundary of the system independently.

    Runs 3 instances of the synchronized leader election subroutine in parallel, using a global circuit for synchronization. All particles participate in the leader election but only boundary particles start as candidates. Each boundary forms an election circuit

    Inheritance
    object
    ParticleAlgorithm
    SubroutineTest2Particle
    Namespace: AS2.Algos.SubroutineTest2
    Assembly: .dll
    Syntax
    public class SubroutineTest2Particle : ParticleAlgorithm

    Constructors

    | Edit this page View Source

    SubroutineTest2Particle(Particle)

    Declaration
    public SubroutineTest2Particle(Particle p)
    Parameters
    Type Name Description
    Particle p

    Fields

    | Edit this page View Source

    boundaries

    Declaration
    private ParticleAttribute<int>[,] boundaries
    Field Value
    Type Description
    ParticleAttribute<int>[,]
    | Edit this page View Source

    candidateColors

    Declaration
    public static readonly Color[] candidateColors
    Field Value
    Type Description
    Color[]
    | Edit this page View Source

    finished

    Declaration
    private ParticleAttribute<bool> finished
    Field Value
    Type Description
    ParticleAttribute<bool>
    | Edit this page View Source

    kappa

    Declaration
    private ParticleAttribute<int> kappa
    Field Value
    Type Description
    ParticleAttribute<int>
    | Edit this page View Source

    numBoundaries

    Declaration
    private ParticleAttribute<int> numBoundaries
    Field Value
    Type Description
    ParticleAttribute<int>
    | Edit this page View Source

    partitionSetDistance

    Declaration
    public static readonly float partitionSetDistance
    Field Value
    Type Description
    float
    | Edit this page View Source

    phase2CandidateColors

    Declaration
    public static readonly Color[] phase2CandidateColors
    Field Value
    Type Description
    Color[]
    | Edit this page View Source

    round

    Declaration
    private ParticleAttribute<int> round
    Field Value
    Type Description
    ParticleAttribute<int>
    | Edit this page View Source

    subLEs

    Declaration
    private SubLeaderElectionSync[] subLEs
    Field Value
    Type Description
    SubLeaderElectionSync[]

    Properties

    | Edit this page View Source

    GenerationMethod

    Declaration
    public static string GenerationMethod { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Name

    Declaration
    public static string Name { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    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
    Type Description
    int
    Overrides
    ParticleAlgorithm.PinsPerEdge

    Methods

    | Edit this page View Source

    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
    ParticleAlgorithm.ActivateBeep()
    | Edit this page View Source

    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
    ParticleAlgorithm.ActivateMove()
    | Edit this page View Source

    FindBoundaries()

    Helper that detects all boundaries in the first round.

    Declaration
    private bool FindBoundaries()
    Returns
    Type Description
    bool

    true if and only if we are not the only particle in the system.

    | Edit this page View Source

    Init(int)

    Declaration
    public void Init(int kappa = 3)
    Parameters
    Type Name Description
    int kappa
    | Edit this page View Source

    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
    ParticleAlgorithm.IsFinished()
    | Edit this page View Source

    SetupPinConfiguration(PinConfiguration)

    Sets up the boundary pin configuration by connecting the predecessor and successor using the pins closest to that boundary. Partition set IDs are the boundary indices.

    Declaration
    private void SetupPinConfiguration(PinConfiguration pc)
    Parameters
    Type Name Description
    PinConfiguration pc

    The pin configuration to be changed.

    | Edit this page View Source

    UpdateColor()

    Updates the particle's color based on its candidacies. Leaders and candidates are green, being brighter the more leaderships/candidacies they have. Phase 2 candidates are shades of blue, again depending on how many candidacies they have. Inner particles turn black when the leader election is finished.

    Declaration
    private void UpdateColor()
    • Edit this page
    • View Source
    In this article
    Back to top AmoebotSim 2.0 Documentation v1.11
    Copyright © 2025 AmoebotSim 2.0 Authors
    Generated by DocFX