Pick an initial point at random
This commit is contained in:
parent
c8c382d9cc
commit
9508362149
13
main.c
13
main.c
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user