aboutsummaryrefslogtreecommitdiff
path: root/tools/200_solve_small/solve_small.c
blob: 4d07728b8e254fa433a654c3f14df584a593a366 (plain)
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 <pthread.h>

#include "../tool.h"

const char *solver = "h48";
const char *options = "0;4;20";
const char *filename = "tables/h48h0k4";
char *buf;

char *scrambles[] = {
	"R D' R2 D R U2 R' D' R U2 R D R'", /* 12 optimal */
	"RLUD RLUD RLUD", /* 12 optimal */
	NULL
};

void run(void) {
	int i;
	int64_t n;
	char sol[100], cube[22];

	printf("Solved the following scrambles:\n\n");
	for (i = 0; scrambles[i] != NULL; i++) {
		printf("%d. %s\n", i+1, scrambles[i]);
		fprintf(stderr, "Solving scramble %s\n", scrambles[i]);
		if (nissy_frommoves(scrambles[i], cube) == -1) {
			fprintf(stderr, "Invalid scramble\n");
			printf("Invalid\n");
			continue;
		}
		n = nissy_solve(
		    cube, "h48", options, "", 0, 20, 1, -1, buf, sol);
		if (n == 0) {
			printf("No solution\n");
			fprintf(stderr, "No solution found\n");
		} else {
			printf("Solutions:\n%s\n", sol);
		}
	}
}

int main(void) {

	srand(time(NULL));
	nissy_setlogger(log_stderr);

	if (getdata(solver, options, &buf, filename) != 0)
		return 1;

	timerun(run, "small solver benchmark");

	free(buf);
	return 0;
}

Generated with cgit - Back to sebastiano.tronto.net