-
Notifications
You must be signed in to change notification settings - Fork 0
/
board_generate.c
53 lines (46 loc) · 1.13 KB
/
board_generate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
#include "board_generate.h"
#include "board.h"
void gen_board(int board_x_max, int board_y_max)
{
int max_artif = 4;
int max_treas = 6;
int mini = 0;
for (int i = 0; i < board_y_max; i++)
{
for (int j = 0; j < board_x_max; j++)
{
tab[i][j].game = 0;
tab[i][j].artif = (rand() % (max_artif - mini));
tab[i][j].treas = (rand() % (max_treas - mini));
}
}
}
void print_board(int board_x_max, int board_y_max)
{
printf(" ");
for (int i = 0; i < board_x_max; i++)
{
printf(" ");
if (i < 10)
printf(" %d", i);
else
printf(" %d", i);
}
printf("\n");
for (int i = 0; i < board_y_max; i++)
{
if (i < 10)
printf(" %d ", i);
else
printf(" %d ", i);
for (int j = 0; j < board_x_max; j++)
{
printf("%d", tab[i][j].treas);
printf("%d", tab[i][j].artif);
printf("%d ", tab[i][j].game);
}
printf("\n");
}
}