• Installation Guide
  • Amoebot Model
  • User Guide
  • Model Reference
  • Dev Guide
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • AS2
      • AlgorithmGenerator
      • AlgorithmGeneratorEditor
      • AlgorithmManager
      • AlgorithmManager.AlgorithmInfo
      • AmoebotFunctions
      • AmoebotSimulator
      • CameraUtils
      • CellRect
      • CellRect.CellRect_Iterator
      • ColorData
      • Config
      • ConfigData
      • ConfigData.AdditionalConfiguration
      • ConfigData.SettingsMenu
      • ConfigurationEditor
      • ConfigurationEditorBehavior
      • Constants
      • Direction
      • DirectionHelpers
      • EventDatabase
      • FileBrowser
      • FileBrowser.FileTypeHandler
      • FilePaths
      • InitModeSaveData
      • InitParticleSaveData
      • InitRandomWithHoles
      • Initialization
      • Initialization.Chirality
      • Initialization.Compass
      • InitializationMethod
      • InitializationMethod.DistanceSortedVectorList
      • InitializationMethodManager
      • InitializationMethodManager.AlgorithmInfo
      • InitializationStateSaveData
      • Log
      • MaterialDatabase
      • MessageSaveData
      • MinMax
      • MouseController
      • PSPlacementMode
      • ParticleAttributeEnumSaveData
      • ParticleAttributePCSaveData
      • ParticleAttributeSaveDataBase
      • ParticleAttributeSaveData<T>
      • ParticleObjectSaveData
      • ParticleStateSaveData
      • PinConfigurationHistorySaveData
      • PinConfigurationSaveData
      • RandomNumberGenerator
      • SaveStateUtility
      • SimulationStateSaveData
      • StatusInfoAttribute
      • TypeConverter
      • TypeConverter.ConversionResult
      • UIDatabase
      • ValueHistorySaveData<T>
    • AS2.Algos.BeepFailureTest
      • BeepFailureTestParticle
    • AS2.Algos.BinOpTest
      • BinOpTestInitializer
      • BinOpTestParticle
      • BinOpTestParticle.Mode
    • AS2.Algos.BoundaryTest
      • BoundaryTestParticle
      • Phase
      • SCMode
    • AS2.Algos.BoundaryTestSub
      • BoundaryTestSubParticle
    • AS2.Algos.ChiralityCompass
      • ChiralityAndCompassInitializer
      • ChiralityAndCompassParticle
      • CoinTossResult
      • DirectionMessage
    • AS2.Algos.CollisionTestAlgo
      • CollisionTestAlgoInitializer
      • CollisionTestAlgoParticle
    • AS2.Algos.CollisionTestAlgo2
      • CollisionTestAlgo2Initializer
      • CollisionTestAlgo2Particle
      • Role
    • AS2.Algos.ExpandedCircuitTest
      • ExpandedCircuitTestInitializer
      • ExpandedCircuitTestParticle
    • AS2.Algos.JMTest
      • JMTestInitializer
      • JMTestParticle
    • AS2.Algos.LeaderElection
      • LeaderElectionInitializer
      • LeaderElectionParticle
    • AS2.Algos.LineFormation
      • LineFormationInitializer
      • LineFormationParticleSync
      • LineFormationParticleSync.LFState
      • MyMessage
      • MyMessage.Direction
    • AS2.Algos.ObjectTest
      • ObjectTestInitializer
      • ObjectTestParticle
    • AS2.Algos.PASCTestAlgo
      • PASCTestAlgoInitializer
      • PASCTestAlgoParticle
    • AS2.Algos.SingleSourceSP
      • SingleSourceSPInitializer
      • SingleSourceSPParticle
      • SingleSourceSPParticle.Phase
    • AS2.Algos.SmartMaterial
      • SmartMaterialInitializer
      • SmartMaterialParticle
    • AS2.Algos.SubroutineTest
      • SubroutineTestInitializer
      • SubroutineTestParticle
    • AS2.Algos.SubroutineTest2
      • SubroutineTest2Initializer
      • SubroutineTest2Particle
    • AS2.Sim
      • ActionType
      • AlgorithmException
      • AmoebotSimException
      • BondMovementInfo
      • BondMovementInfoList
      • Circuit
      • CollisionChecker
      • CollisionChecker.DebugLine
      • EdgeMovement
      • IParticleAttribute
      • IParticleObject
      • IReplayHistory
      • InitializationParticle
      • InvalidActionException
      • JointMovementInfo
      • Message
      • Neighbor<T>
      • OpenInitParticle
      • Particle
      • ParticleAction
      • ParticleAlgorithm
      • ParticleAttributeBase
      • ParticleAttributeFactory
      • ParticleAttributeWithHistory<T>
      • ParticleAttribute_Bool
      • ParticleAttribute_Direction
      • ParticleAttribute_Enum<T>
      • ParticleAttribute_Float
      • ParticleAttribute_Int
      • ParticleAttribute_PinConfiguration
      • ParticleAttribute_String
      • ParticleAttribute<T>
      • ParticleException
      • ParticleFactory
      • ParticleObject
      • ParticleSystem
      • ParticleSystem_Utils
      • PartitionSet
      • Pin
      • PinConfiguration
      • SimulationException
      • SimulatorException
      • SimulatorStateException
      • SysPartitionSet
      • SysPin
      • SysPinConfiguration
      • ValueHistoryBondInfo
      • ValueHistoryJointMovement
      • ValueHistoryMessage
      • ValueHistoryPinConfiguration
      • ValueHistory<T>
    • AS2.Subroutines
      • Subroutine
    • AS2.Subroutines.BinStateHelpers
      • BinAttributeBitField
      • BinAttributeBool
      • BinAttributeDirection
      • BinAttributeEnum<T>
      • BinAttributeInt
      • BinAttribute<T>
    • AS2.Subroutines.BinaryOps
      • BinOpUtils
      • SubAddition
      • SubBinOps
      • SubBinOps.Mode
      • SubComparison
      • SubComparison.ComparisonResult
      • SubDivision
      • SubMSBDetection
      • SubMultiplication
      • SubSubtraction
    • AS2.Subroutines.BoundaryTest
      • SubBoundaryTest
    • AS2.Subroutines.ETT
      • Comparison
      • SubETT
    • AS2.Subroutines.LeaderElection
      • SubLeaderElection
    • AS2.Subroutines.LeaderElectionFast
      • SubLeaderElectionFast
    • AS2.Subroutines.LeaderElectionSync
      • SubLeaderElectionSync
    • AS2.Subroutines.PASC
      • SubPASC
      • SubPASC2
      • SubPASC2.NbrType
    • AS2.UI
      • ButtonHoldTrigger
      • ClickAction
      • ClickAction.ClickButton
      • ClickAction.ClickType
      • InitializationUIHandler
      • InputAction
      • InputAction.InputType
      • InputController
      • InputHandler
      • InputHandler.MouseState
      • InputManager
      • LineDrawer
      • LogUIHandler
      • LogUIHandler.EntryType
      • ObjectUIHandler
      • ParticleUIExtensionSmoothLerp
      • ParticleUIHandler
      • SettingsUIHandler
      • SizeFitter
      • Tooltip
      • TooltipHandler
      • UIHandler
      • UIHandler.UITool
      • UISetting
      • UISetting_Color
      • UISetting_Color.InputType
      • UISetting_Dropdown
      • UISetting_Header
      • UISetting_MinMax
      • UISetting_MinMax.InputType
      • UISetting_Slider
      • UISetting_Spacing
      • UISetting_Text
      • UISetting_Text.InputType
      • UISetting_Toggle
      • UISetting_ValueSlider
      • WorldSpaceBackgroundUIHandler
      • WorldSpaceUIHandler
      • WorldSpaceUIHandler.ParticleTextUIData
      • WorldSpaceUIHandler.TextType
    • AS2.Visuals
      • CircleDistributionCircleArea
      • CircleDistributionCircleLine
      • IGenerateDynamicMesh
      • IObjectInfo
      • IParticleGraphicsAdapter
      • IParticleState
      • InstancedDrawer
      • MaterialPropertyBlockData
      • MaterialPropertyBlockData_Circuits
      • MaterialPropertyBlockData_Objects
      • MaterialPropertyBlockData_Particles
      • MeshCreator_CircularView
      • MeshCreator_HexagonalView
      • ObjectGraphicsAdapter
      • ObjectGraphicsAdapter.VertexInfo
      • PSetDragHandler
      • ParticleBondGraphicState
      • ParticleGraphicsAdapterImpl
      • ParticleGraphicsAdapterImpl.ParticleMovement
      • ParticleGraphicsAdapterImpl.PositionSnap
      • ParticleJointMovementState
      • ParticleMovementState
      • ParticlePinGraphicState
      • ParticlePinGraphicState.CodeOverrideType_Node
      • ParticlePinGraphicState.NeighborPinConnection
      • ParticlePinGraphicState.PSetData
      • ParticlePinGraphicState.PSetData.GraphicalData
      • ParticlePinGraphicState.PSetData.GraphicalData.CodeOverrideType_PSet
      • ParticlePinGraphicState.PinDef
      • PartitionSetViewType
      • Polar2DCoordinate
      • PriorityQueue<T>
      • RenderBatchIndex
      • RenderSystem
      • RendererBackground
      • RendererCircuitPins_RenderBatch
      • RendererCircuitPins_RenderBatch.PropertyBlockData
      • RendererCircuitsAndBonds
      • RendererCircuits_Instance
      • RendererCircuits_Instance.GDRef
      • RendererCircuits_Instance.ParticleCircuitData
      • RendererCircuits_Instance.ParticleCircuitData.PSetInnerPinRef
      • RendererCircuits_Instance.ParticleCircuitData.PSetInnerPinRef.PinType
      • RendererCircuits_RenderBatch
      • RendererCircuits_RenderBatch.PropertyBlockData
      • RendererCircuits_RenderBatch.PropertyBlockData.ActiveState
      • RendererCircuits_RenderBatch.PropertyBlockData.LineType
      • RendererObjects
      • RendererParticles
      • RendererParticles_RenderBatch
      • RendererParticles_RenderBatch.PropertyBlockData
      • RendererUI
      • TextureCreator
      • ViewType
    • AS2.Visuals.Library
      • DegreeConstants
      • InterpolationConstants
      • MatrixConstants
      • MeshConstants
      • VectorConstants
      • BasicSample
      • CanvasSampleSaveFileImage
      • CanvasSampleSaveFileText
      • HexagonalExpansionPrototype

    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

    Circuit(int)

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

    Fields

    children

    The circuits merged into this one.

    Declaration
    private List<Circuit> children
    Field Value
    Type Description
    List<Circuit>

    color

    The color in which this circuit should be displayed.

    Declaration
    private Color color
    Field Value
    Type Description
    Color

    colorOverride

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

    Declaration
    private bool colorOverride
    Field Value
    Type Description
    bool

    hasBeep

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

    Declaration
    private bool hasBeep
    Field Value
    Type Description
    bool

    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

    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

    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

    pool

    A stack that contains the currently unused circuits.

    Declaration
    private static Stack<Circuit> pool
    Field Value
    Type Description
    Stack<Circuit>

    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

    NumPartitionSets

    The number of partition sets belonging to this circuit.

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

    Methods

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

    In this article
    Back to top AmoebotSim 2.0 Documentation v1.11
    Copyright © 2025 AmoebotSim 2.0 Authors
    Generated by DocFX