Remove unused variable dispersal
This commit is contained in:
parent
474adb740c
commit
e840a3e580
2 changed files with 4 additions and 10 deletions
|
@ -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() {
|
||||
|
|
|
@ -10,7 +10,6 @@ class Simulation {
|
|||
Grid<bool> _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<int>(map.width, map.height);
|
||||
void set gridSize(math.Point<int> 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<int, bool> 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<int> _getRandomPoint(
|
||||
math.Random rng, math.Point size, num spreadFromCenter) {
|
||||
math.Point<int> _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);
|
||||
|
|
Loading…
Reference in a new issue