Table of Contents

Class DefaultGroupPlacementStrategy.Constraint

Namespace
RandomizerCore.Randomization
Assembly
RandomizerCore.dll
public record DefaultGroupPlacementStrategy.Constraint : IEquatable<DefaultGroupPlacementStrategy.Constraint>
Inheritance
DefaultGroupPlacementStrategy.Constraint
Implements
Inherited Members

Constructors

Constraint()

protected Constraint()

Constraint(Func<IRandoItem, IRandoLocation, bool>, Action<IRandoItem, IRandoLocation>?, string?)

public Constraint(Func<IRandoItem, IRandoLocation, bool> Test, Action<IRandoItem, IRandoLocation>? Fail = null, string? Label = null)

Parameters

Test Func<IRandoItem, IRandoLocation, bool>
Fail Action<IRandoItem, IRandoLocation>
Label string

Properties

Fail

public Action<IRandoItem, IRandoLocation>? Fail { get; init; }

Property Value

Action<IRandoItem, IRandoLocation>

Label

Optional identifying label

public string? Label { get; init; }

Property Value

string

Test

public Func<IRandoItem, IRandoLocation, bool> Test { get; init; }

Property Value

Func<IRandoItem, IRandoLocation, bool>

Methods

IsSatisfied(IRandoItem, IRandoLocation)

Return false to indicate that the item cannot be placed with the location, unless no constraint-satisfying alternatives exist.

public bool IsSatisfied(IRandoItem ri, IRandoLocation rl)

Parameters

ri IRandoItem
rl IRandoLocation

Returns

bool

OnViolated(IRandoItem, IRandoLocation)

Called when the constraint is not satisfied, but no constraint-satisfying alternatives exist. Exit normally to accept the placement, or throw OutOfLocationsException to trigger a new attempt. Throw other exceptions to halt randomization.

public void OnViolated(IRandoItem ri, IRandoLocation rl)

Parameters

ri IRandoItem
rl IRandoLocation