From bb981499a806ad030b265f3dcc85adc61955458c Mon Sep 17 00:00:00 2001 From: Eonwake <142854385+Avid-Xenoblade-Player@users.noreply.github.com> Date: Mon, 18 Mar 2024 19:29:44 +1100 Subject: [PATCH] Update new.js --- new.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/new.js b/new.js index 3eb290c..53999c2 100644 --- a/new.js +++ b/new.js @@ -43,7 +43,7 @@ function initializeGrid() { [WeatherState.BLACK]: 0.55, // 55% chance [WeatherState.BLUE]: 0.0, // 0% chance [WeatherState.MOUNTAIN]: 0.0, // 0% chance - [WeatherState.SNOW]: 0.0 // 0% chance + [WeatherState.SNOW]: 0.0, // 0% chance }; for (let x = 0; x < gridSize; x++) { @@ -74,7 +74,7 @@ function updateCell(x, y) { [WeatherState.BLUE]: 0, [WeatherState.MOUNTAIN]: 0, [WeatherState.SNOW]: 0, - }; + }; for (let dx = -1; dx <= 1; dx++) { for (let dy = -1; dy <= 1; dy++) { @@ -86,7 +86,7 @@ function updateCell(x, y) { stateCounts[neighborState]++; } } - + // Apply transition rules based on current state and surroundings switch (currentState) { case WeatherState.SNOW: @@ -109,14 +109,14 @@ function updateCell(x, y) { newState = WeatherState.MOUNTAIN; } if (stateCounts[WeatherState.MOUNTAIN] > 3 && - (getCell(x + 3, y + 3) == WeatherState.MOUNTAIN || - getCell(x + 3, y + 3) == WeatherState.SNOW) && - (getCell(x + 3, y - 3) == WeatherState.MOUNTAIN || - getCell(x + 3, y - 3) == WeatherState.SNOW) && - (getCell(x - 3, y + 3) == WeatherState.MOUNTAIN || - getCell(x - 3, y + 3) == WeatherState.SNOW) && - (getCell(x - 3, y - 3) == WeatherState.MOUNTAIN || - getCell(x - 3, y - 3) == WeatherState.SNOW) && + (getCell(x + 4, y + 4) == WeatherState.MOUNTAIN || + getCell(x + 4, y + 4) == WeatherState.SNOW) && + (getCell(x + 4, y - 4) == WeatherState.MOUNTAIN || + getCell(x + 4, y - 4) == WeatherState.SNOW) && + (getCell(x - 4, y + 4) == WeatherState.MOUNTAIN || + getCell(x - 4, y + 4) == WeatherState.SNOW) && + (getCell(x - 4, y - 4) == WeatherState.MOUNTAIN || + getCell(x - 4, y - 4) == WeatherState.SNOW) && stateCounts[WeatherState.BLACK] < 1) { newState = WeatherState.SNOW; } else {