-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.c
64 lines (54 loc) · 1.45 KB
/
demo.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
57
58
59
60
61
62
63
64
#include <time.h>
#include "jkiss/jkiss.h"
#include "pujobot/util.h"
#include "pujobot/bitboard.h"
#include "pujobot/screen.h"
#include "pujobot/game.h"
#include "pujobot/ai.h"
void advance_bag(color_t *bag, size_t horizon) {
for (size_t i = 0; i < horizon - 1; ++i) {
bag[2*i+0] = bag[2*i+2];
bag[2*i+1] = bag[2*i+3];
}
bag[2*(horizon-1)+0] = rand() % COLOR_SELECTION_SIZE;
bag[2*(horizon-1)+1] = rand() % COLOR_SELECTION_SIZE;
}
void play_demo() {
simple_game g;
clear_simple_game(&g);
g.screen.jkiss = jkiss32_spawn();
size_t horizon = 3;
color_t *bag = calloc(2 * horizon, sizeof(color_t));
for (size_t i = 0; i < horizon; ++i) {
advance_bag(bag, horizon);
}
int score = 0;
for (int i = 0; i < 200; ++i) {
if (rand() < RAND_MAX / 12) {
if (rand() < RAND_MAX / 2) {
g.pending_garbage += (rand() % 25) + (rand() % 25);
} else {
g.late_garbage += (rand() % 25) + (rand() % 25);
g.late_time_remaining = rand() % 100;
}
}
double heuristic_score;
move_t move = flex_droplet_strategy_3(&g, bag, 2*horizon, &heuristic_score);
play_simple(&g, bag, move);
advance_bag(bag, horizon);
int move_score = resolve_simple(&g);
score += move_score;
print_simple_game(&g);
printf("Score: %d\n", score);
if (move_score < 0) {
clear_simple_game(&g);
}
}
free(bag);
}
int main() {
srand(time(0));
jkiss_init();
play_demo();
return EXIT_SUCCESS;
}