From e840a3e58022e655f9057bbafc700c24a59d93db Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 23 Oct 2018 14:47:23 +0200 Subject: [PATCH] Remove unused variable dispersal --- lib/service/simulation_service.dart | 2 +- lib/src/Simulation.dart | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/service/simulation_service.dart b/lib/service/simulation_service.dart index 9d5a95b..fb2804e 100644 --- a/lib/service/simulation_service.dart +++ b/lib/service/simulation_service.dart @@ -14,7 +14,7 @@ class SimulationService { SimulationService(this._engine, [Simulation sim]) : this._sim = sim ?? Simulation(DEFAULT_GRID_SIZE, DEFAULT_GRID_SIZE) { _engine.simulation = _sim; - _sim.addRandomPattern(amount: 15, dispersal: 5); + _sim.addRandomPattern(amount: 15); } void reset() { diff --git a/lib/src/Simulation.dart b/lib/src/Simulation.dart index 8144646..5800f70 100644 --- a/lib/src/Simulation.dart +++ b/lib/src/Simulation.dart @@ -10,7 +10,6 @@ class Simulation { Grid _snapshot; final int _RANDOM_PATTERN_AMOUNT = 20; - final int _RANDOM_PATTERN_DISPERSAL = 10; final double _RANDOM_PATTERN_SPREAD_FROM_CENTER = 1 / 3; RuleSet rules = GameOfLife(); @@ -20,8 +19,6 @@ class Simulation { bool _renderEdges = true; bool get renderEdges => _renderEdges; - int _dispersal; - math.Point get gridSize => math.Point(map.width, map.height); void set gridSize(math.Point value) { if (value.x <= 0 || value.y <= 0) @@ -41,18 +38,16 @@ class Simulation { return map; } - void addRandomPattern( - {int seed, int amount, int dispersal, num spreadFromCenter}) { + void addRandomPattern({int seed, int amount, num spreadFromCenter}) { math.Random rng = _getRNG(seed ?? DateTime.now().millisecondsSinceEpoch); amount ??= rng.nextInt(_RANDOM_PATTERN_AMOUNT); - dispersal ??= _RANDOM_PATTERN_DISPERSAL; spreadFromCenter ??= _RANDOM_PATTERN_SPREAD_FROM_CENTER; int sanityCheck = 0; Map changeSet = {}; for (var i = 0; i < (amount); i++) { sanityCheck++; - math.Point cell = _getRandomPoint(rng, gridSize, spreadFromCenter); + math.Point cell = _getRandomPoint(rng, spreadFromCenter); getCellState(cell.x, cell.y) ? i-- : changeSet[map.toIndex(cell.x, cell.y)] = true; @@ -66,8 +61,7 @@ class Simulation { return rng; } - math.Point _getRandomPoint( - math.Random rng, math.Point size, num spreadFromCenter) { + math.Point _getRandomPoint(math.Random rng, num spreadFromCenter) { math.Point absoluteSpread = math.Point(map.width * spreadFromCenter, map.height * spreadFromCenter); math.Point center = math.Point(map.width / 2, map.height / 2);