Environment

open class Environment<R>(val defaultRetainTime: Int = 1, val areConnected: (Environment<R>, Node<R>, Node<R>) -> Boolean = { _, _, _ -> true })

An environment with a set of nodes with a defaultRetainTime mapped into positions, which are considered connected if the areConnected function returns true for them.

Inheritors

Constructors

Link copied to clipboard
constructor(defaultRetainTime: Int = 1, areConnected: (Environment<R>, Node<R>, Node<R>) -> Boolean = { _, _, _ -> true })

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val nodes: Set<Node<R>>

The set of nodes in the environment.

Link copied to clipboard

The map of nodes and their positions in the environment.

Functions

Link copied to clipboard
fun addNode(position: Position, initial: R, retainTime: Int = defaultRetainTime, program: Aggregate<Int>.(environment: Environment<R>) -> R)

Adds a node to the environment at the given position with the given initial value and program.

Link copied to clipboard

Runs a Collektive cycles for all the nodes in the environment, from the node with the lowest id to the one with the highest, in order.

Link copied to clipboard

Runs a Collektive cycles for all the nodes in the environment, in random (but repeatable) order.

Link copied to clipboard

Runs a Collektive cycles for all the nodes in the environment, from the node with the lowest id to the one with the highest, in order.

Link copied to clipboard
operator fun get(id: Int): Node<R>

Returns the node with the given id, or throws exception if not found.

Link copied to clipboard
fun neighborsOf(node: Node<R>): List<Node<R>>

Retrieves the neighboring nodes of the provided node.

Link copied to clipboard
fun positionOf(node: Node<R>): Position

Retrieves the position of a node.

Retrieves the position of a node with the given id.

Link copied to clipboard
fun removeNode(nodeId: Int)

Removes a node from the environment.

Link copied to clipboard
fun status(): Map<Int, R>

Returns the current status of the environment as a map of node IDs to their values.

Link copied to clipboard
open override fun toString(): String