summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/main.c b/main.c
index 0a8e97a..c863e01 100644
--- a/main.c
+++ b/main.c
@@ -17,12 +17,11 @@
void step(state_t *state)
{
- state->data[((state->dwidth / 2) * state->dwidth) + (state->dwidth / 2)]++;
for (size_t i = 0; i < state->dwidth; ++i)
for (size_t j = 0; j < state->dwidth; ++j)
if (state->data[(i * state->dwidth) + j] >= 4)
{
- unsigned char *references[] = {
+ uint64_t *references[] = {
(j == 0) ? NULL : &state->data[((i)*state->dwidth) + j - 1],
(i == state->dwidth - 1)
? NULL
@@ -33,8 +32,8 @@ void step(state_t *state)
(i == 0) ? NULL : &state->data[((i - 1) * state->dwidth) + j]};
for (size_t k = 0; k < 4; ++k)
if (references[k])
- *references[k] += 1;
- state->data[(i * state->dwidth) + j] = 0;
+ *references[k] += state->data[(i * state->dwidth) + j] / 4;
+ state->data[(i * state->dwidth) + j] %= 4;
}
}
@@ -97,8 +96,8 @@ int main(void)
for (size_t i = 0; i < state.dwidth; ++i)
for (size_t j = 0; j < state.dwidth; ++j)
{
- Color c = {0};
- unsigned char sandpile = state.data[(i * state.dwidth) + j];
+ Color c = {0};
+ uint64_t sandpile = state.data[(i * state.dwidth) + j];
if (sandpile == 0)
c = BLACK;
else if (sandpile == 1)