-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
53 lines (42 loc) · 1.14 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
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "cubically/src/rubiks.h"
#define u toupper
#define rubiksnotation(x) (u(x) == 'U' ? 0 : u(x) == 'L' ? 1 : u(x) == 'F' ? 2 : u(x) == 'R' ? 3 : u(x) == 'B' ? 4 : u(x) == 'D' ? 5 : -1)
extern void stdin_set(), stdin_reset();
extern int asize, *rotated;
int main(int argc, char **argv)
{
int move;
if (argc > 1)
CUBESIZE = atoi(argv[1]);
if (CUBESIZE < 0)
CUBESIZE = -CUBESIZE;
if (CUBESIZE < 2)
CUBESIZE = 3;
initcube();
stdin_set();
/* optimizations to speed up turns */
asize = 6 * CUBESIZE * CUBESIZE * sizeof(int);
rotated = malloc(asize);
int loop = 1;
int depth = 0;
while (loop) {
printf("\e[H\e[2J");
printcube(stderr);
printf("\n\e[0mDepth offset: %d\e[H",depth);
move = getchar();
if (move == 'E' || move == '&')
loop = 0;
else if (move == '+')
depth++;
else if (move == '-')
depth--;
move = rubiksnotation(move);
turncube(move,1,depth);
}
free(cube);
stdin_reset();
exit(EXIT_SUCCESS);
}