Search Results for

    Show / Hide Table of Contents

    Class Circuit

    Represents a collection of partition sets that are connected into a single circuit.

    Use the pooling mechanism (Get(int) and Free(Circuit)) to obtain and free instances.

    A tree structure is used for merging circuits. When one circuit is merged into another, all of its children and the circuit itself are added as children to the other circuit. All children of a root circuit dispatch operations to their root.

    Inheritance
    object
    Circuit
    Namespace: AS2.Sim
    Assembly: .dll
    Syntax
    public class Circuit

    Constructors

    | Edit this page View Source

    Circuit(int)

    Declaration
    private Circuit(int id)
    Parameters
    Type Name Description
    int id

    Fields

    | Edit this page View Source

    children

    The circuits merged into this one.

    Declaration
    private List<Circuit> children
    Field Value
    Type Description
    List<Circuit>
    | Edit this page View Source

    color

    The color in which this circuit should be displayed.

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

    colorOverride

    Indicates whether the circuit color has been set by a partition set.

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

    hasBeep

    Indicates whether a beep is sent on this circuit in this round.

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

    id

    The ID given to this circuit while computing circuits in a particle system. Used to easily identify and refer to circuits while merging.

    Declaration
    public int id
    Field Value
    Type Description
    int
    | Edit this page View Source

    message

    The message that is sent via this circuit in this round. null if no message is sent.

    Declaration
    private Message message
    Field Value
    Type Description
    Message
    | Edit this page View Source

    numPartitionSets

    The number of partition sets added directly to this circuit. Since this circuit might be merged into a larger one, this number is not always up to date.

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

    pool

    A stack that contains the currently unused circuits.

    Declaration
    private static Stack<Circuit> pool
    Field Value
    Type Description
    Stack<Circuit>
    | Edit this page View Source

    rootParent

    Reference to the root circuit that contains this one. null if this circuit is the root.

    Declaration
    private Circuit rootParent
    Field Value
    Type Description
    Circuit

    Properties

    | Edit this page View Source

    NumPartitionSets

    The number of partition sets belonging to this circuit.

    Declaration
    public int NumPartitionSets { get; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    AddPartitionSet(SysPartitionSet)

    Adds the given partition set to this circuit.

    If the partition set has a planned beep or message or has defined a display color, this information will be stored in the circuit.

    Declaration
    public void AddPartitionSet(SysPartitionSet ps)
    Parameters
    Type Name Description
    SysPartitionSet ps

    The partition set to be added.

    | Edit this page View Source

    AddPartitionSetRoot(SysPartitionSet)

    Counterpart to AddPartitionSet(SysPartitionSet) to be called on the root only.

    Declaration
    private void AddPartitionSetRoot(SysPartitionSet ps)
    Parameters
    Type Name Description
    SysPartitionSet ps

    The partition set to be added.

    | Edit this page View Source

    Free(Circuit)

    Returns the given circuit instance to the pool.

    Declaration
    public static void Free(Circuit c)
    Parameters
    Type Name Description
    Circuit c

    The circuit to be returned to the pool.

    | Edit this page View Source

    Get(int)

    Returns a new circuit instance with the given ID.

    Use Free(Circuit) on the instance when it is not needed anymore so that it can be reused later.

    Declaration
    public static Circuit Get(int id)
    Parameters
    Type Name Description
    int id

    The ID for the new circuit.

    Returns
    Type Description
    Circuit

    A new circuit instance obtained from the pool or newly created.

    | Edit this page View Source

    GetColor()

    Returns the color in which the circuit should be displayed. This may be one of the default colors or a color defined by a partition set.

    Declaration
    public Color GetColor()
    Returns
    Type Description
    Color

    The desired display color of the circuit.

    | Edit this page View Source

    GetMessage()

    Gets the message sent on this circuit in this round.

    Declaration
    public Message GetMessage()
    Returns
    Type Description
    Message

    The message sent on this circuit in this round, or null if no message was sent.

    | Edit this page View Source

    GetRoot()

    Returns the root circuit in this circuit's tree.

    Declaration
    private Circuit GetRoot()
    Returns
    Type Description
    Circuit

    The root of the circuit tree to which this circuit belongs.

    | Edit this page View Source

    HasBeep()

    Checks whether a beep has been sent on this circuit.

    Declaration
    public bool HasBeep()
    Returns
    Type Description
    bool

    true if and only if any partition set contained in this circuit sends a beep in this round.

    | Edit this page View Source

    HasColorOverride()

    Checks whether the color of this circuit was changed by a partition set.

    Declaration
    public bool HasColorOverride()
    Returns
    Type Description
    bool

    true if and only if a partition set in this circuit has defined a display color.

    | Edit this page View Source

    IsRoot()

    Checks whether this circuit is currently a root.

    Declaration
    public bool IsRoot()
    Returns
    Type Description
    bool

    true if and only if this circuit does not have a root parent.

    | Edit this page View Source

    MergeOther(Circuit)

    Merges the given other circuit into this one. If one of the circuits has a color override, that color is used. If both circuits have a color override, the color of this circuit is used.

    Declaration
    private void MergeOther(Circuit other)
    Parameters
    Type Name Description
    Circuit other

    The circuit to be merged into this one. It will be set to inactive after the merge.

    | Edit this page View Source

    MergeWith(Circuit)

    Merges this circuit with the given other circuit.

    Nothing happens if the other circuit is the same as this one. Otherwise, the smaller circuit is merged into the bigger one and the smaller one is set to be inactive. If one of the circuits has a planned beep, the resulting circuit will also have a planned beep. If any of the two circuits has a message, the message with the higher priority is sent on the resulting circuit. The color is determined by override if only one has a color set or by the larger one if both have a color override.

    Declaration
    public void MergeWith(Circuit other)
    Parameters
    Type Name Description
    Circuit other

    The circuit to merge this one with.

    | Edit this page View Source

    MergeWithRoot(Circuit)

    Counterpart to MergeWith(Circuit) to be called on the root only.

    Declaration
    private void MergeWithRoot(Circuit other)
    Parameters
    Type Name Description
    Circuit other

    The other circuit to merge with this root.

    | Edit this page View Source

    Reset(int)

    Completely reinitializes the circuit with a new ID.

    Declaration
    private void Reset(int id)
    Parameters
    Type Name Description
    int id

    The new ID.

    | Edit this page View Source

    SameCircuitAs(Circuit)

    Checks whether this circuit is part of the same tree as the given circuit.

    Declaration
    public bool SameCircuitAs(Circuit other)
    Parameters
    Type Name Description
    Circuit other

    The other circuit to be checked.

    Returns
    Type Description
    bool

    true if and only if the trees of this circuit and the other have the same root.

    | Edit this page View Source

    SetColor(Color)

    Sets the display color of this circuit.

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

    The new color in which the circuit should be displayed.

    • 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