Search Results for

    Show / Hide Table of Contents

    Class Particle

    The system-side representation of a particle.

    This class stores all internal particle information that should be hidden from the developers of a particle algorithm. It also provides methods for changing the particle's state to be called by the ParticleSystem.

    There is a 1:1 correspondence between Particle and ParticleAlgorithm instances. The conventional way to instantiate a pair of these objects is the following:

    Particle part = new Particle(particleSystem, startPosition[, compassDir][, chirality][, initialHeadDir]);
    part.isActive = true;
    AlgorithmManager.Instance.Instantiate(algorithmId, part);
    part.isActive = false;
    p.InitWithAlgorithm();
    It is recommended to use the ParticleFactory class instead of doing this manually.
    Inheritance
    object
    Particle
    Implements
    IParticleState
    IReplayHistory
    Namespace: AS2.Sim
    Assembly: .dll
    Syntax
    public class Particle : IParticleState, IReplayHistory

    Constructors

    | Edit this page View Source

    Particle(ParticleSystem, ParticleStateSaveData)

    Creates a new particle from the given serializable object.

    Declaration
    private Particle(ParticleSystem system, ParticleStateSaveData data)
    Parameters
    Type Name Description
    ParticleSystem system

    The system in which the particle should be created.

    ParticleStateSaveData data

    The serializable object from which the particle's state history will be recovered.

    | Edit this page View Source

    Particle(ParticleSystem, Vector2Int, Direction, bool, Direction)

    Creates a new particle without an algorithm controlling its behavior.

    Declaration
    public Particle(ParticleSystem system, Vector2Int pos, Direction compassDir = Direction.NONE, bool chirality = true, Direction initialHeadDir = Direction.NONE)
    Parameters
    Type Name Description
    ParticleSystem system

    The system containing the new particle.

    Vector2Int pos

    The initial grid position of the particle's tail.

    Direction compassDir

    The compass direction of the particle.

    bool chirality

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

    Direction initialHeadDir

    The initial local head direction if the particle should be expanded. NONE will make the particle contracted.

    Fields

    | Edit this page View Source

    activeBondHistory

    The history of all active bond settings.

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

    activeBonds

    Flags indicating which bonds should be active. Indices are local labels. Only the 10 lowest bits are used.

    Declaration
    private BitVector32 activeBonds
    Field Value
    Type Description
    BitVector32
    | Edit this page View Source

    activeBondsGlobal

    Active bonds indexed by global labels.

    Declaration
    public bool[] activeBondsGlobal
    Field Value
    Type Description
    bool[]
    | Edit this page View Source

    algorithm

    The algorithm controlling this particle's behavior.

    Declaration
    public ParticleAlgorithm algorithm
    Field Value
    Type Description
    ParticleAlgorithm
    | Edit this page View Source

    attributes

    A list containing the particle's attributes.

    Declaration
    private List<IParticleAttribute> attributes
    Field Value
    Type Description
    List<IParticleAttribute>
    | Edit this page View Source

    bondGraphicInfo

    Stores visualization info about some of the bonds incident to this particle so that they can be animated correctly.

    Declaration
    public List<ParticleBondGraphicState> bondGraphicInfo
    Field Value
    Type Description
    List<ParticleBondGraphicState>
    | Edit this page View Source

    bondMovementHistory

    History of bond information records.

    Declaration
    private ValueHistoryBondInfo bondMovementHistory
    Field Value
    Type Description
    ValueHistoryBondInfo
    | Edit this page View Source

    chirality

    If true, the positive rotation direction of the particle is counter-clockwise, else it is clockwise.

    Declaration
    public readonly bool chirality
    Field Value
    Type Description
    bool
    | Edit this page View Source

    comDir

    The compass orientation of the particle, represented as a global direction.

    Declaration
    public readonly Direction comDir
    Field Value
    Type Description
    Direction
    | Edit this page View Source

    currPinConfig

    The pin configuration at the beginning of the round.

    Declaration
    private SysPinConfiguration currPinConfig
    Field Value
    Type Description
    SysPinConfiguration
    | Edit this page View Source

    exp_expansionDir

    The local direction pointing from the particle's tail towards its head.

    Declaration
    private Direction exp_expansionDir
    Field Value
    Type Description
    Direction
    | Edit this page View Source

    exp_isExpanded

    Indicates whether the particle is currently expanded.

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

    expansionDirHistory

    The history of all expansion directions.

    Declaration
    private ValueHistory<Direction> expansionDirHistory
    Field Value
    Type Description
    ValueHistory<Direction>
    | Edit this page View Source

    gCircuit

    An object that represents this particle's pin configuration and its pin connections (internal and external) so that it can be rendered correctly.

    Declaration
    public ParticlePinGraphicState gCircuit
    Field Value
    Type Description
    ParticlePinGraphicState
    | Edit this page View Source

    graphics

    An object that serves as the graphical representation of this particle for the rendering system.

    Declaration
    public IParticleGraphicsAdapter graphics
    Field Value
    Type Description
    IParticleGraphicsAdapter
    | Edit this page View Source

    hasPlannedBeeps

    Indicates whether the particle has planned sending any beeps in this round.

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

    hasPlannedMessages

    Indicates whether the particle has planned sending any messages in this round.

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

    inConstructor

    Flag used to indicate that the particle's algorithm is currently running its constructor. If this is false while the algorithm tries to create a new attribute or subroutine, an exception will be thrown.

    Declaration
    public bool inConstructor
    Field Value
    Type Description
    bool
    | Edit this page View Source

    inReinitialize

    Special flag that is set while a particle is being reinitialized on load. Prevents state changes caused by an algorithm constructor.

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

    isActive

    Flag used to indicate that the particle is currently being activated. Causes the particle's attributes to behave differently for this particle than for others to enable the "snapshot" semantics.

    Declaration
    public bool isActive
    Field Value
    Type Description
    bool
    | Edit this page View Source

    isHeadOrigin

    Indicates whether the particle's head is its local origin, i.e., the part that would stay at its absolute position if the particle was the anchor of the system. The head is the origin if the particle is and stays contracted or if it is expanded and contracts into its head.

    Declaration
    public bool isHeadOrigin
    Field Value
    Type Description
    bool
    | Edit this page View Source

    jmOffset

    The absolute offset from the particle's initial location, accumulated by joint movements.

    Declaration
    public Vector2Int jmOffset
    Field Value
    Type Description
    Vector2Int
    | Edit this page View Source

    jointMovementHistory

    History of joint movement information records.

    Declaration
    private ValueHistoryJointMovement jointMovementHistory
    Field Value
    Type Description
    ValueHistoryJointMovement
    | Edit this page View Source

    mainColor

    The current particle color.

    Declaration
    private Color mainColor
    Field Value
    Type Description
    Color
    | Edit this page View Source

    mainColorHistory

    History of particle colors.

    Declaration
    private ValueHistory<Color> mainColorHistory
    Field Value
    Type Description
    ValueHistory<Color>
    | Edit this page View Source

    mainColorSet

    Indicates whether the particle color has been set.

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

    mainColorSetHistory

    History of flags showing whether the particle color is set.

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

    markedBondHistory

    The history of all marked bond settings.

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

    markedBonds

    Flags indicating which bonds have been marked for special behavior, i.e., moving with a particle's head during an expansion movement.

    Declaration
    private BitVector32 markedBonds
    Field Value
    Type Description
    BitVector32
    | Edit this page View Source

    markedBondsGlobal

    Marked bonds indexed by global labels.

    Declaration
    public bool[] markedBondsGlobal
    Field Value
    Type Description
    bool[]
    | Edit this page View Source

    markedForAutomaticBonds

    Flag indicating that the particle switched to automatic bonds mode, which will cause the bonds to create movements like in the original movement model, with no joint movements.

    Declaration
    public bool markedForAutomaticBonds
    Field Value
    Type Description
    bool
    | Edit this page View Source

    movementOffset

    The global offset by which the particle would move a bonded neighbor relative to its own origin if the bond moves relative to the origin. This is simply the direction of movement written as a vector.

    Declaration
    public Vector2Int movementOffset
    Field Value
    Type Description
    Vector2Int
    | Edit this page View Source

    neighborsNew

    The current neighbors of the particle. Indices are global labels.

    Declaration
    public Particle[] neighborsNew
    Field Value
    Type Description
    Particle[]
    | Edit this page View Source

    neighborsOld

    The neighbors of the particle in the last round. Indices are global labels.

    Declaration
    public Particle[] neighborsOld
    Field Value
    Type Description
    Particle[]
    | Edit this page View Source

    nextPinConfig

    The pin configuration to be set at the end of the round.

    Declaration
    private SysPinConfiguration nextPinConfig
    Field Value
    Type Description
    SysPinConfiguration
    | Edit this page View Source

    pinConfigurationHistory

    The history of all pin configurations.

    Declaration
    private ValueHistoryPinConfiguration pinConfigurationHistory
    Field Value
    Type Description
    ValueHistoryPinConfiguration
    | Edit this page View Source

    plannedBeeps

    Flags indicating which partition sets of the planned pin configuration have scheduled sending a beep. Indices equal (local) partition set IDs.

    Declaration
    private BitArray plannedBeeps
    Field Value
    Type Description
    BitArray
    | Edit this page View Source

    plannedBeepsByPin

    The (local) pin indices on which beeps were planned during an activation. Gets merged into plannedBeeps at the end of each activation.

    Declaration
    private HashSet<int> plannedBeepsByPin
    Field Value
    Type Description
    HashSet<int>
    | Edit this page View Source

    plannedBeepsHistory

    The histories of sent beeps for all partition sets.

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

    plannedMessageHistory

    The histories of sent messages for all partition sets.

    Declaration
    private ValueHistoryMessage[] plannedMessageHistory
    Field Value
    Type Description
    ValueHistoryMessage[]
    | Edit this page View Source

    plannedMessages

    Array of the currently planned messages. Indices are (local) partition set IDs.

    Declaration
    private Message[] plannedMessages
    Field Value
    Type Description
    Message[]
    | Edit this page View Source

    plannedMessagesByPin

    A dictionary of (local) pin indices and messages scheduled on them. Gets merged into plannedMessages at the end of each activation.

    Declaration
    private Dictionary<int, Message> plannedMessagesByPin
    Field Value
    Type Description
    Dictionary<int, Message>
    | Edit this page View Source

    pos_head

    The current global head position.

    Declaration
    private Vector2Int pos_head
    Field Value
    Type Description
    Vector2Int
    | Edit this page View Source

    pos_tail

    The current global tail position.

    Declaration
    private Vector2Int pos_tail
    Field Value
    Type Description
    Vector2Int
    | Edit this page View Source

    predictHeadDir

    Predicted head direction if the particle will be expanded at the end of this round according to the scheduled movement.

    Declaration
    private Direction predictHeadDir
    Field Value
    Type Description
    Direction
    | Edit this page View Source

    predictIsExpanded

    Indicates whether the particle will be expanded at the end of this round according to the currently scheduled movement.

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

    predictTailDir

    Predicted tail direction if the particle will be expanded at the end of this round according to the scheduled movement.

    Declaration
    private Direction predictTailDir
    Field Value
    Type Description
    Direction
    | Edit this page View Source

    processedJointMovement

    Flag indicating whether the particle has already been processed for joint movements. Becomes true as soon as the particle's movement has been validated against all of its neighbors' movements and its new location has been determined.

    Declaration
    public bool processedJointMovement
    Field Value
    Type Description
    bool
    | Edit this page View Source

    processedPinConfig

    Flag indicating whether the pin configuration of the particle has already been processed for finding circuits. Becomes true as soon as all non-empty partition sets have been assigned to a circuit, and is reset to false after finishing the round.

    Declaration
    public bool processedPinConfig
    Field Value
    Type Description
    bool
    | Edit this page View Source

    psetFailureHistory

    The histories of partition set failures for all partition sets.

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

    psetFailures

    Flags indicating which partition sets of the next pin configuration have suffered a failure. Indices equal (local) partition set IDs.

    Declaration
    private BitArray psetFailures
    Field Value
    Type Description
    BitArray
    | Edit this page View Source

    queuedForJMProcessing

    Flag indicating whether the particle has been added to the BFS queue for joint movement simulation. Used to ensure that each particle is only added to the queue once.

    Declaration
    public bool queuedForJMProcessing
    Field Value
    Type Description
    bool
    | Edit this page View Source

    queuedForPinConfigProcessing

    Flag indicating whether the particle has been added to the BFS queue for circuit discovery. Used to ensure that each particle is only added to the queue once.

    Declaration
    public bool queuedForPinConfigProcessing
    Field Value
    Type Description
    bool
    | Edit this page View Source

    receivedBeeps

    Flags indicating which partition sets have received a beep. Indices equal (local) partition set IDs.

    Declaration
    private BitArray receivedBeeps
    Field Value
    Type Description
    BitArray
    | Edit this page View Source

    receivedBeepsHistory

    The histories of received beeps for all partition sets.

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

    receivedMessages

    Array of the currently received messages. Indices are (local) partition set IDs.

    Declaration
    public Message[] receivedMessages
    Field Value
    Type Description
    Message[]
    | Edit this page View Source

    receivedMessagesHistory

    The histories of received messages for all partition sets.

    Declaration
    private ValueHistoryMessage[] receivedMessagesHistory
    Field Value
    Type Description
    ValueHistoryMessage[]
    | Edit this page View Source

    scheduledMovement

    The movement action scheduled during the current simulation round.

    Declaration
    private ParticleAction scheduledMovement
    Field Value
    Type Description
    ParticleAction
    | Edit this page View Source

    system

    The system containing this particle.

    Declaration
    public ParticleSystem system
    Field Value
    Type Description
    ParticleSystem
    | Edit this page View Source

    tailPosHistory

    The history of all global tail positions.

    Declaration
    private ValueHistory<Vector2Int> tailPosHistory
    Field Value
    Type Description
    ValueHistory<Vector2Int>
    | Edit this page View Source

    visibleBondHistory

    The history of all bond visibility settings.

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

    visibleBonds

    Flags indicating which bonds should be visible.

    Declaration
    private BitVector32 visibleBonds
    Field Value
    Type Description
    BitVector32
    | Edit this page View Source

    visibleBondsGlobal

    Visible bonds indexed by global labels.

    Declaration
    public bool[] visibleBondsGlobal
    Field Value
    Type Description
    bool[]

    Properties

    | Edit this page View Source

    CurrPinConfig

    The pin configuration at the beginning of the round.

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

    NextPinConfig

    The pin configuration to be set at the end of the round.

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

    ScheduledMovement

    Stores the movement action the particle scheduled during the current round. Used to find out if a particle intends to perform a movement to check if movements are consistent or will lead to conflicts.

    Reset this to null after applying the movement action.

    Declaration
    public ParticleAction ScheduledMovement { get; set; }
    Property Value
    Type Description
    ParticleAction

    Methods

    | Edit this page View Source

    ActivateBeep()

    This is the beep activation method of the particle. It is implemented by the particle algorithm and should be called exactly once in each round, after the movement activation.

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

    ActivateMove()

    This is the movement activation method of the particle. It is implemented by the particle algorithm and should be called exactly once in each round, before the beep activation.

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

    AddAttribute(IParticleAttribute)

    Adds the given IParticleAttribute to the particle's list of attributes. All attributes on this list will be displayed and editable in the simulation UI. This function is called by the ParticleAttributeFactory when it is called by this particle's ParticleAlgorithm to instantiate the attribute.

    Declaration
    public void AddAttribute(IParticleAttribute attr)
    Parameters
    Type Name Description
    IParticleAttribute attr

    The attribute to add to this particle's attribute list.

    | Edit this page View Source

    AlgorithmName()

    Gets the name of the algorithm running this particle's behavior.

    Declaration
    public string AlgorithmName()
    Returns
    Type Description
    string

    The unique display name of the algorithm running this particle.

    | Edit this page View Source

    ApplyNextPinConfiguration()

    Updates the current pin configuration to the next one for this round. Also transfers the beeps and messages scheduled on pins to the corresponding partition sets and resets them and resets the received beeps and messages.

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

    Apply_ContractHead(Vector2Int)

    Contracts this particle into the node occupied by its head and moves the particle by the specified global offset.

    Declaration
    public void Apply_ContractHead(Vector2Int offset)
    Parameters
    Type Name Description
    Vector2Int offset

    The global offset by which this particle moves in the system, relative to its head.

    Remarks

    The method will not check if this operation is valid.

    | Edit this page View Source

    Apply_ContractTail(Vector2Int)

    Contracts this particle into the node occupied by its tail and moves the particle by the specified global offset.

    Declaration
    public void Apply_ContractTail(Vector2Int offset)
    Parameters
    Type Name Description
    Vector2Int offset

    The global offset by which this particle moves in the system, relative to its tail.

    Remarks

    The method will not check if this operation is valid.

    | Edit this page View Source

    Apply_Expand(Direction)

    Expands this particle in the specified local direction.

    Declaration
    public void Apply_Expand(Direction locDir)
    Parameters
    Type Name Description
    Direction locDir

    The local direction into which this particle should expand.

    Remarks

    The method will not check if this operation is valid.

    | Edit this page View Source

    Apply_Expand(Direction, Vector2Int)

    Expands this particle in the specified local direction and moves it by the specified global offset.

    Declaration
    public void Apply_Expand(Direction locDir, Vector2Int offset)
    Parameters
    Type Name Description
    Direction locDir

    The local direction into which this particle should expand.

    Vector2Int offset

    The global offset by which this particle moves in the system, relative to its tail.

    Remarks

    The method will not check if this operation is valid.

    | Edit this page View Source

    Apply_Offset(Vector2Int)

    Moves the particle by the given global offset in the grid, without changing its expansion state.

    Declaration
    public void Apply_Offset(Vector2Int offset)
    Parameters
    Type Name Description
    Vector2Int offset

    The global offset by which the particle should be moved.

    | Edit this page View Source

    BondActive(int)

    Checks if the bond at the given label is still marked as active or will be released.

    See ReleaseBond(int).

    Declaration
    public bool BondActive(int label)
    Parameters
    Type Name Description
    int label

    The local label of the bond to be checked.

    Returns
    Type Description
    bool

    true if and only if the bond at the given label is still marked as active.

    | Edit this page View Source

    BondMarked(int)

    Checks if the bond at the given label is marked for special behavior.

    See MarkBond(int).

    Declaration
    public bool BondMarked(int label)
    Parameters
    Type Name Description
    int label

    The local label of the bond to be checked.

    Returns
    Type Description
    bool

    true if and only if the bond at the given label has been marked.

    | Edit this page View Source

    BondVisible(int)

    Checks if the bond at the given label is currently visible.

    See SetBondVisible(int, bool).

    Declaration
    public bool BondVisible(int label)
    Parameters
    Type Name Description
    int label

    The local label of the bond to be checked.

    Returns
    Type Description
    bool

    true if and only if the bond at the given label is currently visible.

    | Edit this page View Source

    Chirality()

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

    Declaration
    public bool Chirality()
    Returns
    Type Description
    bool

    The chirality of the particle.

    | Edit this page View Source

    CompassDir()

    Returns the global compass orientation of the particle. This is the global direction that the particle identifies as E in its local view.

    Declaration
    public Direction CompassDir()
    Returns
    Type Description
    Direction

    The global compass orientation of the particle.

    | 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

    CreateFromSaveState(ParticleSystem, ParticleStateSaveData)

    Initializes a new particle from the data stored in the given serializable object.

    Declaration
    public static Particle CreateFromSaveState(ParticleSystem system, ParticleStateSaveData data)
    Parameters
    Type Name Description
    ParticleSystem system

    The system in which the new particle should be created.

    ParticleStateSaveData data

    A serializable object created using GenerateSaveData() that stores the particle's state history.

    Returns
    Type Description
    Particle

    A new particle recovered from the serializable object.

    | Edit this page View Source

    CutOffAtMarker()

    Implementation of CutOffAtMarker().

    Note that a particle stores multiple value histories and their current marker positions may differ unless they were set to track the same round previously

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

    GenerateSaveData()

    Generates a serializable object that contains the current state and history of this particle.

    Declaration
    public ParticleStateSaveData GenerateSaveData()
    Returns
    Type Description
    ParticleStateSaveData

    A serializable object containing the entire state history of the particle.

    | Edit this page View Source

    GetAttributes()

    Gets this particle's list of IParticleAttributes. These attributes are supposed to be shown and edited in the simulation UI.

    Declaration
    public List<IParticleAttribute> GetAttributes()
    Returns
    Type Description
    List<IParticleAttribute>

    The list of IParticleAttributes belonging to this particle.

    | Edit this page View Source

    GetCircuitPinsPerSide()

    Returns the number of pins the particle's algorithm defines for each edge.

    Declaration
    public int GetCircuitPinsPerSide()
    Returns
    Type Description
    int

    The number of pins on each edge.

    | Edit this page View Source

    GetCurrentBondGraphicsInfo()

    Returns the currently loaded graphics information for bonds.

    Declaration
    public BondMovementInfoList GetCurrentBondGraphicsInfo()
    Returns
    Type Description
    BondMovementInfoList

    A BondMovementInfoList that holds the bond movement information for the currently loaded state.

    | Edit this page View Source

    GetCurrentMovementGraphicsInfo()

    Returns the currently loaded graphics information for joint movements.

    Declaration
    public JointMovementInfo GetCurrentMovementGraphicsInfo()
    Returns
    Type Description
    JointMovementInfo

    A JointMovementInfo that holds the joint movement information for the currently loaded state.

    | Edit this page View Source

    GetFirstRecordedRound()

    Implementation of GetFirstRecordedRound().

    Note that a particle stores multiple value histories and their first recorded rounds may differ.

    Declaration
    public int GetFirstRecordedRound()
    Returns
    Type Description
    int

    The first recorded round of one of the value histories that were initialized in the constructor.

    | Edit this page View Source

    GetGraphicsAdapter()

    Returns the graphics adapter for the particle.

    Declaration
    public IParticleGraphicsAdapter GetGraphicsAdapter()
    Returns
    Type Description
    IParticleGraphicsAdapter
    | Edit this page View Source

    GetMarkedRound()

    Implementation of GetMarkedRound().

    Note that a particle stores multiple value histories and their currently marked rounds may differ unless they were set to track the same round previously.

    Declaration
    public int GetMarkedRound()
    Returns
    Type Description
    int

    The currently marked round of one of the value histories that was initialized in the constructor.

    | Edit this page View Source

    GetParticleColor()

    Returns the main color of this particle.

    Call IsParticleColorSet() to check if this color has been set or not. If not, the particle's color should default to some other value.

    Declaration
    public Color GetParticleColor()
    Returns
    Type Description
    Color

    The current main color of this particle.

    | Edit this page View Source

    GetPlannedMessage(int)

    Returns the message planned for the specified partition set, if it exists.

    Declaration
    public Message GetPlannedMessage(int idx)
    Parameters
    Type Name Description
    int idx

    ID of the partition set from which to get the message.

    Returns
    Type Description
    Message

    The message planned for the specified partition set, if one has been planned, otherwise null.

    | Edit this page View Source

    GetReceivedMessage(int)

    Returns the message received by the specified partition set.

    Declaration
    public Message GetReceivedMessage(int idx)
    Parameters
    Type Name Description
    int idx

    The ID of the partition set.

    Returns
    Type Description
    Message

    A Message instance if the specified partition set has received one, otherwise null.

    | Edit this page View Source

    GlobalHeadDirection()

    Converts the particle's local direction that points from its tail towards its head into a global direction.

    Declaration
    public Direction GlobalHeadDirection()
    Returns
    Type Description
    Direction

    The global direction pointing from this particle's tail towards its head, if it is expanded, otherwise NONE.

    | Edit this page View Source

    GlobalHeadDirectionInt()

    The global direction of an expansion. Returns -1 if there is no expansion.

    Declaration
    public int GlobalHeadDirectionInt()
    Returns
    Type Description
    int
    | Edit this page View Source

    GlobalTailDirection()

    Converts the particle's local direction that points from its head towards its tail into a global direction.

    Declaration
    public Direction GlobalTailDirection()
    Returns
    Type Description
    Direction

    The global direction pointing from this particle's head towards its tail, if it is expanded, otherwise NONE.

    | Edit this page View Source

    HasPlannedBeep(int)

    Checks if the specified partition set has planned a beep.

    Declaration
    public bool HasPlannedBeep(int idx)
    Parameters
    Type Name Description
    int idx

    ID of the partition set to check.

    Returns
    Type Description
    bool

    true if and only if the partition set of the planned pin configuration with ID idx has planned a beep.

    | Edit this page View Source

    HasPlannedMessage(int)

    Checks if the specified partition set has planned a message.

    Declaration
    public bool HasPlannedMessage(int idx)
    Parameters
    Type Name Description
    int idx

    ID of the partition set to check.

    Returns
    Type Description
    bool

    true if and only if the partition set of the planned pin configuration with ID idx has planned a message.

    | Edit this page View Source

    HasPsetFailure(int)

    Checks if the specified partition set has suffered a failure.

    Declaration
    public bool HasPsetFailure(int idx)
    Parameters
    Type Name Description
    int idx

    ID of the partition set to check.

    Returns
    Type Description
    bool

    true if and only if the partition set with ID idx has suffered a failure.

    | Edit this page View Source

    HasReceivedBeep(int)

    Checks if the specified partition set has received a beep.

    Declaration
    public bool HasReceivedBeep(int idx)
    Parameters
    Type Name Description
    int idx

    ID of the partition set to check.

    Returns
    Type Description
    bool

    true if and only if the partition set with ID idx has received a beep.

    | Edit this page View Source

    HasReceivedMessage(int)

    Checks if the specified partition set has received a message.

    Declaration
    public bool HasReceivedMessage(int idx)
    Parameters
    Type Name Description
    int idx

    ID of the partition set to check.

    Returns
    Type Description
    bool

    true if and only if the partition set with ID idx has received a message.

    | Edit this page View Source

    Head()

    Returns the grid node on which the particle's head is currently positioned. When a particle expands, its part on the node it expands to becomes the particle's head. For contracted particles, the head and tail are on the same node.

    See Tail()

    Declaration
    public Vector2Int Head()
    Returns
    Type Description
    Vector2Int

    The node on which the particle's head is currently positioned.

    | Edit this page View Source

    HeadDirection()

    Returns the local direction pointing from the particle's tail towards its head.

    Declaration
    public Direction HeadDirection()
    Returns
    Type Description
    Direction

    The local direction pointing from the particle's tail towards its head, if it is expanded, otherwise NONE.

    | Edit this page View Source

    HeadDirection_After()

    Like HeadDirection(), but returns the predicted value for after the round.

    Declaration
    public Direction HeadDirection_After()
    Returns
    Type Description
    Direction

    The local direction pointing from the particle's tail towards its head, if it is expanded, otherwise NONE.

    | Edit this page View Source

    InitWithAlgorithm()

    Initialization to be called after the ParticleAlgorithm has been bound to this particle by instantiating it.

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

    InitWithAlgorithm(ParticleStateSaveData)

    Equivalent of InitWithAlgorithm() using data stored in a serializable object.

    Declaration
    private void InitWithAlgorithm(ParticleStateSaveData data)
    Parameters
    Type Name Description
    ParticleStateSaveData data

    The serializable object from which the particle's algorithm information should be recovered.

    | Edit this page View Source

    IsAnchor()

    Checks if the particle is currently the anchor of the system. The anchor particle defines how the system moves during a joint movement by keeping its global position.

    Declaration
    public bool IsAnchor()
    Returns
    Type Description
    bool

    true if and only if this particle is the anchor.

    | Edit this page View Source

    IsContracted()

    Checks if the particle is currently contracted, i.e., occupies exactly one node of the grid.

    See IsExpanded()

    Declaration
    public bool IsContracted()
    Returns
    Type Description
    bool

    true if and only if the particle is contracted.

    | Edit this page View Source

    IsContracted_After()

    Like IsContracted(), but returns the predicted value for after the round.

    Declaration
    public bool IsContracted_After()
    Returns
    Type Description
    bool

    true if and only if the particle will be contracted after the current round if its planned movements succeed.

    | Edit this page View Source

    IsExpanded()

    Checks if the particle is currently expanded, i.e., occupies 2 neighboring grid nodes simultaneously.

    See IsContracted()

    Declaration
    public bool IsExpanded()
    Returns
    Type Description
    bool

    true if and only if the particle is expanded.

    | Edit this page View Source

    IsExpanded_After()

    Like IsExpanded(), but returns the predicted value for after the round.

    Declaration
    public bool IsExpanded_After()
    Returns
    Type Description
    bool

    true if and only if the particle will be expanded after the current round if its planned movements succeed.

    | Edit this page View Source

    IsFinished()

    Checks whether the algorithm executed by this particle is finished.

    Declaration
    public bool IsFinished()
    Returns
    Type Description
    bool

    true if and only if the particle has finished executing its algorithm.

    | Edit this page View Source

    IsParticleColorSet()

    Checks whether the particle's main color has been overwritten.

    Declaration
    public bool IsParticleColorSet()
    Returns
    Type Description
    bool

    true if and only if the main color has been overwritten by the particle algorithm.

    | 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

    LogPsetFailure(int)

    Stores a partition set failure for the given partition set. This is done by the system so that failures can be stored in the history, allowing failures to be visualized while scrolling through the history and after loading a simulation state.

    Declaration
    public void LogPsetFailure(int idx)
    Parameters
    Type Name Description
    int idx

    The ID of the partition set on which the failure occurred.

    | Edit this page View Source

    MakeAnchor()

    Turns this particle into the anchor of the system. The anchor particle defines how the system moves during a joint movement by keeping its global position.

    Declaration
    public bool MakeAnchor()
    Returns
    Type Description
    bool

    true if and only if the particle was successfully turned into the anchor.

    | Edit this page View Source

    MarkBond(int)

    Marks the bond with the given label to have special behavior. This means that it will be pulled with an expansion movement or transferred during a handover contraction.

    See BondMarked(int).

    Declaration
    public void MarkBond(int label)
    Parameters
    Type Name Description
    int label

    The local label of the bond to be marked.

    | Edit this page View Source

    PlanBeepOnPartitionSet(int)

    Sets the flag that a beep should be sent on the given partition set.

    Declaration
    public void PlanBeepOnPartitionSet(int partitionSetID)
    Parameters
    Type Name Description
    int partitionSetID

    The ID of the partition set to send the beep.

    | Edit this page View Source

    PlanBeepOnPin(int)

    Sets the flag that a beep should be sent on the given pin.

    Declaration
    public void PlanBeepOnPin(int pinID)
    Parameters
    Type Name Description
    int pinID

    The ID of the pin to send the beep.

    | Edit this page View Source

    PlanMessageOnPartitionSet(int, Message)

    Stores the given message to be sent on the partition set with the given ID.

    Declaration
    public void PlanMessageOnPartitionSet(int partitionSetID, Message msg)
    Parameters
    Type Name Description
    int partitionSetID

    The ID of the partition set to send the message.

    Message msg

    The message to be sent.

    | Edit this page View Source

    PlanMessageOnPin(int, Message)

    Stores the given message to be sent on the given pin.

    Declaration
    public void PlanMessageOnPin(int pinID, Message msg)
    Parameters
    Type Name Description
    int pinID

    The ID of the pin to send the message.

    Message msg

    The message to be sent.

    | Edit this page View Source

    ReceiveBeep(int)

    Sets the flag that the partition set with the given ID has received a beep.

    Declaration
    public void ReceiveBeep(int idx)
    Parameters
    Type Name Description
    int idx

    The ID of the partition set to receive the beep.

    | Edit this page View Source

    ReceiveMessage(int, Message)

    Stores the given message to be recceived by the partition set with the given ID.

    Declaration
    public void ReceiveMessage(int idx, Message msg)
    Parameters
    Type Name Description
    int idx

    The ID of the partition set to receive the message.

    Message msg

    The message to be received.

    | Edit this page View Source

    ReleaseBond(int)

    Marks the bond with the given label to be released before the scheduled movement.

    See BondActive(int).

    Declaration
    public void ReleaseBond(int label)
    Parameters
    Type Name Description
    int label

    The local label of the bond to be released.

    | Edit this page View Source

    ResetAttributeIntermediateValues()

    Resets the intermediate values of all attributes so that they can be reused in the next round.

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

    ResetParticleColor()

    Resets the particle's main color to its default value.

    Should only be called during a simulation, i.e., while the system is in the tracking state.

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

    ResetPinConfigurationAfterMovement()

    Sets the next pin configuration to match the expansion state after a movement, deleting all received beeps and messages.

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

    ResetPlannedBeepsAndMessages()

    Deletes all planned beeps and messages to prepare for planning new ones in the next round. Also resets partition set failures.

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

    ResetReceivedBeepsAndMessages()

    Deletes all received beeps and messages to prepare for receiving new ones in the next round.

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

    ResetScheduledMovement()

    Resets the scheduled movement to null. Predicted state information is not reset.

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

    SetBondVisible(int, bool)

    Sets the visibility of the bond at the given label.

    See BondVisible(int).

    Declaration
    public void SetBondVisible(int label, bool visible)
    Parameters
    Type Name Description
    int label

    The local label of the bond.

    bool visible

    Whether the bond should be visible.

    | Edit this page View Source

    SetChirality(bool)

    Sets the particle's chirality to the given value. Only works if the particle is in a state that allows the chirality to be set.

    Declaration
    public void SetChirality(bool chirality)
    Parameters
    Type Name Description
    bool chirality

    The new chirality. true means counter-clockwise, false means clockwise.

    | Edit this page View Source

    SetCompassDir(Direction)

    Sets the particle's compass direction to the given value. Only works if the particle is in a state that allows the compass to be set.

    Declaration
    public void SetCompassDir(Direction compassDir)
    Parameters
    Type Name Description
    Direction compassDir

    The new compass direction, given as a global cardinal direction.

    | 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

    SetNextPinConfiguration(SysPinConfiguration)

    Sets the pin configuration to be applied at the end of the current round.

    This configuration must match the expansion state of the particle at the end of the round.

    After setting it to be the next configuration, it can be used to send beeps and messages. This ability expires if another pin configuration is set as the next one.

    Declaration
    public void SetNextPinConfiguration(SysPinConfiguration pc)
    Parameters
    Type Name Description
    SysPinConfiguration pc

    The new pin configuration.

    | Edit this page View Source

    SetParticleColor(Color)

    Sets this particle's main color.

    Should only be called during a simulation, i.e., while the system is in the tracking state.

    Declaration
    public void SetParticleColor(Color c)
    Parameters
    Type Name Description
    Color c

    The new main color of the particle.

    | Edit this page View Source

    SetScheduledMovement(ParticleAction)

    Sets the scheduled movement of this particle to the given action.

    Declaration
    private void SetScheduledMovement(ParticleAction a)
    Parameters
    Type Name Description
    ParticleAction a

    The new movement action.

    | 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

    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

    StoreAndResetMovementInfo()

    Stores the active and marked bond info in the particle's history and resets their values for the next round. All bonds are active again and no bonds are marked after this method is called.

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

    StoreBeepsAndMessages()

    Triggers the insertion of the planned and received beeps and messages into the history. Should be called after each activation, after the beeps and messages have been distributed.

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

    SwapNeighborCaches()

    Swaps the old and the new neighbor cache so that the new cache can be written and the current new cache is turned into the old cache.

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

    Tail()

    Returns the grid node on which the particle's tail is currently positioned. When a particle expands, its part on the node it originally occupies becomes the particle's tail. For contracted particles, the head and tail are on the same node.

    See Head()

    Declaration
    public Vector2Int Tail()
    Returns
    Type Description
    Vector2Int

    The node on which the particle's tail is currently positioned.

    | Edit this page View Source

    TailDirection()

    Returns the local direction pointing from the particle's head towards its tail.

    Declaration
    public Direction TailDirection()
    Returns
    Type Description
    Direction

    The local direction pointing from the particle's head towards its tail, if it is expanded, otherwise NONE.

    | Edit this page View Source

    TailDirection_After()

    Like TailDirection(), but returns the predicted value for after the round.

    Declaration
    public Direction TailDirection_After()
    Returns
    Type Description
    Direction

    The local direction pointing from the particle's head towards its tail, if it is expanded, otherwise NONE.

    | Edit this page View Source

    TryGetAttributeByName(string)

    Provides access to ParticleAttribute<T>s by their display names.

    Declaration
    public IParticleAttribute TryGetAttributeByName(string attrName)
    Parameters
    Type Name Description
    string attrName

    The display of the attribute to return.

    Returns
    Type Description
    IParticleAttribute

    The particle's attribute with the given name attrName if it exists, otherwise null.

    | Edit this page View Source

    UpdateInternalState()

    Helper that updates the private state variables after the histories were changed in any way.

    Also loads planned beeps and messages from the history, which must be reset before starting the next round.

    Declaration
    private void UpdateInternalState()

    Implements

    IParticleState
    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