Set up solve state

This commit is contained in:
Camden Dixie O'Brien 2025-03-22 13:33:38 +00:00
parent 67afbc1353
commit b2d9dcb6fe
2 changed files with 28 additions and 0 deletions

26
main.c
View File

@ -5,10 +5,14 @@
#include "puzz.h" #include "puzz.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/time.h> #include <sys/time.h>
enum { UNKNOWN = 0xfe };
int main(void) int main(void)
{ {
struct timeval tv; struct timeval tv;
@ -21,5 +25,27 @@ int main(void)
gen(); gen();
print(); print();
puzz_t field;
memset(field, UNKNOWN, sizeof(field));
for (int y = 0; y < HEIGHT; ++y) {
for (int x = 0; x < WIDTH; ++x) {
char c;
switch (field[x][y]) {
case UNKNOWN:
c = '?';
break;
case MINE:
c = 'x';
break;
default:
c = '0' + field[x][y];
break;
}
putchar(c);
}
putchar('\n');
}
return 0; return 0;
} }

2
puzz.c
View File

@ -42,9 +42,11 @@ void gen(void)
void print(void) void print(void)
{ {
puts("Solution:");
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)
putchar(soln[x][y] == MINE ? 'x' : '0' + soln[x][y]); putchar(soln[x][y] == MINE ? 'x' : '0' + soln[x][y]);
putchar('\n'); putchar('\n');
} }
putchar('\n');
} }