Remove unnecessary Switch Case in Simulation

This commit is contained in:
Unknown 2018-10-17 21:07:48 +02:00
parent 9b2b5f3e55
commit e6e82f78f2
1 changed files with 10 additions and 12 deletions

View File

@ -43,19 +43,17 @@ class Simulation {
_dispersal = dispersal ?? 10; _dispersal = dispersal ?? 10;
int cx = x ?? rng.nextInt(map.width ~/ 3) + (map.width ~/ 3); int cx = x ?? rng.nextInt(map.width ~/ 3) + (map.width ~/ 3);
int cy = y ?? rng.nextInt(map.height ~/ 3) + (map.height ~/ 3); int cy = y ?? rng.nextInt(map.height ~/ 3) + (map.height ~/ 3);
switch (pattern) {
default: int sanityCheck = 0;
int sanityCheck = 0; for (var i = 0; i < (_amount); i++) {
for (var i = 0; i < (_amount); i++) { sanityCheck++;
sanityCheck++; getCellState(cx, cy)
getCellState(cx, cy) ? i--
? i-- : setCellState(
: setCellState(cx + rng.nextInt(_dispersal), cx + rng.nextInt(_dispersal), cy + rng.nextInt(_dispersal), true);
cy + rng.nextInt(_dispersal), true); if (sanityCheck > 100 && sanityCheck > i * 3) break;
if (sanityCheck > 100 && sanityCheck > i * 3) break;
}
break;
} }
_dirty = true; _dirty = true;
} }