Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions wled00/FX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5375,29 +5375,17 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
memset(cells, 0, dataSize);
random16_set_seed(strip.now>>2); //seed the random generator
unsigned cIndex = 0;
uint32_t xorshift32_state = random16();
const uint32_t threshold = (UINT32_MAX / 3);
for (unsigned y = 0; y < rows; ++y) for (unsigned x = 0; x < cols; ++x, ++cIndex) {
for (unsigned y = 0; y < rows; ++y) {
#if defined(ARDUINO_ARCH_ESP32)
// bool setAlive = esp_random() < 1374389534; // ~32%
// bool setAlive = random16(100) < 32;
// bool setAlive = (rand() & 0xFF) < 86;
// bool setAlive = random8(3);
uint32_t myrand = xorshift32_state;
myrand ^= myrand << 13;
myrand ^= myrand >> 17;
myrand ^= myrand << 5;
xorshift32_state = myrand;
bool setAlive = (myrand < threshold);
#else
bool setAlive = random16(100) < 32;
random16_add_entropy(esp_random() & 0xFFFF);
#endif
if (setAlive) {
grid.setCell(cIndex, x, y, true, wrap);
cells[cIndex].toggleStatus = 1; // Used to set initial color
for (unsigned x = 0; x < cols; ++x, ++cIndex) {
if ((random16() & 0xFF) < 82) { // ~32%
grid.setCell(cIndex, x, y, true, wrap);
cells[cIndex].toggleStatus = 1; // Used to set initial color
}
else cells[cIndex].superDead = 1;
}
else cells[cIndex].superDead = 1;

}
}

Expand Down