diff --git a/lib/src/Engine.dart b/lib/src/Engine.dart index e00b50f..59bcc66 100644 --- a/lib/src/Engine.dart +++ b/lib/src/Engine.dart @@ -102,7 +102,10 @@ class Engine { /// If simulation should be advanced manually one time, prefer using step(). void update() { // TODO: create hasUpdated/hasAdvanced method in simulation to abstract actual updating away - if (_simulation.update().length == 0) running = false; + Map simulationUpdate = _simulation.update(); + _simulation.mergeStateChanges(simulationUpdate); + + if (simulationUpdate.length == 0) running = false; } /// Advances Logic One Update diff --git a/lib/src/Simulation.dart b/lib/src/Simulation.dart index b0bbb46..8cc04ef 100644 --- a/lib/src/Simulation.dart +++ b/lib/src/Simulation.dart @@ -72,12 +72,14 @@ class Simulation { Map update() { Map stateChanges = calculateNextState(map); - - stateChanges.forEach((i, el) => map[i] = el); - stateChanges.length != 0 ? _dirty = true : false; return stateChanges; } + void mergeStateChanges(Map stateChanges) { + stateChanges.forEach((i, el) => map[i] = el); + if (stateChanges.length != 0) _dirty = true; + } + Map calculateNextState(Grid oldState) { Map stateChanges = Map();