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 <string.h>
#include <sys/time.h> #include <sys/time.h>
enum { UNKNOWN = 0xfe }; enum { UNKNOWN = 0xfe, KILLER = 0xfd };
int main(void) int main(void)
{ {
@ -28,6 +28,14 @@ int main(void)
puzz_t field; puzz_t field;
memset(field, UNKNOWN, sizeof(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 y = 0; y < HEIGHT; ++y) {
for (int x = 0; x < WIDTH; ++x) { for (int x = 0; x < WIDTH; ++x) {
char c; char c;
@ -35,6 +43,9 @@ int main(void)
case UNKNOWN: case UNKNOWN:
c = '?'; c = '?';
break; break;
case KILLER:
c = '!';
break;
case MINE: case MINE:
c = 'x'; c = 'x';
break; break;