Search Results for

    Show / Hide Table of Contents

    Class ParticleSystem

    Main container for a system of particles in the grid together with the execution logic for simulating rounds.

    Unlike other IReplayHistory implementations, the system will automatically reactivate the tracking state as soon as the marker is set to the latest round.

    Inheritance
    object
    ParticleSystem
    Implements
    IReplayHistory
    Namespace: AS2.Sim
    Assembly: .dll
    Syntax
    public class ParticleSystem : IReplayHistory

    Constructors

    | Edit this page View Source

    ParticleSystem(AmoebotSimulator, RenderSystem)

    Declaration
    public ParticleSystem(AmoebotSimulator sim, RenderSystem renderSystem)
    Parameters
    Type Name Description
    AmoebotSimulator sim
    RenderSystem renderSystem

    Fields

    | Edit this page View Source

    _currentRound

    Declaration
    private int _currentRound
    Field Value
    Type Description
    int
    | Edit this page View Source

    _earliestRound

    Declaration
    private int _earliestRound
    Field Value
    Type Description
    int
    | Edit this page View Source

    _latestRound

    Declaration
    private int _latestRound
    Field Value
    Type Description
    int
    | Edit this page View Source

    _previousRound

    Declaration
    private int _previousRound
    Field Value
    Type Description
    int
    | Edit this page View Source

    anchorIdxHistory

    The history of the anchor particle's index.

    Declaration
    private ValueHistory<int> anchorIdxHistory
    Field Value
    Type Description
    ValueHistory<int>
    | Edit this page View Source

    anchorInit

    The index of the anchor particle selected in initialization mode. -1 means that no anchor has been selected, in which case the first particle on the list will become the anchor.

    Declaration
    private int anchorInit
    Field Value
    Type Description
    int
    | Edit this page View Source

    anchorIsObjectHistory

    The history of the flag telling whether the anchor index refers to an object.

    Declaration
    private ValueHistory<bool> anchorIsObjectHistory
    Field Value
    Type Description
    ValueHistory<bool>
    | Edit this page View Source

    anchorIsObjectInit

    Flag telling whether the anchor index belongs to an object in Init Mode.

    Declaration
    private bool anchorIsObjectInit
    Field Value
    Type Description
    bool
    | Edit this page View Source

    beepFailureProb

    Declaration
    private float beepFailureProb
    Field Value
    Type Description
    float
    | Edit this page View Source

    collisionCheckEnabled

    Indicates whether the collision check should be executed.

    Declaration
    private bool collisionCheckEnabled
    Field Value
    Type Description
    bool
    | Edit this page View Source

    collisionDebugLines

    Declaration
    private CollisionChecker.DebugLine[] collisionDebugLines
    Field Value
    Type Description
    DebugLine[]
    | Edit this page View Source

    edgeMovements

    Declaration
    private List<EdgeMovement> edgeMovements
    Field Value
    Type Description
    List<EdgeMovement>
    | Edit this page View Source

    finished

    true as soon as all particles are finished.

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

    finishedRound

    The first round in which all particles were finished.

    Declaration
    private int finishedRound
    Field Value
    Type Description
    int
    | Edit this page View Source

    inBeepPhase

    true while in the beep phase during round simulation.

    Declaration
    private bool inBeepPhase
    Field Value
    Type Description
    bool
    | Edit this page View Source

    inCollisionState

    true when a collision occurred in the last recorded round.

    Declaration
    private bool inCollisionState
    Field Value
    Type Description
    bool
    | Edit this page View Source

    inInitializationState

    Declaration
    private bool inInitializationState
    Field Value
    Type Description
    bool
    | Edit this page View Source

    inMovePhase

    true while in the move phase during round simulation.

    Declaration
    private bool inMovePhase
    Field Value
    Type Description
    bool
    | Edit this page View Source

    isTracking

    true while tracking the latest simulation round. Useful for IReplayHistory implementation.

    Declaration
    private bool isTracking
    Field Value
    Type Description
    bool
    | Edit this page View Source

    objectMap

    A map of the grid positions of all objects in the simulation. Similar to particleMap.

    Declaration
    private Dictionary<Vector2Int, ParticleObject> objectMap
    Field Value
    Type Description
    Dictionary<Vector2Int, ParticleObject>
    | Edit this page View Source

    objectMapInit

    Declaration
    private Dictionary<Vector2Int, ParticleObject> objectMapInit
    Field Value
    Type Description
    Dictionary<Vector2Int, ParticleObject>
    | Edit this page View Source

    objects

    A list of all objects in the system. Similar to particles.

    Declaration
    private List<ParticleObject> objects
    Field Value
    Type Description
    List<ParticleObject>
    | Edit this page View Source

    objectsInit

    Declaration
    private List<ParticleObject> objectsInit
    Field Value
    Type Description
    List<ParticleObject>
    | Edit this page View Source

    particleMap

    A map of the grid positions of all particles in the simulation.

    The map is updated at the end of each round simulation or when jumping to a round in the history.

    Declaration
    private Dictionary<Vector2Int, Particle> particleMap
    Field Value
    Type Description
    Dictionary<Vector2Int, Particle>
    | Edit this page View Source

    particleMapInit

    Map of InitializationParticle posiitons, similar to particleMap for the initialization mode.

    Declaration
    private Dictionary<Vector2Int, OpenInitParticle> particleMapInit
    Field Value
    Type Description
    Dictionary<Vector2Int, OpenInitParticle>
    | Edit this page View Source

    particles

    A list of all particles in the simulation.

    This list does not change during the simulation.

    Declaration
    public List<Particle> particles
    Field Value
    Type Description
    List<Particle>
    | Edit this page View Source

    particlesInit

    List of InitializationParticles, similar to particles for the initialization mode.

    Declaration
    private List<OpenInitParticle> particlesInit
    Field Value
    Type Description
    List<OpenInitParticle>
    | Edit this page View Source

    renderSystem

    The object responsible for rendering this particle system.

    Declaration
    public RenderSystem renderSystem
    Field Value
    Type Description
    RenderSystem
    | Edit this page View Source

    selectedAlgorithm

    The name of the selected algorithm in initialization mode.

    Declaration
    private string selectedAlgorithm
    Field Value
    Type Description
    string
    | Edit this page View Source

    sim

    The simulator object to which this system belongs.

    Declaration
    public AmoebotSimulator sim
    Field Value
    Type Description
    AmoebotSimulator
    | Edit this page View Source

    storedSimulationRound

    The round we were in when we stored the simulation state.

    Declaration
    private int storedSimulationRound
    Field Value
    Type Description
    int
    | Edit this page View Source

    storedSimulationState

    Is true when we entered initialization mode and saved the previous simulation state.

    Declaration
    private bool storedSimulationState
    Field Value
    Type Description
    bool

    Properties

    | Edit this page View Source

    BeepFailureProb

    The probability of a beep not being received on each partition set of a particle.

    Value is always clamped between 0 and 1.

    Declaration
    public float BeepFailureProb { get; set; }
    Property Value
    Type Description
    float
    | Edit this page View Source

    CollisionCheckEnabled

    Indicates whether the collision check should be executed. Turn the collision check off for improved performance.

    Declaration
    public bool CollisionCheckEnabled { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    CurrentRound

    The current round describing the simulation state.

    Before the first round is simulated, the current round is 0. After each simulated round, this counter is incremented by 1.

    Declaration
    public int CurrentRound { get; private set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    EarliestRound

    The round of the initial configuration before the first simulation round.

    This is assumed to be always 0.

    Declaration
    public int EarliestRound { get; private set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Finished

    true if the simulation has reached a round after which all particles in the system were finished, even if this round lies later in the history than the currently marked round.

    Declaration
    public bool Finished { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    InBeepPhase

    true while the look-compute-beep cycle of a round is being simulated.

    Declaration
    public bool InBeepPhase { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    InCollisionState

    true if a collision has occurred in the last recorded round. The simulation will not proceed until the last round is cut off from the history.

    Declaration
    public bool InCollisionState { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    InInitializationState

    Indicates whether the system is currently in the initialization state. In this state, particles can be added, removed, moved and modified freely and new configurations can be generated.

    In this state, no methods controlling the simulation or the history replay should be called.

    Declaration
    public bool InInitializationState { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    InMovePhase

    true while the look-compute-move cycle of a round is being simulated.

    Declaration
    public bool InMovePhase { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    LatestRound

    The latest round that has been reached through simulation.

    Any simulation state between round 0 and this round can be restored at any time without having to simulate the particles. To proceed to later rounds, the simulation must be continued from this round.

    Declaration
    public int LatestRound { get; private set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    PreviousRound

    The round that was previously simulated.

    While a simulation round is being computed and the particles are being activated, this value will be CurrentRound - 1. Inbetween rounds, CurrentRound and PreviousRound will have the same value.

    Declaration
    public int PreviousRound { get; private set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    SelectedAlgorithm

    The name of the currently selected algorithm in initialization mode.

    Declaration
    public string SelectedAlgorithm { get; }
    Property Value
    Type Description
    string

    Methods

    | Edit this page View Source

    ActivateParticlesBeep()

    Executes the beep activation of each particle.

    Declaration
    private void ActivateParticlesBeep()
    | Edit this page View Source

    ActivateParticlesMove()

    Executes the movement activations of all particles in the system and prepares the particles for the joint movement computation.

    The final bonds of each particle are computed by their global positions and adjusted based on the scheduled movement. Additionally, it is determined whether the head of the particle is its local origin and the local movement offset is calculated. The global offset of the particles is reset to (0, 0).

    Declaration
    private bool ActivateParticlesMove()
    Returns
    Type Description
    bool

    true if any particle has scheduled a movement or released a bond (object bonds count as well).

    | Edit this page View Source

    AddInitParticle(Vector2Int, bool, Direction, Direction)

    General method for adding particles to the system in initialization mode.

    Declaration
    public InitializationParticle AddInitParticle(Vector2Int tailPos, bool chirality, Direction compassDir, Direction headDirection = Direction.NONE)
    Parameters
    Type Name Description
    Vector2Int tailPos

    The grid position of the particle's tail.

    bool chirality

    The chirality of the particle. true means counter-clockwise and false means clockwise.

    Direction compassDir

    The compass direction of the particle. This is the global direction that corresponds to the particle's local E direction.

    Direction headDirection

    The global direction pointing from the particle's tail towards its head. Set to NONE to make the particle contracted.

    Returns
    Type Description
    InitializationParticle

    The newly added particle or null if the particle could not be added.

    | Edit this page View Source

    AddNewObject(Vector2Int)

    Creates a new object and adds it to the system in Init Mode.

    The object is registered in the render system and should push updates to the particle system (i.e., whenever positions are added or removed or the object is moved).

    Declaration
    public ParticleObject AddNewObject(Vector2Int position)
    Parameters
    Type Name Description
    Vector2Int position

    The initial position of the new object.

    Returns
    Type Description
    ParticleObject

    The newly created object, if it was created successfully, otherwise null.

    | Edit this page View Source

    AddObject(ParticleObject)

    Adds an object to the system in Init Mode.

    The object is registered in the render system and should push updates to the particle system (i.e., whenever positions are added or removed or the object is moved).

    Declaration
    public void AddObject(ParticleObject o)
    Parameters
    Type Name Description
    ParticleObject o

    The object to be added.

    | Edit this page View Source

    AddParticleContracted(Vector2Int, Chirality, Compass)

    Adds a contracted particle at the given position when in initialization mode.

    Declaration
    public void AddParticleContracted(Vector2Int gridPos, Initialization.Chirality chirality = Chirality.CounterClockwise, Initialization.Compass compassDir = Compass.E)
    Parameters
    Type Name Description
    Vector2Int gridPos

    The grid position where the particle should be placed.

    Initialization.Chirality chirality

    The current chirality setting.

    Initialization.Compass compassDir

    The current compass direction setting.

    | Edit this page View Source

    AddParticleExpanded(Vector2Int, Vector2Int, Chirality, Compass)

    Adds an expanded particle at the given position when in initialization mode.

    Declaration
    public void AddParticleExpanded(Vector2Int gridPosHead, Vector2Int gridPosTail, Initialization.Chirality chirality = Chirality.CounterClockwise, Initialization.Compass compassDir = Compass.E)
    Parameters
    Type Name Description
    Vector2Int gridPosHead

    The grid position of the particle's head.

    Vector2Int gridPosTail

    The grid position of the particle's tail.

    Initialization.Chirality chirality

    The current chirality setting.

    Initialization.Compass compassDir

    The current compass direction setting.

    | Edit this page View Source

    AddPositionToObject(ParticleObject, Vector2Int)

    Extends the given object by adding the given position to the object map. Should be called whenever a new position is added to a registered object. Works only in Init Mode.

    Declaration
    public bool AddPositionToObject(ParticleObject o, Vector2Int gridPos)
    Parameters
    Type Name Description
    ParticleObject o

    The registered object that gains a new position.

    Vector2Int gridPos

    The global grid position that should be added to the object.

    Returns
    Type Description
    bool

    true if and only if the position was added successfully.

    | Edit this page View Source

    AnchorPosition()

    Returns the world coordinates of the system's current anchor particle or object.

    Declaration
    public Vector2 AnchorPosition()
    Returns
    Type Description
    Vector2

    The world coordinates of the system's anchor particle or object, if it exists, otherwise (0, 0).

    | Edit this page View Source

    ApplyAttributeValueToAllParticles(IParticleState, string)

    Copies the attribute value of the given particle to all particles in the system.

    All particles that have an attribute with name attributeName will try to read the string representation of p's attribute value. This only works for attribute types that can be represented as strings (i.e., pin configurations will not work).

    Declaration
    public void ApplyAttributeValueToAllParticles(IParticleState p, string attributeName)
    Parameters
    Type Name Description
    IParticleState p

    The particle from which to copy the attribute value.

    string attributeName

    The name of the attribute to copy.

    | Edit this page View Source

    ApplyNewPinConfigurations()

    Updates the pin configuration for each particle.

    If a particle has moved in the move phase and has not set a new pin configuration, it will be reset to a singleton pattern.

    Declaration
    public void ApplyNewPinConfigurations()
    | Edit this page View Source

    CallAutomaticStatusInfoMethods()

    Calls all automatic status info methods of the currently selected algorithm. Only works in Simulation Mode.

    Declaration
    private void CallAutomaticStatusInfoMethods()
    | Edit this page View Source

    CenterPosition(bool)

    Calculates the average world position of all particles and objects in the system.

    Declaration
    public Vector2 CenterPosition(bool includeObjects = true)
    Parameters
    Type Name Description
    bool includeObjects

    Whether positions occupied by objects should be included.

    Returns
    Type Description
    Vector2

    The average world of all particles. Will be (0, 0) if there are no particles.

    | Edit this page View Source

    CheckForCollision()

    Checks for joint movement collisions by searching for overlapping edge movements in the set of recorded edges.

    This method also clears the sets of collected edge movements in any case.

    Declaration
    private bool CheckForCollision()
    Returns
    Type Description
    bool

    true if and only if a collision was found.

    | Edit this page View Source

    CleanupAfterRound()

    Resets the helper information of all particles and objects to prepare for the simulation of the next round.

    Declaration
    private void CleanupAfterRound()
    | Edit this page View Source

    ClearEdgeMovements()

    Releases all edge movements that were recorded for particles.

    Declaration
    private void ClearEdgeMovements()
    | Edit this page View Source

    CollectBondInfo(Particle, int, Direction, Particle[], bool[], bool[], int[], ParticleObject[], int)

    Helper method for finding the bonded neighbors of a particle.

    Declaration
    private void CollectBondInfo(Particle p, int numNbrs, Direction globalHeadDir, Particle[] nbrParts, bool[] bondNbrs, bool[] nbrHead, int[] nbrLabels, ParticleObject[] nbrObjs, int handoverLabelToCheck = -1)
    Parameters
    Type Name Description
    Particle p

    The particle whose neighbors shall be found.

    int numNbrs

    The number of labels to be checked. Should be 6 or 10, depending on the expansion state of the particle. All provided array parameters must have at least this length.

    Direction globalHeadDir

    The global head direction of the particle.

    Particle[] nbrParts

    A particle array that should hold references to the bonded neighbor particles that still have to be processed.

    bool[] bondNbrs

    A bool array that should have true entries for all labels at which there is a bonded neighbor.

    bool[] nbrHead

    A bool array that should have true entries for all labels that are adjacent to the head of a bonded neighbor.

    int[] nbrLabels

    An int array that should hold the bonded neighbor's label corresponding to each of the current particle's labels.

    ParticleObject[] nbrObjs

    An object array that should hold references to the neighboring objects to which the particle is bonded.

    int handoverLabelToCheck

    One label that must have a bonded neighbor because the current particle intends to perform a handover in that direction. If no such neighbor is found, a System.InvalidOperationException is thrown. Use -1 to indicate that no label must be checked.

    | Edit this page View Source

    ComputeBondsStatic()

    Computes bond information in the case that no movements have occurred. This method works similar to the joint movement simulation but it does not process any movements. It also does not check whether the particle bond structure is connected or not. Bonds will only be computed for the connected component that contains the anchor particle (or the first particle if the anchor is an object).

    Declaration
    private void ComputeBondsStatic()
    | Edit this page View Source

    ContinueTracking()

    Resets the marker to track the latest recorded state and to continue evolving as the simulation progresses.

    Declaration
    public void ContinueTracking()
    | Edit this page View Source

    ContractParticle(Particle, bool)

    Declaration
    private void ContractParticle(Particle p, bool head)
    Parameters
    Type Name Description
    Particle p
    bool head
    | Edit this page View Source

    ContractParticleHead(Particle)

    System-side implementation of ContractHead().

    Schedules a ParticleAction to contract the given particle into its head if the action is applicable. A contraction action is definitely not applicable if the particle is already contracted.

    Declaration
    public void ContractParticleHead(Particle p)
    Parameters
    Type Name Description
    Particle p

    The particle that should contract.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the particle is already contracted.

    | Edit this page View Source

    ContractParticleTail(Particle)

    System-side implementation of ContractTail().

    Schedules a ParticleAction to contract the given particle into its tail if the action is applicable. A contraction action is definitely not applicable if the particle is already contracted.

    Declaration
    public void ContractParticleTail(Particle p)
    Parameters
    Type Name Description
    Particle p

    The particle that should contract.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the particle is already contracted.

    | Edit this page View Source

    CutOffAtMarker()

    Deletes all recorded states after the currently marked round.

    Declaration
    public void CutOffAtMarker()
    | Edit this page View Source

    DiscoverCircuits(bool)

    Uses the particles' pin configurations to determine all circuits in the system from scratch and send the planned beeps and messages accordingly.

    The algorithm performs a breadth-first search on each connected component of the particle system to assign every partition set of each particle to a circuit, merging the circuits if they happen to be connected when a partition set is added.

    Declaration
    private void DiscoverCircuits(bool sendBeepsAndMessages)
    Parameters
    Type Name Description
    bool sendBeepsAndMessages

    Determines whether beeps and messages are sent. Set to false to only recompute the current circuits and update their graphics info.

    | Edit this page View Source

    ExpandParticle(Particle, Direction)

    System-side implementation of Expand(Direction).

    Schedules a ParticleAction to expand the given particle in the specified direction if the action is applicable. An expansion action is definitely not applicable if the particle is already expanded.

    Declaration
    public void ExpandParticle(Particle p, Direction locDir)
    Parameters
    Type Name Description
    Particle p

    The particle that should expand.

    Direction locDir

    The local direction into which the particle should expand.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the particle is already expanded.

    | Edit this page View Source

    FindFirstNeighborObjectWithProperty(Particle, Func<IParticleObject, bool>, out Neighbor<IParticleObject>, Direction, bool, bool, int)

    System-side implementation of FindFirstNeighborObjectWithProperty(Func<IParticleObject, bool>, out Neighbor<IParticleObject>, Direction, bool, bool, int).

    Declaration
    public bool FindFirstNeighborObjectWithProperty(Particle p, Func<IParticleObject, bool> prop, out Neighbor<IParticleObject> neighbor, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxNumber = -1)
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Func<IParticleObject, bool> prop

    The property to be satisfied by the neighbor object.

    Neighbor<IParticleObject> neighbor

    The neighbor to be returned.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxNumber

    Maximum number of neighbor nodes to search.

    Returns
    Type Description
    bool

    true if and only if a neighbor object satisfying the property was found.

    | Edit this page View Source

    FindFirstNeighborWithProperty<T>(Particle, Func<T, bool>, out Neighbor<T>, Direction, bool, bool, int)

    System-side implementation of FindFirstNeighborWithProperty<T>(Func<T, bool>, out Neighbor<T>, Direction, bool, bool, int).

    Declaration
    public bool FindFirstNeighborWithProperty<T>(Particle p, Func<T, bool> prop, out Neighbor<T> neighbor, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxNumber = -1) where T : ParticleAlgorithm
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Func<T, bool> prop

    The property to be satisfied by the neighbor.

    Neighbor<T> neighbor

    The neighbor to be returned.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxNumber

    Maximum number of neighbor nodes to search.

    Returns
    Type Description
    bool

    true if and only if a neighbor satisfying the property was found.

    Type Parameters
    Name Description
    T

    The algorithm type to search for.

    | Edit this page View Source

    FindFirstNeighbor<T>(Particle, out Neighbor<T>, Direction, bool, bool, int)

    System-side implementation of FindFirstNeighbor<T>(out Neighbor<T>, Direction, bool, bool, int).

    Declaration
    public bool FindFirstNeighbor<T>(Particle p, out Neighbor<T> neighbor, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxNumber = -1) where T : ParticleAlgorithm
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Neighbor<T> neighbor

    The neighbor to be returned.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxNumber

    Maximum number of neighbor nodes to search.

    Returns
    Type Description
    bool

    true if and only if a neighbor was found.

    Type Parameters
    Name Description
    T

    The algorithm type to search for.

    | Edit this page View Source

    FindFirstObjectNeighbor(Particle, out Neighbor<IParticleObject>, Direction, bool, bool, int)

    System-side implementation of FindFirstObjectNeighbor(out Neighbor<IParticleObject>, Direction, bool, bool, int).

    Declaration
    public bool FindFirstObjectNeighbor(Particle p, out Neighbor<IParticleObject> neighbor, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxNumber = -1)
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor object.

    Neighbor<IParticleObject> neighbor

    The neighbor object to be returned.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxNumber

    Maximum number of neighbor nodes to search.

    Returns
    Type Description
    bool

    true if and only if a neighbor object was found.

    | Edit this page View Source

    FindNeighborObjects(Particle, Direction, bool, bool, int, int)

    System-side implementation of FindNeighborObjects(Direction, bool, bool, int, int).

    Declaration
    public List<Neighbor<IParticleObject>> FindNeighborObjects(Particle p, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxSearch = -1, int maxReturn = -1)
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxSearch

    Maximum number of neighbor nodes to search.

    int maxReturn

    Maximum number of neighbors to return.

    Returns
    Type Description
    List<Neighbor<IParticleObject>>

    The list of discovered neighbor objects.

    | Edit this page View Source

    FindNeighborObjectsWithProperty(Particle, Func<IParticleObject, bool>, Direction, bool, bool, int, int)

    System-side implementation of FindNeighborObjectsWithProperty(Func<IParticleObject, bool>, Direction, bool, bool, int, int).

    Declaration
    public List<Neighbor<IParticleObject>> FindNeighborObjectsWithProperty(Particle p, Func<IParticleObject, bool> prop, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxSearch = -1, int maxReturn = -1)
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Func<IParticleObject, bool> prop

    The property to be satisfied by the neighbor objects.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxSearch

    Maximum number of neighbor nodes to search.

    int maxReturn

    Maximum number of neighbors to return.

    Returns
    Type Description
    List<Neighbor<IParticleObject>>

    The list of discovered neighbor objects.

    | Edit this page View Source

    FindNeighborsWithProperty<T>(Particle, Func<T, bool>, Direction, bool, bool, int, int)

    System-side implementation of FindNeighborsWithProperty<T>(Func<T, bool>, Direction, bool, bool, int, int).

    Declaration
    public List<Neighbor<T>> FindNeighborsWithProperty<T>(Particle p, Func<T, bool> prop, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxSearch = -1, int maxReturn = -1) where T : ParticleAlgorithm
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Func<T, bool> prop

    The property to be satisfied by the neighbors.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxSearch

    Maximum number of neighbor nodes to search.

    int maxReturn

    Maximum number of neighbors to return.

    Returns
    Type Description
    List<Neighbor<T>>

    The list of discovered neighbors.

    Type Parameters
    Name Description
    T

    The algorithm type to search for.

    | Edit this page View Source

    FindNeighbors<T>(Particle, Direction, bool, bool, int, int)

    System-side implementation of FindNeighbors<T>(Direction, bool, bool, int, int).

    Declaration
    public List<Neighbor<T>> FindNeighbors<T>(Particle p, Direction startDir = Direction.E, bool startAtHead = true, bool withChirality = true, int maxSearch = -1, int maxReturn = -1) where T : ParticleAlgorithm
    Parameters
    Type Name Description
    Particle p

    The particle searching for a neighbor.

    Direction startDir

    The direction in which to start searching.

    bool startAtHead

    If true, start searching at the particle's head.

    bool withChirality

    If true, search in direction of the particle's chirality.

    int maxSearch

    Maximum number of neighbor nodes to search.

    int maxReturn

    Maximum number of neighbors to return.

    Returns
    Type Description
    List<Neighbor<T>>

    The list of discovered neighbors.

    Type Parameters
    Name Description
    T

    The algorithm type to search for.

    | Edit this page View Source

    FinishBeepAndMessageInfo()

    Stores the received beeps and messages and resets the planned beeps and messages for each particle. Use this to prepare the particles for the transmission and reception of beeps and messages in the next round.

    Declaration
    private void FinishBeepAndMessageInfo()
    | Edit this page View Source

    FinishMovementInfo()

    Stores the released and marked bonds and resets them for each particle and resets joint movement info for every object. Use this to prepare the particles and objects for the joint movements in the next round.

    Declaration
    private void FinishMovementInfo()
    | Edit this page View Source

    GenerateInitSaveData(InitModeSaveData)

    Writes the current initialization state into a serializable object.

    Declaration
    public InitializationStateSaveData GenerateInitSaveData(InitModeSaveData initModeSaveData = null)
    Parameters
    Type Name Description
    InitModeSaveData initModeSaveData

    Serializable information describing the current UI state.

    Returns
    Type Description
    InitializationStateSaveData

    A serializable object containing the current initialization state including UI elements.

    | Edit this page View Source

    GenerateInitSystem()

    Generates the particle system in initialization mode using the selected algorithm's default parameters.

    Declaration
    private void GenerateInitSystem()
    | Edit this page View Source

    GenerateInitSystem(object[])

    Generates the particle system in initialization mode using the given parameters.

    Declaration
    private void GenerateInitSystem(object[] parameters)
    Parameters
    Type Name Description
    object[] parameters

    The parameters that should be passed to the selected algorithm's generation method.

    | Edit this page View Source

    GenerateParticles(string, object[])

    Invokes the specified system generation method to fill the system with particles in initialization mode.

    Declaration
    public void GenerateParticles(string methodName, object[] parameters)
    Parameters
    Type Name Description
    string methodName

    The name of the generation method.

    object[] parameters

    The parameters for the generation method.

    | Edit this page View Source

    GenerateSaveData()

    Writes the current simulation state including its entire history into a serializable object.

    Declaration
    public SimulationStateSaveData GenerateSaveData()
    Returns
    Type Description
    SimulationStateSaveData

    A serializable object containing the current simulation state and its history.

    | Edit this page View Source

    GetBoundingBox(bool)

    Computes the bounding box of the current particle system (including objects) in world coordinates. The bounding box is computed with respect to the current camera rotation, but this rotation is not preserved in the result.

    Declaration
    public Vector4 GetBoundingBox(bool includeObjects = true)
    Parameters
    Type Name Description
    bool includeObjects

    Whether objects should be included in the calculation.

    Returns
    Type Description
    Vector4

    A vector (x, y, z, w) where (x, y) is the world position of the bounding box center and z and w are the bounding box width and height, respectively.

    | Edit this page View Source

    GetFirstRecordedRound()

    Returns the first round for which a state has been recorded.

    The object cannot be reset to a time before this round.

    Declaration
    public int GetFirstRecordedRound()
    Returns
    Type Description
    int

    The first round for which a state has been recorded.

    | Edit this page View Source

    GetInitParticles()

    Returns an array storing all current particles in initialization mode.

    Declaration
    public InitializationParticle[] GetInitParticles()
    Returns
    Type Description
    InitializationParticle[]

    An array containing all initialization particles.

    | Edit this page View Source

    GetMarkedRound()

    Returns the round that is currently marked.

    If the marker is tracking the object's state, this round will increase every time a new value is recorded.

    Declaration
    public int GetMarkedRound()
    Returns
    Type Description
    int

    The round that is currently marked.

    | Edit this page View Source

    GetNeighborAt(Particle, Direction, bool)

    System-side implementation of GetNeighborAt(Direction, bool).

    See also HasNeighborAt(Particle, Direction, bool).

    Declaration
    public Particle GetNeighborAt(Particle p, Direction locDir, bool fromHead = true)
    Parameters
    Type Name Description
    Particle p

    The particle trying to get its neighbor.

    Direction locDir

    The local direction of the particle in which to check.

    bool fromHead

    If true, check relative to p's head, otherwise check relative to the tail.

    Returns
    Type Description
    Particle

    The neighboring particle in the specified position, if it exists, otherwise null.

    | Edit this page View Source

    GetObjectAt(Particle, Direction, bool)

    System-side implementation of GetObjectAt(Direction, bool).

    See also HasObjectAt(Particle, Direction, bool).

    Declaration
    public IParticleObject GetObjectAt(Particle p, Direction locDir, bool fromHead = true)
    Parameters
    Type Name Description
    Particle p

    The particle trying to get its neighbor object.

    Direction locDir

    The local direction of the particle in which to check.

    bool fromHead

    If true, check relative to p's head, otherwise check relative to the tail.

    Returns
    Type Description
    IParticleObject

    The neighboring object in the specified position, if it exists, otherwise null.

    | Edit this page View Source

    HasNeighborAt(Particle, Direction, bool)

    System-side implementation of HasNeighborAt(Direction, bool).

    See also GetNeighborAt(Particle, Direction, bool).

    Declaration
    public bool HasNeighborAt(Particle p, Direction locDir, bool fromHead = true)
    Parameters
    Type Name Description
    Particle p

    The particle checking for a neighbor.

    Direction locDir

    The local direction of the particle in which to check.

    bool fromHead

    If true, check relative to p's head, otherwise check relative to the tail.

    Returns
    Type Description
    bool

    true if and only if the node in local direction locDir relative to p's head or tail is occupied by a particle other than p.

    | Edit this page View Source

    HasObjectAt(Particle, Direction, bool)

    System-side implementation of HasObjectAt(Direction, bool).

    See also HasNeighborAt(Particle, Direction, bool).

    Declaration
    public bool HasObjectAt(Particle p, Direction locDir, bool fromHead = true)
    Parameters
    Type Name Description
    Particle p

    The particle checking for a neighboring object.

    Direction locDir

    The local direction of the particle in which to check.

    bool fromHead

    If true, check relative to p's head, otherwise check relative to the tail.

    Returns
    Type Description
    bool

    true if and only if the node in local direction locDir relative to p's head or tail is occupied by an object.

    | Edit this page View Source

    HasSimulationFinished()

    Checks if the simulation has finished by calling the IsFinished() method on all particles.

    Declaration
    private bool HasSimulationFinished()
    Returns
    Type Description
    bool

    true if and only if all particles are finished and no particle caused an exception while running IsFinished().

    | Edit this page View Source

    InitializationModeAborted()

    Aborts the initialization mode and reloads the previous simulation state if possible.

    Declaration
    public void InitializationModeAborted()
    | Edit this page View Source

    InitializationModeFinished(string)

    Exits the initialization mode and initializes the particle system based on the current configuration.

    Declaration
    public void InitializationModeFinished(string algorithmName)
    Parameters
    Type Name Description
    string algorithmName

    The name of the selected algorithm.

    | Edit this page View Source

    InitializationModeStarted(string)

    Switches the system state to initialization mode.

    Declaration
    public void InitializationModeStarted(string selectedAlgo)
    Parameters
    Type Name Description
    string selectedAlgo

    The name of the first algorithm that should be selected.

    | Edit this page View Source

    InitializeBoundaryTest(int, float)

    See InitializeLineFormation(int, float).

    Declaration
    public void InitializeBoundaryTest(int numParticles, float holeProb)
    Parameters
    Type Name Description
    int numParticles
    float holeProb
    | Edit this page View Source

    InitializeChiralityCompass(int, float)

    See InitializeLineFormation(int, float).

    Declaration
    public void InitializeChiralityCompass(int numParticles, float holeProb)
    Parameters
    Type Name Description
    int numParticles
    float holeProb
    | Edit this page View Source

    InitializeExpandedTest(int)

    See InitializeLineFormation(int, float).

    Declaration
    public void InitializeExpandedTest(int numParticles)
    Parameters
    Type Name Description
    int numParticles
    | Edit this page View Source

    InitializeFixed(string, object[])

    Helper for initializing the system with a specific algorithm and starting the simulation. Does not work in initialization mode.

    Declaration
    private void InitializeFixed(string algorithmName, object[] parameters)
    Parameters
    Type Name Description
    string algorithmName

    The name of the algorithm to be initialized.

    object[] parameters

    The parameters that should be passed to the algorithm's generation method.

    | Edit this page View Source

    InitializeFromSaveState(SimulationStateSaveData, bool)

    Initializes the system to the state that is stored in the given save data object.

    This only works correctly if the system was reset using the Reset() method before.

    Declaration
    public void InitializeFromSaveState(SimulationStateSaveData data, bool updateVisuals = true)
    Parameters
    Type Name Description
    SimulationStateSaveData data

    The object containing the saved simulation state.

    bool updateVisuals

    If true, the render system is notified about the updated system immediately after loading the simulation state.

    | Edit this page View Source

    InitializeJMTest(int)

    See InitializeLineFormation(int, float).

    Declaration
    public void InitializeJMTest(int mode)
    Parameters
    Type Name Description
    int mode
    | Edit this page View Source

    InitializeLeaderElection(int, float)

    See InitializeLineFormation(int, float).

    Declaration
    public void InitializeLeaderElection(int numParticles, float holeProb)
    Parameters
    Type Name Description
    int numParticles
    float holeProb
    | Edit this page View Source

    InitializeLineFormation(int, float)

    Initializes the system with connected LineFormationParticles for testing purposes. This should be removed after a proper initialization method has been created.

    Declaration
    public void InitializeLineFormation(int numParticles, float holeProb)
    Parameters
    Type Name Description
    int numParticles

    The number of particles to create.

    float holeProb

    The probability of a position not being occupied by a particle and being left empty instead.

    | Edit this page View Source

    IsAnchor(ParticleObject)

    Checks if the given object is the anchor of the system.

    Declaration
    public bool IsAnchor(ParticleObject obj)
    Parameters
    Type Name Description
    ParticleObject obj

    The object that should be checked.

    Returns
    Type Description
    bool

    true if and only if obj is currently the anchor object.

    | Edit this page View Source

    IsAnchor(IParticleState)

    Checks if the given particle is the anchor of the system.

    Declaration
    public bool IsAnchor(IParticleState p)
    Parameters
    Type Name Description
    IParticleState p

    The particle that should be checked.

    Returns
    Type Description
    bool

    true if and only if p is currently the anchor particle.

    | Edit this page View Source

    IsHeadAt(Particle, Direction, bool)

    System-side implementation of IsHeadAt(Direction, bool).

    Declaration
    public bool IsHeadAt(Particle p, Direction locDir, bool fromHead = true)
    Parameters
    Type Name Description
    Particle p

    The particle checking for a neighbor's head.

    Direction locDir

    The local direction of the particle in which to check.

    bool fromHead

    If true, check relative to p's head, otherwise check relative to the tail.

    Returns
    Type Description
    bool

    true if and only if the node in local direction locDir relative to p's head or tail is occupied by the head of a particle other than p.

    | Edit this page View Source

    IsInLatestRound()

    Checks whether the simulation state is currently in the latest recorded round.

    Declaration
    public bool IsInLatestRound()
    Returns
    Type Description
    bool

    true if and only if the current simulation state is in the latest round.

    | Edit this page View Source

    IsInitSystemConnected()

    Checks whether the initialization system is connected such that the particles form a connected component and all objects are either directly or indirectly connected to a particle.

    Declaration
    private bool IsInitSystemConnected()
    Returns
    Type Description
    bool

    true if and only if the particle system is connected and all objects are connected to the particles.

    | Edit this page View Source

    IsTailAt(Particle, Direction, bool)

    System-side implementation of IsTailAt(Direction, bool).

    Declaration
    public bool IsTailAt(Particle p, Direction locDir, bool fromHead = true)
    Parameters
    Type Name Description
    Particle p

    The particle checking for a neighbor's tail.

    Direction locDir

    The local direction of the particle in which to check.

    bool fromHead

    If true, check relative to p's head, otherwise check relative to the tail.

    Returns
    Type Description
    bool

    true if and only if the node in local direction locDir relative to p's head or tail is occupied by the tail of a particle other than p.

    | Edit this page View Source

    IsTracking()

    Checks whether the object is currently tracking the latest recorded state.

    If the object is not tracking, it may not be usable in the regular way until the tracking is continued.

    Declaration
    public bool IsTracking()
    Returns
    Type Description
    bool

    Whether the marker currently tracks the latest recorded state.

    | Edit this page View Source

    IterateNeighborObjects(Particle, Direction, bool, bool, int, int)

    Iterates through the neighbor nodes of a given particle and returns the encountered objects. See IterateNeighbors<T>(Particle, Direction, bool, bool, int, int).

    Declaration
    private IEnumerable<Neighbor<IParticleObject>> IterateNeighborObjects(Particle p, Direction localStartDir, bool startAtHead, bool withChirality, int maxSearch, int maxReturn)
    Parameters
    Type Name Description
    Particle p

    The particle searching for neighbor objects.

    Direction localStartDir

    The local direction of p indicating the place where the search should start.

    bool startAtHead

    If true, the search starts at p's head, otherwise it starts at its tail (no effect for contracted particles).

    bool withChirality

    If true, the search progresses in the same direction as p's chirality, otherwise it progresses in the opposite direction.

    int maxSearch

    The maximum number of nodes to search.

    int maxReturn

    The maximum number of neighbors to return.

    Returns
    Type Description
    IEnumerable<Neighbor<IParticleObject>>

    Every neighbor object encountered during the search, each wrapped in a Neighbor<T> instance.

    | Edit this page View Source

    IterateNeighbors<T>(Particle, Direction, bool, bool, int, int)

    Iterates through the neighbor nodes of a given particle and returns the encountered particles.

    Declaration
    private IEnumerable<Neighbor<T>> IterateNeighbors<T>(Particle p, Direction localStartDir, bool startAtHead, bool withChirality, int maxSearch, int maxReturn) where T : ParticleAlgorithm
    Parameters
    Type Name Description
    Particle p

    The particle searching for neighbors.

    Direction localStartDir

    The local direction of p indicating the place where the search should start.

    bool startAtHead

    If true, the search starts at p's head, otherwise it starts at its tail (no effect for contracted particles).

    bool withChirality

    If true, the search progresses in the same direction as p's chirality, otherwise it progresses in the opposite direction.

    int maxSearch

    The maximum number of nodes to search.

    int maxReturn

    The maximum number of neighbors to return.

    Returns
    Type Description
    IEnumerable<Neighbor<T>>

    Every neighbor ParticleAlgorithm encountered during the search, each wrapped in a Neighbor<T> instance.

    Type Parameters
    Name Description
    T

    The type of particles to search for, must be ParticleAlgorithm subclass.

    | Edit this page View Source

    JointMovementContractedExpanded(Particle, Particle, Direction, Direction, int, int, int, int, bool, bool, bool)

    Helper method for handling the joint movement of a contracted particle that is bonded to an expanded particle.

    Declaration
    private Vector2Int JointMovementContractedExpanded(Particle c, Particle e, Direction bondDir, Direction secondBondDir, int cLabel1, int cLabel2, int eLabel1, int eLabel2, bool eHead1, bool eHead2, bool bondForContracted = true)
    Parameters
    Type Name Description
    Particle c

    The contracted particle.

    Particle e

    The expanded particle.

    Direction bondDir

    The global direction of the primary bond from the contracted to the expanded particle. The primary bond is simply the first one we encounter while processing the movements.

    Direction secondBondDir

    The global direction of the second bond from the contracted to the expanded particle. Must be NONE if there is no second bond.

    int cLabel1

    The global label of the contracted particle identifying the primary bond.

    int cLabel2

    The global label of the contracted particle identifying the second bond. Must be -1 if there is no second bond.

    int eLabel1

    The global label of the expanded particle identifying the primary bond.

    int eLabel2

    The global label of the expanded particle identifying the second bond. Must be -1 if there is no second bond.

    bool eHead1

    Flag indicating whether the first bond is incident to the head of the expanded particle.

    bool eHead2

    Flag indicating whether the second bond is incident to the head of the expanded particle. Must be false if there is no second bond.

    bool bondForContracted

    Flag indicating whether the bond info should be associated with the contracted particle.

    Returns
    Type Description
    Vector2Int

    The global offset vector of the expanded particle's origin relative to the contracted particle's origin.

    | Edit this page View Source

    JointMovementExpandedTwoBonds(Particle, Particle, bool, bool, bool, bool, bool)

    Helper method for handling the joint movements of two neighboring expanded particles that from a triangle with two bonds.

    Declaration
    private Vector2Int JointMovementExpandedTwoBonds(Particle pCorner, Particle pEdge, bool cornerAtHead, bool cornerMarked1, bool cornerMarked2, bool edgeMarkedHead, bool edgeMarkedTail)
    Parameters
    Type Name Description
    Particle pCorner

    The particle owning the part where the two bonds meet.

    Particle pEdge

    The particle having one bond on each of its parts.

    bool cornerAtHead

    Indicates whether the part where the two bonds meet is the head of the pCorner particle.

    bool cornerMarked1

    Indicates whether the particle owning the corner has marked the first bond.

    bool cornerMarked2

    Indicates whether the particle owning the corner has marked the second bond.

    bool edgeMarkedHead

    Indicates whether the edge particle has marked the bond at its head.

    bool edgeMarkedTail

    Indicates whether the edge particle has marked the bond at its tail.

    Returns
    Type Description
    Vector2Int

    The global offset vector of the edge particle's origin relative to the corner particle's origin.

    | Edit this page View Source

    LoadInitSaveState(InitializationStateSaveData)

    Initializes the system to the initialization state that is stored in the given save data object.

    Only works correctly in Initialization mode.

    Declaration
    public InitModeSaveData LoadInitSaveState(InitializationStateSaveData data)
    Parameters
    Type Name Description
    InitializationStateSaveData data

    The object containing the saved initialization state.

    Returns
    Type Description
    InitModeSaveData

    The serializable data about the UI state that is contained in data.

    | Edit this page View Source

    LoadMovementGraphicsInfo(bool)

    Sets the bond graphics info of all particles and objects to the currently loaded state so that it can be displayed. If animations are required, the joint movement info is also loaded and set up to produce the correct animations. This should be called when stepping or jumping through the history.

    Declaration
    private void LoadMovementGraphicsInfo(bool withAnimation)
    Parameters
    Type Name Description
    bool withAnimation

    Flag indicating whether the loaded movement information should include an animation or not.

    | Edit this page View Source

    MakeObjectAnchor(Particle, Direction, bool)

    System-side implementation of MakeObjectAnchor(Direction, bool).

    Checks if there is an object at the given neighbor location and turns it into the anchor if it is found.

    Declaration
    public bool MakeObjectAnchor(Particle p, Direction locDir, bool head)
    Parameters
    Type Name Description
    Particle p

    The particle trying to turn its neighbor object into the anchor.

    Direction locDir

    The local direction in which the neighbor object should be.

    bool head

    Whether the neighbor object is adjacent to the particle's head.

    Returns
    Type Description
    bool

    true if and only if the object was found and turned into the anchor.

    | Edit this page View Source

    MoveObject(ParticleObject, Vector2Int)

    Moves all registered positions of the given object by the given offset. The positions stored internally by the object are not changed by this operation. Only works for objects registered in the system and in Init Mode.

    Declaration
    public bool MoveObject(ParticleObject o, Vector2Int offset)
    Parameters
    Type Name Description
    ParticleObject o

    The object that should be moved.

    Vector2Int offset

    The offset by which the object should be moved.

    Returns
    Type Description
    bool

    true if and only if the object was moved successfully.

    | Edit this page View Source

    MoveParticleToNewContractedPosition(IParticleState, Vector2Int)

    Moves the given particle to a new location in which it is contracted, when in initialization mode.

    Declaration
    public void MoveParticleToNewContractedPosition(IParticleState p, Vector2Int gridPos)
    Parameters
    Type Name Description
    IParticleState p

    The particle to be moved.

    Vector2Int gridPos

    The new grid position to which p should be moved.

    | Edit this page View Source

    MoveParticleToNewExpandedPosition(IParticleState, Vector2Int, Vector2Int)

    Moves the given particle to a new location in which it is expanded, when in initialization mode.

    Declaration
    public void MoveParticleToNewExpandedPosition(IParticleState p, Vector2Int gridPosHead, Vector2Int gridPosTail)
    Parameters
    Type Name Description
    IParticleState p

    The particle to be moved.

    Vector2Int gridPosHead

    The new grid position to which p's head should be moved.

    Vector2Int gridPosTail

    The new grid position to which p's tail should be moved. Must be adjacent to gridPosHead.

    | Edit this page View Source

    PerformPullHandover(Particle, Direction, bool)

    Declaration
    private void PerformPullHandover(Particle p, Direction locDir, bool head)
    Parameters
    Type Name Description
    Particle p
    Direction locDir
    bool head
    | Edit this page View Source

    PerformPullHandoverHead(Particle, Direction)

    System-side implementation of PullHandoverHead(Direction).

    Schedules a ParticleAction to contract the given particle into its head, pulling a contracted neighbor into its tail position, if the action is applicable. A pull handover action is definitely not applicable if the particle is already contracted or there is no contracted neighbor in the specified direction.

    Declaration
    public void PerformPullHandoverHead(Particle p, Direction locDir)
    Parameters
    Type Name Description
    Particle p

    The particle that should contract during the handover.

    Direction locDir

    The local direction relative to p's tail from where a contracted neighbor particle should be expanded to occupy the tail node.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the particle is already contracted or there is no contracted neighbor in the specified local direction relative to the particle's tail.

    | Edit this page View Source

    PerformPullHandoverTail(Particle, Direction)

    System-side implementation of PullHandoverTail(Direction).

    Schedules a ParticleAction to contract the given particle into its tail, pulling a contracted neighbor into its head position, if the action is applicable. A pull handover action is definitely not applicable if the particle is already contracted or there is no contracted neighbor in the specified direction.

    Declaration
    public void PerformPullHandoverTail(Particle p, Direction locDir)
    Parameters
    Type Name Description
    Particle p

    The particle that should contract during the handover.

    Direction locDir

    The local direction relative to p's head from where a contracted neighbor particle should be expanded to occupy the head node.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the particle is already contracted or there is no contracted neighbor in the specified local direction relative to the particle's head.

    | Edit this page View Source

    PerformPushHandover(Particle, Direction)

    System-side implementation of PushHandover(Direction).

    Schedules a ParticleAction to expand the given particle in the specified direction, pushing away an expanded neighbor, if the action is applicable. A push handover action is definitely not applicable if the particle is already expanded or the node in expansion direction is not occupied by an expanded particle.

    Declaration
    public void PerformPushHandover(Particle p, Direction locDir)
    Parameters
    Type Name Description
    Particle p

    The particle that should expand during the handover.

    Direction locDir

    The local direction into which the particle should expand.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if the particle is already expanded or the node in expansion direction is not occupied by an expanded particle.

    | Edit this page View Source

    PropagateObjectOffset(ParticleObject, Particle, bool)

    Helper method that propagates joint movement offset in a connected structure of objects and computes the corresponding bonds.

    Declaration
    private void PropagateObjectOffset(ParticleObject o, Particle sourceParticle, bool collectEdgeMovements = true)
    Parameters
    Type Name Description
    ParticleObject o

    The object at which to start the propagation. The offset of this object will be applied to all connected objects.

    Particle sourceParticle

    The particle to which the visual bond information should be assigned.

    bool collectEdgeMovements

    Whether edge movements should be collected for the bonds between objects. These edge movements will be used for the collision check.

    | Edit this page View Source

    RemoveObject(ParticleObject)

    Removes the given object from the system. The object must be removed from the render system manually. Only works in Init Mode.

    Declaration
    public void RemoveObject(ParticleObject o)
    Parameters
    Type Name Description
    ParticleObject o

    The object to be removed.

    | Edit this page View Source

    RemoveParticle(IParticleState)

    Removes the given particle when in initialization state.

    Declaration
    public void RemoveParticle(IParticleState p)
    Parameters
    Type Name Description
    IParticleState p

    The particle to be removed.

    | Edit this page View Source

    RemovePositionFromObject(ParticleObject, Vector2Int)

    Removes the given position from the given object. Should be called whenever a position is removed from a registered object. Works only in Init Mode.

    Declaration
    public bool RemovePositionFromObject(ParticleObject o, Vector2Int gridPos)
    Parameters
    Type Name Description
    ParticleObject o

    The registered object that loses a position.

    Vector2Int gridPos

    The global grid position that should be removed from the object.

    Returns
    Type Description
    bool

    true if and only if the position was removed successfully.

    | Edit this page View Source

    Reset()

    Resets the entire system to a state from which it can be initialized again.

    Declaration
    public void Reset()
    | Edit this page View Source

    ResetAfterException()

    Resets the simulation state to the previous round if an exception has occurred during round simulation.

    Declaration
    private void ResetAfterException()
    | Edit this page View Source

    ResetInit(bool)

    Resets the current particle configuration while in initialization mode.

    Declaration
    public void ResetInit(bool removeObjects = true)
    Parameters
    Type Name Description
    bool removeObjects
    | Edit this page View Source

    SetAnchor(ParticleObject)

    Sets the given object to be the new anchor of the system. Only works in the latest round of the simulation or in Initialization Mode.

    Declaration
    public bool SetAnchor(ParticleObject obj)
    Parameters
    Type Name Description
    ParticleObject obj

    The object that should become the anchor.

    Returns
    Type Description
    bool

    true if and only if the anchor object was set successfully.

    | Edit this page View Source

    SetAnchor(IParticleState)

    Sets the given particle to be the new anchor of the system. Only works in the latest round of the simulation or in Initialization Mode.

    Declaration
    public bool SetAnchor(IParticleState p)
    Parameters
    Type Name Description
    IParticleState p

    The particle that should become the anchor.

    Returns
    Type Description
    bool

    true if and only if the anchor particle was set successfully.

    | Edit this page View Source

    SetCollisionCheck(bool)

    Enables or disables the collision check.

    Declaration
    public void SetCollisionCheck(bool enabled)
    Parameters
    Type Name Description
    bool enabled

    If true, the collision check will be enabled, otherwise it will be disabled.

    | Edit this page View Source

    SetInitialParticleBonds()

    Sets all global bonds of all particles to active so that their initial bonds can be computed easily.

    Declaration
    private void SetInitialParticleBonds()
    | Edit this page View Source

    SetMarkerToRound(int)

    Sets the tracking marker to the specified round, restores the state recorded for that point in time, and stops the marker from tracking the latest round.

    The target round must not be earlier than the round returned by GetFirstRecordedRound().

    Declaration
    public void SetMarkerToRound(int round)
    Parameters
    Type Name Description
    int round

    The round to which the tracking marker should be set.

    | Edit this page View Source

    SetSelectedAlgorithm(string)

    Updates the currently selected algorithm in initialization mode.

    This will trigger a new system generation if the selected algorithm has changed.

    Declaration
    public void SetSelectedAlgorithm(string algoName)
    Parameters
    Type Name Description
    string algoName

    The name of the newly selected algorithm.

    | Edit this page View Source

    SetSystemAttributeRandom(string)

    Sets the given attribute to a random value for each particle in the system.

    Declaration
    public void SetSystemAttributeRandom(string attributeName)
    Parameters
    Type Name Description
    string attributeName

    The name of the attribute to randomize.

    | Edit this page View Source

    SetSystemChirality(Chirality)

    Resets the chirality of all particles to the given value when in initialization mode.

    Declaration
    public bool SetSystemChirality(Initialization.Chirality chirality)
    Parameters
    Type Name Description
    Initialization.Chirality chirality

    The chirality to assign to each particle. If the value is Random, the particles get a clockwise chirality with a probability of 50%.

    Returns
    Type Description
    bool

    true if and only if the chirality was set successfully.

    | Edit this page View Source

    SetSystemCompassDir(Compass)

    Resets the compass direction of all particles to the given value when in initialization mode.

    Declaration
    public bool SetSystemCompassDir(Initialization.Compass compassDir)
    Parameters
    Type Name Description
    Initialization.Compass compassDir

    The compass direction to assign to each particle. If the value is Random, each particle gets one of the cardinal directions chosen uniformly and independently.

    Returns
    Type Description
    bool

    true if and only if the compass direction was set successfully.

    | Edit this page View Source

    SetupPinGraphicState(bool)

    Initializes the ParticlePinGraphicState of all particles and sets the neighbor information. The neighbor caches must have been updated and movement information must have been loaded at this point.

    Declaration
    private void SetupPinGraphicState(bool reset = false)
    Parameters
    Type Name Description
    bool reset

    If true, all pin connections will be set to "Shown" (i.e., no animations).

    | Edit this page View Source

    ShiftTimescale(int)

    Shifts all records as well as the marker by the specified amount of rounds.

    Declaration
    public void ShiftTimescale(int amount)
    Parameters
    Type Name Description
    int amount

    The number of rounds to add to each entry. May be negative.

    | Edit this page View Source

    SimulateJointMovements()

    Computes the joint movements of the particle system after all movement activations were executed. Each particle gets a global offset that is applied in addition to its own local movement.

    Performs a breadth-first search on the graph induced by the particles' bonds, starting at the anchor particle (or the particle with index 0 if the anchor is an object). For each visited particle, offsets for all of its unvisited neighbors are computed based on the particle's own offset. The computation fails if two neighboring particles try to perform conflicting movements or any two particles end up at the same final location.

    Declaration
    private void SimulateJointMovements()
    | Edit this page View Source

    SimulateRound()

    Simulates a round in which each particle is activated twice. First, all particles execute their movement activations and the resulting movements are simulated and applied. Afterwards, the particles' beep activations are executed, the resulting circuits are determined and the sent beeps and messages are delivered. The order of activations is the same in both rounds.

    If a catchable exception occurs during the simulation, the system state is reset to the previous round.

    Only works while in tracking state during simulation mode.

    Declaration
    public void SimulateRound()
    | Edit this page View Source

    StepBack()

    Moves the marker one round back and restores the object's recorded state for that round. Also stops it from tracking the last round if it was still tracking.

    Must not be called when the marker is already at the first recorded round.

    Declaration
    public void StepBack()
    | Edit this page View Source

    StepForward()

    Moves the marker one round forward and restores the object's recorded state for that round. Also stops it from tracking the last round if it was still tracking.

    May be ineffective if the object has a hard limit on the last recorded round.

    Declaration
    public void StepForward()
    | Edit this page View Source

    TriggerObjectBondRelease(Particle, Direction, bool)

    System-side implementation of TriggerObjectBondRelease(Direction, bool).

    Checks if there is an object at the given neighbor location and releases its object bonds if it is found.

    Declaration
    public void TriggerObjectBondRelease(Particle p, Direction locDir, bool head)
    Parameters
    Type Name Description
    Particle p

    The particle trying to release the neighbor object's bonds.

    Direction locDir

    The local direction in which the neighbor object should be.

    bool head

    Whether the neighbor object is adjacent to the particle's head.

    | Edit this page View Source

    TryChangeInitParticleExpansion(InitializationParticle, Direction)

    Tries to change a particle's expansion state when in initialization mode. This method should only be called from within the particle itself so that it can update its own state after this check is complete.

    Declaration
    public bool TryChangeInitParticleExpansion(InitializationParticle ip, Direction newHeadDir)
    Parameters
    Type Name Description
    InitializationParticle ip

    The initialization particle trying to change its expansion state.

    Direction newHeadDir

    The desired new head direction.

    Returns
    Type Description
    bool

    true if and only if changing the particle's expansion state was successful.

    | Edit this page View Source

    TryGetInitParticleAt(Vector2Int, out InitializationParticle)

    Tries to get the InitializationParticle at the given position.

    Declaration
    public bool TryGetInitParticleAt(Vector2Int position, out InitializationParticle particle)
    Parameters
    Type Name Description
    Vector2Int position

    The grid position at which to look for the particle.

    InitializationParticle particle

    The particle at the given position, if it exists, otherwise null.

    Returns
    Type Description
    bool

    true if and only if a particle was found at the given position.

    | Edit this page View Source

    TryGetObjectAt(Vector2Int, out IObjectInfo)

    Tries to get the object at the given position.

    Declaration
    public bool TryGetObjectAt(Vector2Int position, out IObjectInfo obj)
    Parameters
    Type Name Description
    Vector2Int position

    The grid position at which to look for the object.

    IObjectInfo obj

    The object at the given position, if it exists, otherwise null.

    Returns
    Type Description
    bool

    true if and only if an object was found at the given position.

    | Edit this page View Source

    TryGetParticleAt(Vector2Int, out Particle)

    Tries to get the Particle at the given position. Only works in simulation mode.

    Declaration
    private bool TryGetParticleAt(Vector2Int position, out Particle particle)
    Parameters
    Type Name Description
    Vector2Int position

    The grid position at which to look for the particle.

    Particle particle

    The particle at the given position, if it exists, otherwise null.

    Returns
    Type Description
    bool

    true if and only if a particle was found at the given position.

    | Edit this page View Source

    TryGetParticleAt(Vector2Int, out IParticleState)

    Tries to get the IParticleState at the given position.

    Declaration
    public bool TryGetParticleAt(Vector2Int position, out IParticleState particle)
    Parameters
    Type Name Description
    Vector2Int position

    The grid position at which to look for the particle.

    IParticleState particle

    The particle at the given position, if it exists, otherwise null.

    Returns
    Type Description
    bool

    true if and only if a particle was found at the given position.

    | Edit this page View Source

    UpdateAfterStep(bool, bool, bool)

    Helper for updating particles and visualization info after stepping or jumping through the history.

    Declaration
    private void UpdateAfterStep(bool withAnimation = false, bool pinGraphicStateReset = true, bool resetVisuals = true)
    Parameters
    Type Name Description
    bool withAnimation

    Passed through to LoadMovementGraphicsInfo(bool), determines whether info for animations should be loaded.

    bool pinGraphicStateReset

    Passed through to SetupPinGraphicState(bool), determines whether pin connections should be animated for a reset.

    bool resetVisuals

    Passed through to UpdateAllParticleVisuals(bool), determines whether the visuals update is a reset without animations.

    | Edit this page View Source

    UpdateAllParticleVisuals(bool)

    Triggers a graphics update for each particle in the system.

    Declaration
    private void UpdateAllParticleVisuals(bool resetVisuals)
    Parameters
    Type Name Description
    bool resetVisuals
    | Edit this page View Source

    UpdateNeighborCaches()

    Updates the neighbor caches of all particles in the system based on their current positions. The current cache will become the old cache.

    Declaration
    private void UpdateNeighborCaches()

    Implements

    IReplayHistory
    • 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