Skip to content

Commit

Permalink
Update new.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Avid-Xenoblade-Player authored Mar 18, 2024
1 parent 4c85f58 commit bb98149
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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++) {
Expand All @@ -86,7 +86,7 @@ function updateCell(x, y) {
stateCounts[neighborState]++;
}
}

// Apply transition rules based on current state and surroundings
switch (currentState) {
case WeatherState.SNOW:
Expand All @@ -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 {
Expand Down

0 comments on commit bb98149

Please sign in to comment.