• 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 SubMultiplication

    Implements binary multiplication for two numbers a, b stored in the same chain.

    Computes a new binary number c := a * b. If the binary representation of c does not fit into the chain, only the lowermost bits are computed and an overflow is detected.

    This procedure requires at least 2 pins and it always uses the 2 "outermost / leftmost" pins when traversing the chain. If an amoebot occurs on the chain multiple times, its predecessor and successor directions must be different for all occurrences.

    Usage:

    • Establish a chain of amoebots such that each amoebot knows its predecessor and successor (except the start and end amoebots). Each amoebot should store a bit a and a bit b. The highest-value 1-bit of a must be marked.
    • Initialize using the Init(bool, bool, bool, Direction, Direction) method. You must pass the bits a and b, the marked MSB of a and the two directions. The start should have no predecessor and the end should have no successor.
    • Call SetupPinConfig(PinConfiguration) to modify the pin configuration.
    • Call ActivateSend() in the same round to start the procedure.
    • After this, call ActivateReceive(), SetupPinConfig(PinConfiguration), and ActivateSend() in this order in every round.
    • The procedure can be paused after each ActivateReceive() call and resumed by continuing with SetupPinConfig(PinConfiguration) in some future round.
    • Call IsFinished() after ActivateReceive() to check whether the multiplication is finished.
    • You can read the result bit c using Bit_C(). After each iteration, you can also read the bit a and the shifted bit b using Bit_A() and Bit_C().
    • If an overflow has occurred, HaveOverflow() will return true after the procedure has finished.
    Inheritance
    object
    Subroutine
    SubMultiplication
    Namespace: AS2.Subroutines.BinaryOps
    Assembly: .dll
    Syntax
    public class SubMultiplication : Subroutine

    Constructors

    SubMultiplication(Particle, ParticleAttribute<int>)

    Declaration
    public SubMultiplication(Particle p, ParticleAttribute<int> stateAttr = null)
    Parameters
    Type Name Description
    Particle p
    ParticleAttribute<int> stateAttr

    Fields

    bit_A

    Declaration
    private const int bit_A = 2
    Field Value
    Type Description
    int

    bit_Add

    Declaration
    private const int bit_Add = 14
    Field Value
    Type Description
    int

    bit_B

    Declaration
    private const int bit_B = 3
    Field Value
    Type Description
    int

    bit_C

    Declaration
    private const int bit_C = 4
    Field Value
    Type Description
    int

    bit_Finished

    Declaration
    private const int bit_Finished = 13
    Field Value
    Type Description
    int

    bit_MSB_A

    Declaration
    private const int bit_MSB_A = 6
    Field Value
    Type Description
    int

    bit_Overflow

    Declaration
    private const int bit_Overflow = 15
    Field Value
    Type Description
    int

    bit_ShiftError

    Declaration
    private const int bit_ShiftError = 16
    Field Value
    Type Description
    int

    bit_Token

    Declaration
    private const int bit_Token = 5
    Field Value
    Type Description
    int

    state

    Declaration
    private ParticleAttribute<int> state
    Field Value
    Type Description
    ParticleAttribute<int>

    Methods

    ActivateReceive()

    Activation during ActivateBeep() to receive the beeps sent in the last round. Should always be called before SetupPinConfig(PinConfiguration) and ActivateSend(), except in the very first activation, where it should not be called.

    Declaration
    public void ActivateReceive()

    ActivateSend()

    Activation during ActivateBeep() to send the beeps required for this step. Must be called after ActivateReceive() and SetupPinConfig(PinConfiguration).

    Declaration
    public void ActivateSend()

    Bit_A()

    This amoebot's bit of a.

    Declaration
    public bool Bit_A()
    Returns
    Type Description
    bool

    Whether this amoebot's bit of a is equal to 1.

    Bit_B()

    This amoebot's bit of b. Note that b will be shifted along the chain during the procedure, one step per iteration.

    Declaration
    public bool Bit_B()
    Returns
    Type Description
    bool

    Whether this amoebot's bit of b is equal to 1.

    Bit_C()

    This amoebot's bit of c, the result of multiplying a and b.

    Declaration
    public bool Bit_C()
    Returns
    Type Description
    bool

    Whether this amoebot's bit of c is equal to 1.

    GetStateBit(int)

    Helper for reading a single bit from the state integer.

    Declaration
    private bool GetStateBit(int bit)
    Parameters
    Type Name Description
    int bit

    The position of the bit.

    Returns
    Type Description
    bool

    The value of the state bit at position bit.

    HaveOverflow()

    Checks whether an overflow occurred during the multiplication. Should only be called once the procedure has finished.

    Declaration
    public bool HaveOverflow()
    Returns
    Type Description
    bool

    true if and only if a 1-bit of b was shifted or a carry bit was sent beyond the end of the chain.

    Init(bool, bool, bool, Direction, Direction)

    Initializes the subroutine. Must be called by each amoebot on the chain that stores a and b.

    Declaration
    public void Init(bool a, bool b, bool msbA, Direction predDir, Direction succDir)
    Parameters
    Type Name Description
    bool a

    This amoebot's bit of a.

    bool b

    This amoebot's bit of b.

    bool msbA

    Whether this amoebot is the highest-value 1-bit of a.

    Direction predDir

    The direction of the predecessor. Should be NONE only at the start of the chain.

    Direction succDir

    The direction of the successor. Should be NONE only at the end of the chain.

    IsFinished()

    Checks whether the procedure is finished. Should be called after ActivateReceive().

    Declaration
    public bool IsFinished()
    Returns
    Type Description
    bool

    true if and only if the multiplication procedure has finished.

    PredDir()

    Helper for reading the predecessor direction from the state integer.

    Declaration
    private Direction PredDir()
    Returns
    Type Description
    Direction

    The direction of the chain predecessor.

    Round()

    Helper for reading the round number from the state integer.

    Declaration
    private int Round()
    Returns
    Type Description
    int

    The current round number.

    SetRound(int)

    Helper for setting the round counter.

    Declaration
    private void SetRound(int round)
    Parameters
    Type Name Description
    int round

    The new value of the round counter.

    SetStateBit(int, bool)

    Helper for setting a single bit from the state integer.

    Declaration
    private void SetStateBit(int bit, bool value)
    Parameters
    Type Name Description
    int bit

    The position of the bit.

    bool value

    The new value of the bit.

    SetupPinConfig(PinConfiguration)

    Sets up the required circuits for the next step in the given pin configuration. This must be called after ActivateReceive() and before ActivateSend().

    Declaration
    public void SetupPinConfig(PinConfiguration pc)
    Parameters
    Type Name Description
    PinConfiguration pc

    The pin configuration to set up. Partition set IDs will always equal one of the IDs of the contained pins.

    SuccDir()

    Helper for reading the successor direction from the state integer.

    Declaration
    private Direction SuccDir()
    Returns
    Type Description
    Direction

    The direction of the chain successor.

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