-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.cc
51 lines (43 loc) · 1.07 KB
/
util.cc
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
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include "bot.h"
#include "util.h"
char move_str[5] = "RLUD";
// ---------------------------------------------------------
// Utility functions for testing and debugging
// Shoudn't be used in final solver code
int my_random_seed = 0;
int my_random() {
my_random_seed = my_random_seed * 1103515245 + 12345;
return my_random_seed % ((unsigned long)RAND_MAX + 1);
}
double now() {
return (double)clock() / CLOCKS_PER_SEC;
}
void print_urow(int urow[N]) {
printf("%d %d %d %d\n", urow[0], urow[1], urow[2], urow[3]);
}
void print_row(row_t r) {
printf("%04x\n", r);
}
void print_board(board_t b) {
printf("%04llx\n%04llx\n%04llx\n%04llx\n",
b & 0xffffll,
b >> 16 & 0xffffll,
b >> 32 & 0xffffll,
b >> 48 & 0xffffll);
}
void print_pretty_board(board_t b) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
int p = i * 4 + (3 - j);
int x = b >> (p*4) & 0xf;
if (x)
printf("%6d", 1<<x);
else
printf("%6s", ".");
}
printf("\n");
}
}