forked from renatocf/rugby-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
56 lines (43 loc) · 1.23 KB
/
main.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
54
55
56
// Standard headers
#include <stdio.h>
#include <stdlib.h>
// Internal headers
#include "attacker.h"
#include "defender.h"
#include "dimension.h"
#include "map.h"
#include "game.h"
// Macros
#define STANDARD_FIELD_DIMENSION (dimension_t){ 10, 10 }
#define STANDARD_MAX_NUMBER_SPIES 1LU
#define STANDARD_MAX_TURNS 42
/*----------------------------------------------------------------------------*/
/* MAIN FUNCTION */
/*----------------------------------------------------------------------------*/
int main(int argc, char** argv) {
if (argc >= 3) {
fprintf(stderr, "USAGE: %s [map_path]\n", argv[0]);
return EXIT_FAILURE;
}
printf("## RUGBY GAME ##\n\n");
Game game = NULL;
if (argc == 1) {
game = new_game(
STANDARD_FIELD_DIMENSION,
STANDARD_MAX_NUMBER_SPIES,
execute_attacker_strategy,
execute_defender_strategy);
}
if (argc == 2) {
Map map = new_map(argv[1]);
game = new_game_from_map(
map,
STANDARD_MAX_NUMBER_SPIES,
execute_attacker_strategy,
execute_defender_strategy);
delete_map(map);
}
play_game(game, STANDARD_MAX_TURNS);
delete_game(game);
return EXIT_SUCCESS;
}