From 4b35dbe5fc689c0401c0f846b062649cb5ac84fb Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 7 Jul 2018 20:47:23 +0200 Subject: [PATCH] Add Parameters for Dispersal and Amount of Cells --- lib/src/Grid.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/Grid.dart b/lib/src/Grid.dart index f188ae9..5649c6b 100644 --- a/lib/src/Grid.dart +++ b/lib/src/Grid.dart @@ -25,7 +25,7 @@ class Grid { print("Grid creation finished"); } - void startingPattern({Pattern pattern, int x, int y}) { + void startingPattern({Pattern pattern, int x, int y, int amount, int dispersal}) { math.Random rng = new math.Random(); int cx = x ?? rng.nextInt(w~/3) + (w~/3); int cy = y ?? rng.nextInt(h~/3) + (h~/3); @@ -56,8 +56,8 @@ class Grid { setCellState(0 + cx, 2 + cy, true); break; default: - for (var i = 0; i < rng.nextInt(20); i++) { - setCellState(cx + rng.nextInt(10), cy + rng.nextInt(10), true); + for (var i = 0; i < amount ?? rng.nextInt(20); i++) { + setCellState(cx + dispersal ?? rng.nextInt(10), cy + dispersal ?? rng.nextInt(10), true); } break; }