alter method

void alter({
  1. Map<Coordinate, Base>? state,
  2. List<Rule<Coordinate, Base>>? rules,
})

Creates a copy of the automaton with the given parameters.

Throws LockedStateException if the automaton is locked when called.

Implementation

void alter({
  Map<Coordinate, Base>? state,
  List<Rule<Coordinate, Base>>? rules,
}) {
  if (_locked) throw LockedStateException();

  _locked = true;
  if (state != null) {
    _state
      ..clear()
      ..addAll(state);
  }
  if (rules != null) {
    _rules
      ..clear()
      ..addAll(rules);
  }
  _locked = false;
}