utils

package utils

Members list

Type members

Classlikes

case class DecisionNode[Ctx, Res](predicate: Ctx => Boolean, trueBranch: DecisionTree[Ctx, Res], falseBranch: DecisionTree[Ctx, Res]) extends DecisionTree[Ctx, Res]

Represents a binary decision node in the decision tree.

Represents a binary decision node in the decision tree.

A DecisionNode evaluates a predicate against the context and branches to either a trueBranch or a falseBranch accordingly.

Type parameters

Ctx

The context type.

Res

The result type.

Value parameters

falseBranch

The DecisionTree to evaluate if the predicate returns false.

predicate

A function that takes the context and returns a boolean, determining the branch to follow.

trueBranch

The DecisionTree to evaluate if the predicate returns true.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait DecisionTree[Ctx, Res]
class Object
trait Matchable
class Any
Show all
sealed trait DecisionTree[Ctx, Res]

Represents a generic decision tree structure.

Represents a generic decision tree structure.

This sealed trait provides the common interface for all nodes within the decision tree, ensuring that any concrete node can evaluate a given context to produce a result. The use of a sealed trait ensures that all possible implementations are known at compile time, enabling exhaustive pattern matching and enhancing type safety.

Type parameters

Ctx

The type of the context (input) on which the decision tree operates.

Res

The type of the result (output) produced by the decision tree.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class DecisionNode[Ctx, Res]
class Leaf[Ctx, Res]
class MultiNode[Ctx, Key, Res]
case class Leaf[Ctx, Res](action: Ctx => Res) extends DecisionTree[Ctx, Res]

Represents a leaf node in the decision tree.

Represents a leaf node in the decision tree.

A Leaf node is a terminal point in the tree, directly providing a result based on an associated action function without further branching.

Type parameters

Ctx

The context type.

Res

The result type.

Value parameters

action

A function that takes the context and produces the final result for this leaf.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait DecisionTree[Ctx, Res]
class Object
trait Matchable
class Any
Show all
case class MultiNode[Ctx, Key, Res](keyOf: Ctx => Key, branches: Map[Key, DecisionTree[Ctx, Res]], default: DecisionTree[Ctx, Res]) extends DecisionTree[Ctx, Res]

Represents a multi-way decision node in the decision tree.

Represents a multi-way decision node in the decision tree.

A MultiNode dispatches to one of several branches based on a key extracted from the context. It includes a default branch for keys that do not have a specific corresponding branch.

Type parameters

Ctx

The context type.

Key

The type of the key extracted from the context.

Res

The result type.

Value parameters

branches

A map associating keys with their respective decision tree branches.

default

The default DecisionTree to evaluate if no matching key is found in 'branches'.

keyOf

A function that extracts a key from the context to select a branch.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait DecisionTree[Ctx, Res]
class Object
trait Matchable
class Any
Show all
enum Result[+T, +E]

A type representing either a successful value or an error.

A type representing either a successful value or an error.

Result[T, E] is similar to Either[E, T] but with more intuitive naming where T represents the success type and E represents the error type. This is commonly used for error handling without exceptions.

Type parameters

E

the type of the error value

T

the type of the success value

Attributes

Example
 val success: Result[Int, String] = Result.Success(42) val failure:
 Result[Int, String] = Result.Failure("Something went wrong")
val doubled = success.map(_ * 2) // Result.Success(84) val errorResult =
failure.map(_ * 2) // Result.Failure("Something went wrong") 
Companion
object
Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Result

Companion object for Result containing utility methods and extensions.

Companion object for Result containing utility methods and extensions.

Attributes

Companion
enum
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Result.type
object TriggerDSL

Object containing the Domain-Specific Language (DSL) for defining dynamic triggers.

Object containing the Domain-Specific Language (DSL) for defining dynamic triggers.

This DSL allows for the creation of clear, readable, and composable conditions used within the simulation's decision-making logic, such as in the DecisionManager.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
TriggerDSL.type
case class Vector2D(x: Double, y: Double)

A 2D vector with double precision coordinates.

A 2D vector with double precision coordinates.

Represents a point or direction in 2D space with x and y components. Provides common vector operations including arithmetic, dot product, magnitude calculation, and normalization.

Value parameters

x

the x-coordinate component

y

the y-coordinate component

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Vector2D

Companion object for Vector2D containing utility methods and constants.

Companion object for Vector2D containing utility methods and constants.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Vector2D.type