diff --git a/2048_curses.c b/2048_curses.c index 6a39edf..ed20983 100644 --- a/2048_curses.c +++ b/2048_curses.c @@ -182,14 +182,14 @@ int space_left() return 0; } -/* places a random block onto the grid */ +/* places a random block onto the grid - either a 4, or a 2 with a chance of 1:3 respectively */ /* could do this in a much smarter fashion by finding which spaces are free */ void rand_block() { if (space_left()) { int x_p, y_p; while (g[x_p = rand() % SZ][y_p = rand() % SZ]); - g[x_p][y_p] = 2; + g[x_p][y_p] = (rand() & 3) ? 2 : 4; } else { endwin(); diff --git a/2048_no_curses.c b/2048_no_curses.c index 0b87647..956d79e 100644 --- a/2048_no_curses.c +++ b/2048_no_curses.c @@ -181,14 +181,14 @@ int space_left() return 0; } -/* places a random block onto the grid */ +/* places a random block onto the grid - either a 4, or a 2 with a ratio of 1:3 respectively */ /* do this in a smarter fashion */ void rand_block() { if (space_left()) { int x_p, y_p; while (g[x_p = rand() % SZ][y_p = rand() % SZ]); - g[x_p][y_p] = 2; + g[x_p][y_p] = (rand() & 3) ? 2 : 4; } else { printf("\n"