From 950836214989fbcbae823d9a7a61dcfa8ff8241b Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Sat, 22 Mar 2025 13:33:38 +0000 Subject: [PATCH] Pick an initial point at random --- main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index dd3c873..393f70f 100644 --- a/main.c +++ b/main.c @@ -11,7 +11,7 @@ #include #include -enum { UNKNOWN = 0xfe }; +enum { UNKNOWN = 0xfe, KILLER = 0xfd }; int main(void) { @@ -28,6 +28,14 @@ int main(void) puzz_t field; memset(field, UNKNOWN, sizeof(field)); + const int x = rand() % WIDTH; + const int y = rand() % HEIGHT; + if (probe(x, y, field) == DEAD) { + field[x][y] = KILLER; + fprintf(stderr, "Dead\n"); + } + + putchar('\n'); for (int y = 0; y < HEIGHT; ++y) { for (int x = 0; x < WIDTH; ++x) { char c; @@ -35,6 +43,9 @@ int main(void) case UNKNOWN: c = '?'; break; + case KILLER: + c = '!'; + break; case MINE: c = 'x'; break;