Search Results for

    Show / Hide Table of Contents

    Class PinConfiguration

    Developer API for pin configuration definition.

    Represents a complete pin configuration for a fixed expansion state. The object contains PartitionSet and Pin instances which are connected such that changes to one of the objects may cause changes in any of the other objects. For example, adding a pin to a partition set causes it to be removed from the partition set it was previously contained in.

    The position of a pin is uniquely defined by the edge it is located on and its offset on the edge. The pin indices on each edge are 0-based and increase in (local) counter-clockwise direction.

    Pins and partition sets have fixed IDs from 0 to NumPins - 1. The pin IDs are defined as edgeLabel * PinsPerEdge + edgeOffset. This means that the pins are numbered consecutively in (local) counter-clockwise direction, starting at edge label 0 and edge offset 0.

    Inheritance
    object
    PinConfiguration
    SysPinConfiguration
    Namespace: AS2.Sim
    Assembly: .dll
    Syntax
    public abstract class PinConfiguration

    Properties

    | Edit this page View Source

    HeadDirection

    The local head direction which encodes the expansion state of this pin configuration. If the state is contracted, this value is NONE.

    A pin configuration can only be applied if its expansion state matches the particle's expansion state at the end of the round.

    Declaration
    public abstract Direction HeadDirection { get; }
    Property Value
    Type Description
    Direction
    | Edit this page View Source

    NumPins

    The total number of pins in the pin configuration.

    For contracted particles, this number equals 6 * PinsPerEdge, and for expanded particles, it is 10 * PinsPerEdge.

    Declaration
    public abstract int NumPins { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    PinsPerEdge

    The number of pins per edge. This number is defined as a constant by the particle algorithm.

    Declaration
    public abstract int PinsPerEdge { get; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    GetNonEmptyPartitionSets()

    Returns all partition sets in the pin configuration that contain at least one pin.

    See also GetPartitionSets().

    Declaration
    public abstract PartitionSet[] GetNonEmptyPartitionSets()
    Returns
    Type Description
    PartitionSet[]

    An array containing the non-empty partition sets, ordered by their IDs. The number of returned partition sets is between 1 and NumPins.

    | Edit this page View Source

    GetPartitionSet(int)

    Returns the partition set with the given ID.

    Note that the ID of a partition set does not provide any information on the partition set's content. It is merely used to identify and refer to the partition set and to provide more control over which partition sets contain which pins.

    Declaration
    public abstract PartitionSet GetPartitionSet(int index)
    Parameters
    Type Name Description
    int index

    The index of the partition set to get. Must be in the range 0.,,,.NumPins-1.

    Returns
    Type Description
    PartitionSet

    The partition set with the given ID index.

    | Edit this page View Source

    GetPartitionSets()

    Returns all partition sets in the pin configuration.

    Note that the number of partition sets is always equal to NumPins since this is the maximum number of non-empty partition sets. Use GetNonEmptyPartitionSets() to get only the partition sets that contain at least one pin.

    Declaration
    public abstract PartitionSet[] GetPartitionSets()
    Returns
    Type Description
    PartitionSet[]

    An array of size NumPins containing all partition sets in this pin configuration. The index of a partition set in this array is its ID. Some of the partition sets may be empty.

    | Edit this page View Source

    GetPinAt(Direction, int, bool)

    Returns the pin with the given offset at the given edge.

    Declaration
    public abstract Pin GetPinAt(Direction direction, int offset, bool head = true)
    Parameters
    Type Name Description
    Direction direction

    The direction of the edge containing the pin.

    int offset

    The pin offset on the specified edge. Must be in the range 0,...,PinsPerEdge-1.

    bool head

    If the expansion state of the pin configuration is expanded, use this flag to indicate whether the edge belongs to the particle's head or not.

    Returns
    Type Description
    Pin

    The pin in the specified location.

    | Edit this page View Source

    GetPinId(Direction, int, int, Direction, bool)

    Helper to compute the ID of the pin on the specified edge with the given offset.

    The formula for the pin ID is label * pinsPerEdge + offset, where label is computed using direction, headDirection and head.

    Declaration
    public static int GetPinId(Direction direction, int offset, int pinsPerEdge, Direction headDirection = Direction.NONE, bool head = true)
    Parameters
    Type Name Description
    Direction direction

    The local direction of the edge.

    int offset

    The edge offset of the pin.

    int pinsPerEdge
    Direction headDirection
    bool head

    If the pin configuration represents the expanded state, this flag indicates whether the edge belongs to the particle's head or not.

    Returns
    Type Description
    int

    The ID of the pin in the location specified by an edge and an edge offset.

    | Edit this page View Source

    GetPinsAtEdge(Direction, bool)

    Returns all pins at the given edge.

    Declaration
    public abstract Pin[] GetPinsAtEdge(Direction direction, bool head = true)
    Parameters
    Type Name Description
    Direction direction

    The direction of the edge containing the pins.

    bool head

    If the expansion state of the pin configuration is expanded, use this flag to indicate whether the edge belongs to the particle's head or not.

    Returns
    Type Description
    Pin[]

    An array of size PinsPerEdge containing the pins at the specified edge, ordered by their edge offsets.

    | Edit this page View Source

    GetReceivedMessageOfPartitionSet(int)

    Returns the message received by the specified partition set, if it has received a message and this pin configuration is the current one.

    Declaration
    [Obsolete("This method is part of the old pin configuration system and does not work anymore. To receive beeps and messages, call the methods directly in the algorithm code or use GetCurrPinConfiguration.")]
    public Message GetReceivedMessageOfPartitionSet(int partitionSetIndex)
    Parameters
    Type Name Description
    int partitionSetIndex

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

    Returns
    Type Description
    Message

    A Message instance received by the partition set with ID partitionSetIndex, if it has received one, otherwise null.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this pin configuration is not the current one.

    | Edit this page View Source

    MakePartitionSet(Pin[], PartitionSet)

    Same as MakePartitionSet(int[], int), but the pins and the partition set are specified directly and not by their IDs. The array of pins will not be sorted.

    Declaration
    public abstract void MakePartitionSet(Pin[] pins, PartitionSet partitionSet)
    Parameters
    Type Name Description
    Pin[] pins

    The pins to be put into the given partition set.

    PartitionSet partitionSet
    | Edit this page View Source

    MakePartitionSet(Pin[], int)

    Same as MakePartitionSet(int[], int), but the pins are specified directly and not by their IDs. The array will not be sorted.

    Declaration
    public abstract void MakePartitionSet(Pin[] pins, int partitionSetIndex)
    Parameters
    Type Name Description
    Pin[] pins

    The pins to be put into the specified partition set.

    int partitionSetIndex

    The ID of the partition set that should hold the given set of pins.

    | Edit this page View Source

    MakePartitionSet(int[], PartitionSet)

    Same as MakePartitionSet(int[], int), but the partition set is specified directly instead of by its ID.

    Declaration
    public abstract void MakePartitionSet(int[] pinIds, PartitionSet partitionSet)
    Parameters
    Type Name Description
    int[] pinIds

    The IDs of the pins to be put into the given partition set.

    PartitionSet partitionSet

    The partition set that should hold the specified set of pins.

    | Edit this page View Source

    MakePartitionSet(int[], int)

    Sets the specified partition set to contain exactly the given pins.

    If the partition set already contains any pins that are not part of the given set, they are removed and put into their own singleton sets. If pinIds is empty, it may be impossible to put every removed pin into a singleton set, in which case an exception is thrown.

    The pinIds array will be sorted in ascending order.

    Declaration
    public abstract void MakePartitionSet(int[] pinIds, int partitionSetIndex)
    Parameters
    Type Name Description
    int[] pinIds

    The IDs of the pins to be put into the specified partition set.

    int partitionSetIndex

    The ID of the partition set that should hold the specified set of pins.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if pinIds is empty and not all pins can be inserted into empty partition sets.

    | Edit this page View Source

    ReceivedBeepOnPartitionSet(int)

    Checks whether the specified partition set has received a beep in the last round, if this pin configuration is the current one.

    Declaration
    [Obsolete("This method is part of the old pin configuration system and does not work anymore. To receive beeps and messages, call the methods directly in the algorithm code or use GetCurrPinConfiguration.")]
    public bool ReceivedBeepOnPartitionSet(int partitionSetIndex)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set to check.

    Returns
    Type Description
    bool

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

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this pin configuration is not the current one.

    | Edit this page View Source

    ReceivedMessageOnPartitionSet(int)

    Checks whether the specified partition set hat received a message in the last round, if this pin configuration is the current one.

    Declaration
    [Obsolete("This method is part of the old pin configuration system and does not work anymore. To receive beeps and messages, call the methods directly in the algorithm code or use GetCurrPinConfiguration.")]
    public bool ReceivedMessageOnPartitionSet(int partitionSetIndex)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set to check.

    Returns
    Type Description
    bool

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

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this pin configuration is not the current one.

    | Edit this page View Source

    ResetAllPartitionSetColors()

    Resets the color overrides of all partition sets.

    Declaration
    public abstract void ResetAllPartitionSetColors()
    | Edit this page View Source

    ResetPartitionSetColor(int)

    Resets the specified partition set's color override.

    See SetPartitionSetColor(int, Color).

    Declaration
    public abstract void ResetPartitionSetColor(int partitionSetIndex)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set whose color override to reset.

    | Edit this page View Source

    ResetPartitionSetDrawHandle(bool)

    Resets the handle draw flags of all partition sets in the given part of the particle to false.

    Declaration
    public abstract void ResetPartitionSetDrawHandle(bool head = true)
    Parameters
    Type Name Description
    bool head

    Whether the flag should be reset in the particle's head or tail.

    | Edit this page View Source

    ResetPartitionSetPlacement(bool)

    Resets the positions of the partition sets and sets the placement mode to NONE in the particle's head or tail.

    Declaration
    public abstract void ResetPartitionSetPlacement(bool head = true)
    Parameters
    Type Name Description
    bool head

    Indicates whether the partition sets should be reset in the particle's head or tail.

    | Edit this page View Source

    SendBeepOnPartitionSet(int)

    Sends a beep on the specified partition set, if this is the planned pin configuration.

    Declaration
    [Obsolete("This method is part of the old pin configuration system and does not work anymore. To send beeps and messages, call the methods directly in the algorithm code or use GetNextPinConfiguration.")]
    public void SendBeepOnPartitionSet(int partitionSetIndex)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set on which to send the beep.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if this pin configuration is not the planned one.

    | Edit this page View Source

    SendMessageOnPartitionSet(int, Message)

    Sends the given message on the specified partition set, if this pin configuration is the planned one.

    Note that a copy of the given Message instance msg is sent. Altering the instance after calling this method has no effect on the sent message.

    Declaration
    [Obsolete("This method is part of the old pin configuration system and does not work anymore. To send beeps and messages, call the methods directly in the algorithm code or use GetNextPinConfiguration.")]
    public void SendMessageOnPartitionSet(int partitionSetIndex, Message msg)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set on which to send the message.

    Message msg

    The message to be sent.

    | Edit this page View Source

    SetLineRotation(float, bool)

    Sets the rotation of the line on which the partition sets are arranged in LINE mode. Multiples of 30 or 60 degrees will usually look best. The placement mode is changed automatically.

    Declaration
    public abstract void SetLineRotation(float angle, bool head = true)
    Parameters
    Type Name Description
    float angle

    The new angle of the line in degrees. 0 means vertical (perpendicular to the local E direction) and increasing angles rotate the line in local counter-clockwise direction.

    bool head

    Indicates whether the rotation for the particle's head or tail part should be set. Must be true for contracted particles.

    | Edit this page View Source

    SetPSPlacementMode(PSPlacementMode, bool)

    Sets the partition set placement mode to the given value.

    Declaration
    public abstract void SetPSPlacementMode(PSPlacementMode mode, bool head = true)
    Parameters
    Type Name Description
    PSPlacementMode mode

    The new partition set placement mode.

    bool head

    Indicates whether the placement mode for the particle's head or tail will be set.

    | Edit this page View Source

    SetPartitionSetColor(int, Color)

    Overrides the specified partition set's color. The circuit to which the partition set belongs will be displayed in this color unless it has been overridden by another partition set already.

    See also ResetPartitionSetColor(int).

    Declaration
    public abstract void SetPartitionSetColor(int partitionSetIndex, Color color)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set whose color to override.

    Color color

    The color to set for the partition set.

    | Edit this page View Source

    SetPartitionSetDrawHandle(int, bool)

    Specifies whether the given partition set should always be drawn with a handle, even if it is a singleton set (but not if it is empty).

    Declaration
    public abstract void SetPartitionSetDrawHandle(int partitionSetIndex, bool drawHandle)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set whose handle draw setting to override.

    bool drawHandle

    Whether the handle should always be drawn.

    | Edit this page View Source

    SetPartitionSetPosition(int, Vector2, bool)

    Sets the specified partition set's position in polar coordinates and sets the positioning mode of the pin configuration to MANUAL.

    Declaration
    public abstract void SetPartitionSetPosition(int partitionSetIndex, Vector2 polarCoords, bool head = true)
    Parameters
    Type Name Description
    int partitionSetIndex

    The ID of the partition set whose position to set.

    Vector2 polarCoords

    The polar coordinates of the partition set's position inside of the particle as (angle, distance). An angle of 0 points in local direction E and angles increase in the local counter-clockwise direction. Distance 0 is the center of the particle (part) and distance 1 is on the edge of the particle.

    bool head

    Indicates whether the position in the particle's head or tail should be set. For contracted particles, this should be true.

    | Edit this page View Source

    SetStarConfig(int, PartitionSet)

    Same as SetStarConfig(int, int), but the partition set is specified directly and not by its ID.

    Declaration
    public abstract void SetStarConfig(int offset, PartitionSet partitionSet)
    Parameters
    Type Name Description
    int offset

    The edge offset of the pins to be collected in the star partition set.

    PartitionSet partitionSet

    The partition set that should hold the star pattern.

    | Edit this page View Source

    SetStarConfig(int, bool[], PartitionSet)

    Same as SetStarConfig(int, bool[], int), but the partition set is specified directly and not by its ID.

    Declaration
    public abstract void SetStarConfig(int offset, bool[] inverted, PartitionSet partitionSet)
    Parameters
    Type Name Description
    int offset

    The edge offset of the pins to be collected in the star partition set.

    bool[] inverted

    Array specifying for which edges the offset should be inverted. For any edge with a true entry, the inverted offset is computed as PinsPerEdge - 1 - offset. The array indices correspond to edge labels. The array must have length 6 for a contracted state and 10 for an expanded state.

    PartitionSet partitionSet

    The partition set that should hold the star pattern.

    | Edit this page View Source

    SetStarConfig(int, bool[], int)

    Sets the specified partition set to contain all pins with the given edge offset offset, where the offsets of certain edges are inverted as specified by the inverted array.

    This is an extension of the basic SetStarConfig(int, int) method.

    Declaration
    public abstract void SetStarConfig(int offset, bool[] inverted, int partitionSetIndex)
    Parameters
    Type Name Description
    int offset

    The edge offset of the pins to be collected in the star partition set.

    bool[] inverted

    Array specifying for which edges the offset should be inverted. For any edge with a true entry, the inverted offset is computed as PinsPerEdge - 1 - offset. The array indices correspond to edge labels. The array must have length 6 for a contracted state and 10 for an expanded state.

    int partitionSetIndex

    The ID of the partition set that should hold the star pattern.

    | Edit this page View Source

    SetStarConfig(int, int)

    Sets the specified partition set to contain all pins with the given edge offset offset.

    The partition set will thus contain exactly one pin for each edge. If it already contains any pins that do not have this offset, they are removed and put into their own singleton sets.

    See also SetStarConfig(int, PartitionSet), SetStarConfig(int, bool[], int).

    Declaration
    public abstract void SetStarConfig(int offset, int partitionSetIndex)
    Parameters
    Type Name Description
    int offset

    The edge offset of the pins to be collected in the star partition set.

    int partitionSetIndex

    The ID of the partition set that should hold the star pattern.

    | Edit this page View Source

    SetToGlobal(PartitionSet)

    Same as SetToGlobal(int), but the partition set to hold the pins is specified directly instead of by its ID.

    Declaration
    public abstract void SetToGlobal(PartitionSet partitionSet)
    Parameters
    Type Name Description
    PartitionSet partitionSet

    The partition set that should hold all pins.

    | Edit this page View Source

    SetToGlobal(int)

    Sets the pin configuration to the global pattern.

    In the global pattern, all pins are contained in a single partition set. If all particles in a connected system have this pin configuration, they form a global circuit on all pins simultaneously.

    Declaration
    public abstract void SetToGlobal(int partitionSetId = 0)
    Parameters
    Type Name Description
    int partitionSetId

    The ID of the partition set that should hold the pins.

    | Edit this page View Source

    SetToSingleton()

    Sets the pin configuration to the singleton pattern.

    In the singleton pattern, every pin constitutes its own partition set of size 1, i.e., there are no connections between any pins.

    Additionally, in this implementation, the pins are assigned to the partition sets such that their IDs match.

    Declaration
    public abstract void SetToSingleton()
    • 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