Class SubBoundaryTest
Subroutine implementation of BoundaryTestParticle.
Usage:
- Initialize by calling Init(bool). All amoebots must participate in the subroutine.
- Run SetupPC(PinConfiguration), then SetNextPinConfiguration(PinConfiguration) (if necessary) and ActivateSend() to start the procedure.
- In the round immediately following a ActivateSend() call, ActivateReceive() must be called. There can be an arbitrary break until the next pin configuration setup and ActivateSend() call. Continue this until the procedure is finished.
- You can call IsFinished() immediately after ActivateReceive() to check whether the procedure is finished. If it is, you can find the number of boundaries an amoebot is part of using NumBoundaries() and get boundary information with IsBoundaryLeader(int), IsOuterBoundary(int), GetBoundaryPredecessor(int) and GetBoundarySuccessor(int).
Namespace: AS2.Subroutines.BoundaryTest
Assembly: .dll
Syntax
public class SubBoundaryTest : Subroutine
Constructors
| Edit this page View SourceSubBoundaryTest(Particle, SubPASC[])
Declaration
public SubBoundaryTest(Particle p, SubPASC[] pascInstances = null)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | |
SubPASC[] | pascInstances |
Fields
| Edit this page View Sourceangles
Declaration
private BinAttributeInt[] angles
Field Value
Type | Description |
---|---|
BinAttributeInt[] |
auxCandidate
Declaration
private BinAttributeBool auxCandidate
Field Value
Type | Description |
---|---|
BinAttributeBool |
boundaryCandidate
Declaration
private BinAttributeBitField boundaryCandidate
Field Value
Type | Description |
---|---|
BinAttributeBitField |
boundaryDirs
Declaration
private BinAttributeDirection[] boundaryDirs
Field Value
Type | Description |
---|---|
BinAttributeDirection[] |
coinTossHeads
Declaration
private BinAttributeBitField coinTossHeads
Field Value
Type | Description |
---|---|
BinAttributeBitField |
controlColor
Declaration
private BinAttributeBool controlColor
Field Value
Type | Description |
---|---|
BinAttributeBool |
finished
Declaration
private BinAttributeBool finished
Field Value
Type | Description |
---|---|
BinAttributeBool |
innerBoundary
Declaration
private BinAttributeBitField innerBoundary
Field Value
Type | Description |
---|---|
BinAttributeBitField |
innerBoundaryExists
Declaration
private BinAttributeBool innerBoundaryExists
Field Value
Type | Description |
---|---|
BinAttributeBool |
iteration
Declaration
private BinAttributeInt iteration
Field Value
Type | Description |
---|---|
BinAttributeInt |
kappa
Declaration
private static readonly int kappa
Field Value
Type | Description |
---|---|
int |
numBoundaries
Declaration
private BinAttributeInt numBoundaries
Field Value
Type | Description |
---|---|
BinAttributeInt |
pasc
Declaration
private SubPASC[] pasc
Field Value
Type | Description |
---|---|
SubPASC[] |
round
Declaration
private BinAttributeInt round
Field Value
Type | Description |
---|---|
BinAttributeInt |
state1
Declaration
private ParticleAttribute<int> state1
Field Value
Type | Description |
---|---|
ParticleAttribute<int> |
state2
Declaration
private ParticleAttribute<int> state2
Field Value
Type | Description |
---|---|
ParticleAttribute<int> |
successorBit
Declaration
private BinAttributeBitField successorBit
Field Value
Type | Description |
---|---|
BinAttributeBitField |
successorExists
Declaration
private BinAttributeBitField successorExists
Field Value
Type | Description |
---|---|
BinAttributeBitField |
Methods
| Edit this page View SourceActivateReceive()
The first half of the subroutine activation. Must be called in the round immediately after ActivateSend() was called.
Declaration
public void ActivateReceive()
ActivateSend()
The second half of the subroutine activation. Before this can be called, the pin configuration set up by SetupPC(PinConfiguration) must be planned.
Declaration
public void ActivateSend()
GetBoundaryPredecessor(int)
Gets the predecessor direction on the given boundary.
Declaration
public Direction GetBoundaryPredecessor(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | The boundary index to check. |
Returns
Type | Description |
---|---|
Direction | The direction pointing from this amoebot to its
predecessor in a clockwise traversal of the boundary with
index |
GetBoundarySuccessor(int)
Gets the successor direction on the given boundary.
Declaration
public Direction GetBoundarySuccessor(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | The boundary index to check. |
Returns
Type | Description |
---|---|
Direction | The direction pointing from this amoebot to its
successor in a clockwise traversal of the boundary with
index |
Init(bool)
Initializes the subroutine. Must be called on all amoebots in the system.
Declaration
public void Init(bool controlColor = false)
Parameters
Type | Name | Description |
---|---|---|
bool | controlColor | Whether the subroutine should control the color of this amoebot. |
InnerBoundaryExists()
Checks whether an inner boundary was found during the procedure.
Declaration
public bool InnerBoundaryExists()
Returns
Type | Description |
---|---|
bool |
|
IsBoundaryLeader(int)
Checks whether this amoebot is the leader of the indicated boundary.
Declaration
public bool IsBoundaryLeader(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | The boundary index to check. |
Returns
Type | Description |
---|---|
bool |
|
IsFinished()
Checks whether the procedure is finished.
Declaration
public bool IsFinished()
Returns
Type | Description |
---|---|
bool |
|
IsOuterBoundary(int)
Checks whether the boundary with the given index is the outer boundary.
Declaration
public bool IsOuterBoundary(int idx)
Parameters
Type | Name | Description |
---|---|---|
int | idx | The boundary index to check. |
Returns
Type | Description |
---|---|
bool |
|
IsOuterBoundaryLeader()
Checks whether this amoebot is on the outer boundary leader.
Declaration
public bool IsOuterBoundaryLeader()
Returns
Type | Description |
---|---|
bool |
|
NumBoundaries()
Finds the number of boundaries this amoebot is on. If m is the number of boundaries, the boundary indices are 0,...,m-1.
Declaration
public int NumBoundaries()
Returns
Type | Description |
---|---|
int | The number of boundaries this amoebot is a part
of, or |
OnInnerBoundary()
Checks whether this amoebot is on the inner boundary.
Declaration
public bool OnInnerBoundary()
Returns
Type | Description |
---|---|
bool |
|
OnOuterBoundary()
Checks whether this amoebot is on the outer boundary.
Declaration
public bool OnOuterBoundary()
Returns
Type | Description |
---|---|
bool |
|
SetColor()
Declaration
private void SetColor()
SetupBoundaryCircuit(PinConfiguration, int, bool)
Sets up one or two boundary circuits for the given boundary.
The first circuit's partition set ID is boundaryIndex
* 2
and the second ID is boundaryIndex
* 2 + 1.
Declaration
private void SetupBoundaryCircuit(PinConfiguration pc, int boundaryIndex, bool addInner = true)
Parameters
Type | Name | Description |
---|---|---|
PinConfiguration | pc | The pin configuration to modify. |
int | boundaryIndex | The index of the boundary for which to setup the circuit. |
bool | addInner | Whether the second "inner" circuit should be setup as well. |
SetupGlobalCircuit(PinConfiguration, int, int)
Sets up a global circuit using the given pin offset.
Declaration
private void SetupGlobalCircuit(PinConfiguration pc, int offset, int pSet)
Parameters
Type | Name | Description |
---|---|---|
PinConfiguration | pc | The pin configuration to modify. |
int | offset | The pin offset. |
int | pSet | The partition set ID. |
SetupPC(PinConfiguration)
Sets up the pin configuration required for the ActivateSend() call. The next pin configuration is not set to another object by this method.
Declaration
public void SetupPC(PinConfiguration pc)
Parameters
Type | Name | Description |
---|---|---|
PinConfiguration | pc | The pin configuration to modify. |