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
Namespace: AS2.Sim
Assembly: .dll
Syntax
public class Particle : IParticleState, IReplayHistory
Constructors
| Edit this page View SourceParticle(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. |
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. |
Direction | initialHeadDir | The initial local head direction if the particle should be expanded. NONE will make the particle contracted. |
Fields
| Edit this page View SourceactiveBondHistory
The history of all active bond settings.
Declaration
private ValueHistory<int> activeBondHistory
Field Value
Type | Description |
---|---|
ValueHistory<int> |
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 |
activeBondsGlobal
Active bonds indexed by global labels.
Declaration
public bool[] activeBondsGlobal
Field Value
Type | Description |
---|---|
bool[] |
algorithm
The algorithm controlling this particle's behavior.
Declaration
public ParticleAlgorithm algorithm
Field Value
Type | Description |
---|---|
ParticleAlgorithm |
attributes
A list containing the particle's attributes.
Declaration
private List<IParticleAttribute> attributes
Field Value
Type | Description |
---|---|
List<IParticleAttribute> |
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> |
bondMovementHistory
History of bond information records.
Declaration
private ValueHistoryBondInfo bondMovementHistory
Field Value
Type | Description |
---|---|
ValueHistoryBondInfo |
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 |
comDir
The compass orientation of the particle, represented as a global direction.
Declaration
public readonly Direction comDir
Field Value
Type | Description |
---|---|
Direction |
currPinConfig
The pin configuration at the beginning of the round.
Declaration
private SysPinConfiguration currPinConfig
Field Value
Type | Description |
---|---|
SysPinConfiguration |
exp_expansionDir
The local direction pointing from the particle's tail towards its head.
Declaration
private Direction exp_expansionDir
Field Value
Type | Description |
---|---|
Direction |
exp_isExpanded
Indicates whether the particle is currently expanded.
Declaration
private bool exp_isExpanded
Field Value
Type | Description |
---|---|
bool |
expansionDirHistory
The history of all expansion directions.
Declaration
private ValueHistory<Direction> expansionDirHistory
Field Value
Type | Description |
---|---|
ValueHistory<Direction> |
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 |
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 |
hasPlannedBeeps
Indicates whether the particle has planned sending any beeps in this round.
Declaration
private bool hasPlannedBeeps
Field Value
Type | Description |
---|---|
bool |
hasPlannedMessages
Indicates whether the particle has planned sending any messages in this round.
Declaration
private bool hasPlannedMessages
Field Value
Type | Description |
---|---|
bool |
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 |
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 |
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 |
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 |
jmOffset
The absolute offset from the particle's initial location, accumulated by joint movements.
Declaration
public Vector2Int jmOffset
Field Value
Type | Description |
---|---|
Vector2Int |
jointMovementHistory
History of joint movement information records.
Declaration
private ValueHistoryJointMovement jointMovementHistory
Field Value
Type | Description |
---|---|
ValueHistoryJointMovement |
mainColor
The current particle color.
Declaration
private Color mainColor
Field Value
Type | Description |
---|---|
Color |
mainColorHistory
History of particle colors.
Declaration
private ValueHistory<Color> mainColorHistory
Field Value
Type | Description |
---|---|
ValueHistory<Color> |
mainColorSet
Indicates whether the particle color has been set.
Declaration
private bool mainColorSet
Field Value
Type | Description |
---|---|
bool |
mainColorSetHistory
History of flags showing whether the particle color is set.
Declaration
private ValueHistory<bool> mainColorSetHistory
Field Value
Type | Description |
---|---|
ValueHistory<bool> |
markedBondHistory
The history of all marked bond settings.
Declaration
private ValueHistory<int> markedBondHistory
Field Value
Type | Description |
---|---|
ValueHistory<int> |
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 |
markedBondsGlobal
Marked bonds indexed by global labels.
Declaration
public bool[] markedBondsGlobal
Field Value
Type | Description |
---|---|
bool[] |
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 |
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 |
neighborsNew
The current neighbors of the particle. Indices are global labels.
Declaration
public Particle[] neighborsNew
Field Value
Type | Description |
---|---|
Particle[] |
neighborsOld
The neighbors of the particle in the last round. Indices are global labels.
Declaration
public Particle[] neighborsOld
Field Value
Type | Description |
---|---|
Particle[] |
nextPinConfig
The pin configuration to be set at the end of the round.
Declaration
private SysPinConfiguration nextPinConfig
Field Value
Type | Description |
---|---|
SysPinConfiguration |
pinConfigurationHistory
The history of all pin configurations.
Declaration
private ValueHistoryPinConfiguration pinConfigurationHistory
Field Value
Type | Description |
---|---|
ValueHistoryPinConfiguration |
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 |
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> |
plannedBeepsHistory
The histories of sent beeps for all partition sets.
Declaration
private ValueHistory<bool>[] plannedBeepsHistory
Field Value
Type | Description |
---|---|
ValueHistory<bool>[] |
plannedMessageHistory
The histories of sent messages for all partition sets.
Declaration
private ValueHistoryMessage[] plannedMessageHistory
Field Value
Type | Description |
---|---|
ValueHistoryMessage[] |
plannedMessages
Array of the currently planned messages. Indices are (local) partition set IDs.
Declaration
private Message[] plannedMessages
Field Value
Type | Description |
---|---|
Message[] |
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> |
pos_head
The current global head position.
Declaration
private Vector2Int pos_head
Field Value
Type | Description |
---|---|
Vector2Int |
pos_tail
The current global tail position.
Declaration
private Vector2Int pos_tail
Field Value
Type | Description |
---|---|
Vector2Int |
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 |
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 |
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 |
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 |
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 |
psetFailureHistory
The histories of partition set failures for all partition sets.
Declaration
private ValueHistory<bool>[] psetFailureHistory
Field Value
Type | Description |
---|---|
ValueHistory<bool>[] |
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 |
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 |
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 |
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 |
receivedBeepsHistory
The histories of received beeps for all partition sets.
Declaration
private ValueHistory<bool>[] receivedBeepsHistory
Field Value
Type | Description |
---|---|
ValueHistory<bool>[] |
receivedMessages
Array of the currently received messages. Indices are (local) partition set IDs.
Declaration
public Message[] receivedMessages
Field Value
Type | Description |
---|---|
Message[] |
receivedMessagesHistory
The histories of received messages for all partition sets.
Declaration
private ValueHistoryMessage[] receivedMessagesHistory
Field Value
Type | Description |
---|---|
ValueHistoryMessage[] |
scheduledMovement
The movement action scheduled during the current simulation round.
Declaration
private ParticleAction scheduledMovement
Field Value
Type | Description |
---|---|
ParticleAction |
system
The system containing this particle.
Declaration
public ParticleSystem system
Field Value
Type | Description |
---|---|
ParticleSystem |
tailPosHistory
The history of all global tail positions.
Declaration
private ValueHistory<Vector2Int> tailPosHistory
Field Value
Type | Description |
---|---|
ValueHistory<Vector2Int> |
visibleBondHistory
The history of all bond visibility settings.
Declaration
private ValueHistory<int> visibleBondHistory
Field Value
Type | Description |
---|---|
ValueHistory<int> |
visibleBonds
Flags indicating which bonds should be visible.
Declaration
private BitVector32 visibleBonds
Field Value
Type | Description |
---|---|
BitVector32 |
visibleBondsGlobal
Visible bonds indexed by global labels.
Declaration
public bool[] visibleBondsGlobal
Field Value
Type | Description |
---|---|
bool[] |
Properties
| Edit this page View SourceCurrPinConfig
The pin configuration at the beginning of the round.
Declaration
public SysPinConfiguration CurrPinConfig { get; }
Property Value
Type | Description |
---|---|
SysPinConfiguration |
NextPinConfig
The pin configuration to be set at the end of the round.
Declaration
public SysPinConfiguration NextPinConfig { get; }
Property Value
Type | Description |
---|---|
SysPinConfiguration |
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 SourceActivateBeep()
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()
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()
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. |
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. |
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()
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.
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.
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.
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.
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. |
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 |
|
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 |
|
BondVisible(int)
Checks if the bond at the given label is currently visible.
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 |
|
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. |
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. |
ContinueTracking()
Resets the marker to track the latest recorded state and to continue evolving as the simulation progresses.
Declaration
public void ContinueTracking()
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. |
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()
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. |
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. |
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. |
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. |
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. |
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. |
GetGraphicsAdapter()
Returns the graphics adapter for the particle.
Declaration
public IParticleGraphicsAdapter GetGraphicsAdapter()
Returns
Type | Description |
---|---|
IParticleGraphicsAdapter |
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. |
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. |
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 |
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 |
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. |
GlobalHeadDirectionInt()
The global direction of an expansion. Returns -1 if there is no expansion.
Declaration
public int GlobalHeadDirectionInt()
Returns
Type | Description |
---|---|
int |
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. |
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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. |
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. |
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. |
InitWithAlgorithm()
Initialization to be called after the ParticleAlgorithm has been bound to this particle by instantiating it.
Declaration
public void InitWithAlgorithm()
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. |
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 |
|
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 |
|
IsContracted_After()
Like IsContracted(), but returns the predicted value for after the round.
Declaration
public bool IsContracted_After()
Returns
Type | Description |
---|---|
bool |
|
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 |
|
IsExpanded_After()
Like IsExpanded(), but returns the predicted value for after the round.
Declaration
public bool IsExpanded_After()
Returns
Type | Description |
---|---|
bool |
|
IsFinished()
Checks whether the algorithm executed by this particle is finished.
Declaration
public bool IsFinished()
Returns
Type | Description |
---|---|
bool |
|
IsParticleColorSet()
Checks whether the particle's main color has been overwritten.
Declaration
public bool IsParticleColorSet()
Returns
Type | Description |
---|---|
bool |
|
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. |
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. |
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 |
|
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
ResetAttributeIntermediateValues()
Resets the intermediate values of all attributes so that they can be reused in the next round.
Declaration
public void ResetAttributeIntermediateValues()
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()
ResetPinConfigurationAfterMovement()
Sets the next pin configuration to match the expansion state after a movement, deleting all received beeps and messages.
Declaration
private void ResetPinConfigurationAfterMovement()
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()
ResetReceivedBeepsAndMessages()
Deletes all received beeps and messages to prepare for receiving new ones in the next round.
Declaration
public void ResetReceivedBeepsAndMessages()
ResetScheduledMovement()
Resets the scheduled movement to null
.
Predicted state information is not reset.
Declaration
private void ResetScheduledMovement()
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
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()
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()
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()
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()
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()
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. |
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. |
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. |
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 |
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()