Pick an initial point at random

This commit is contained in:
Camden Dixie O'Brien 2025-03-22 13:33:38 +00:00
parent c8c382d9cc
commit 9508362149

13
main.c
View File

@ -11,7 +11,7 @@
#include <string.h>
#include <sys/time.h>
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;