Compare commits
8 Commits
refactor
...
34a59546e6
| Author | SHA1 | Date | |
|---|---|---|---|
| 34a59546e6 | |||
| 9e2421accf | |||
| 52ca8b208c | |||
|
|
140d37fbd9 | ||
|
|
2b3581a400 | ||
| a6b1fae230 | |||
|
|
8c672e24ad | ||
|
|
815756b5e9 |
@@ -1,572 +0,0 @@
|
|||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"blocks": [
|
|
||||||
{"cellIDs": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
9,
|
|
||||||
10,
|
|
||||||
11,
|
|
||||||
18,
|
|
||||||
19,
|
|
||||||
20
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
12,
|
|
||||||
13,
|
|
||||||
14,
|
|
||||||
21,
|
|
||||||
22,
|
|
||||||
23
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
6,
|
|
||||||
7,
|
|
||||||
8,
|
|
||||||
15,
|
|
||||||
16,
|
|
||||||
17,
|
|
||||||
24,
|
|
||||||
25,
|
|
||||||
26
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
27,
|
|
||||||
28,
|
|
||||||
29,
|
|
||||||
36,
|
|
||||||
37,
|
|
||||||
38,
|
|
||||||
45,
|
|
||||||
46,
|
|
||||||
47
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
32,
|
|
||||||
39,
|
|
||||||
40,
|
|
||||||
41,
|
|
||||||
48,
|
|
||||||
49,
|
|
||||||
50
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
33,
|
|
||||||
34,
|
|
||||||
35,
|
|
||||||
42,
|
|
||||||
43,
|
|
||||||
44,
|
|
||||||
51,
|
|
||||||
52,
|
|
||||||
53
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
54,
|
|
||||||
55,
|
|
||||||
56,
|
|
||||||
63,
|
|
||||||
64,
|
|
||||||
65,
|
|
||||||
72,
|
|
||||||
73,
|
|
||||||
74
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
57,
|
|
||||||
58,
|
|
||||||
59,
|
|
||||||
66,
|
|
||||||
67,
|
|
||||||
68,
|
|
||||||
75,
|
|
||||||
76,
|
|
||||||
77
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
62,
|
|
||||||
69,
|
|
||||||
70,
|
|
||||||
71,
|
|
||||||
78,
|
|
||||||
79,
|
|
||||||
80
|
|
||||||
]}
|
|
||||||
],
|
|
||||||
"multidoku": [{
|
|
||||||
"blockWidth": 3,
|
|
||||||
"cells": [
|
|
||||||
0,
|
|
||||||
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,
|
|
||||||
65,
|
|
||||||
66,
|
|
||||||
67,
|
|
||||||
68,
|
|
||||||
69,
|
|
||||||
70,
|
|
||||||
71,
|
|
||||||
72,
|
|
||||||
73,
|
|
||||||
74,
|
|
||||||
75,
|
|
||||||
76,
|
|
||||||
77,
|
|
||||||
78,
|
|
||||||
79,
|
|
||||||
80
|
|
||||||
],
|
|
||||||
"blocks": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
6,
|
|
||||||
7,
|
|
||||||
8
|
|
||||||
],
|
|
||||||
"constraints": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
@@ -1,572 +0,0 @@
|
|||||||
{
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 0,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 1,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 2,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 3,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 4,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 5,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 6
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 6,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 7
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 7,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"symbolIndex": -1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blockID": 8,
|
|
||||||
"immutable": true,
|
|
||||||
"symbolIndex": 8
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"blocks": [
|
|
||||||
{"cellIDs": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
9,
|
|
||||||
10,
|
|
||||||
11,
|
|
||||||
18,
|
|
||||||
19,
|
|
||||||
20
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
12,
|
|
||||||
13,
|
|
||||||
14,
|
|
||||||
21,
|
|
||||||
22,
|
|
||||||
23
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
6,
|
|
||||||
7,
|
|
||||||
8,
|
|
||||||
15,
|
|
||||||
16,
|
|
||||||
17,
|
|
||||||
24,
|
|
||||||
25,
|
|
||||||
26
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
27,
|
|
||||||
28,
|
|
||||||
29,
|
|
||||||
36,
|
|
||||||
37,
|
|
||||||
38,
|
|
||||||
45,
|
|
||||||
46,
|
|
||||||
47
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
30,
|
|
||||||
31,
|
|
||||||
32,
|
|
||||||
39,
|
|
||||||
40,
|
|
||||||
41,
|
|
||||||
48,
|
|
||||||
49,
|
|
||||||
50
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
33,
|
|
||||||
34,
|
|
||||||
35,
|
|
||||||
42,
|
|
||||||
43,
|
|
||||||
44,
|
|
||||||
51,
|
|
||||||
52,
|
|
||||||
53
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
54,
|
|
||||||
55,
|
|
||||||
56,
|
|
||||||
63,
|
|
||||||
64,
|
|
||||||
65,
|
|
||||||
72,
|
|
||||||
73,
|
|
||||||
74
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
57,
|
|
||||||
58,
|
|
||||||
59,
|
|
||||||
66,
|
|
||||||
67,
|
|
||||||
68,
|
|
||||||
75,
|
|
||||||
76,
|
|
||||||
77
|
|
||||||
]},
|
|
||||||
{"cellIDs": [
|
|
||||||
60,
|
|
||||||
61,
|
|
||||||
62,
|
|
||||||
69,
|
|
||||||
70,
|
|
||||||
71,
|
|
||||||
78,
|
|
||||||
79,
|
|
||||||
80
|
|
||||||
]}
|
|
||||||
],
|
|
||||||
"multidoku": [{
|
|
||||||
"blockWidth": 3,
|
|
||||||
"cells": [
|
|
||||||
0,
|
|
||||||
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,
|
|
||||||
65,
|
|
||||||
66,
|
|
||||||
67,
|
|
||||||
68,
|
|
||||||
69,
|
|
||||||
70,
|
|
||||||
71,
|
|
||||||
72,
|
|
||||||
73,
|
|
||||||
74,
|
|
||||||
75,
|
|
||||||
76,
|
|
||||||
77,
|
|
||||||
78,
|
|
||||||
79,
|
|
||||||
80
|
|
||||||
],
|
|
||||||
"blocks": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
3,
|
|
||||||
4,
|
|
||||||
5,
|
|
||||||
6,
|
|
||||||
7,
|
|
||||||
8
|
|
||||||
],
|
|
||||||
"constraints": [
|
|
||||||
0,
|
|
||||||
1,
|
|
||||||
2
|
|
||||||
]
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ package gui;
|
|||||||
|
|
||||||
import gui.menu.MainMenu;
|
import gui.menu.MainMenu;
|
||||||
import gui.menu.StateMachine;
|
import gui.menu.StateMachine;
|
||||||
import imgui.ImGui;
|
|
||||||
import imgui.app.Application;
|
import imgui.app.Application;
|
||||||
import imgui.app.Configuration;
|
import imgui.app.Configuration;
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ public class RenderableMultidoku {
|
|||||||
return cells.get(index);
|
return cells.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static record PositionConstraint(Sudoku sudoku1, Sudoku sudoku2, Coordinate offset) {
|
private static record PositionConstraint(Sudoku sudoku1, Sudoku sudoku2, Coordinate offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import imgui.ImGui;
|
|||||||
import imgui.ImGuiStyle;
|
import imgui.ImGuiStyle;
|
||||||
import sudoku.io.SudokuSerializer;
|
import sudoku.io.SudokuSerializer;
|
||||||
import sudoku.solver.BacktrackingSolver;
|
import sudoku.solver.BacktrackingSolver;
|
||||||
|
import sudoku.solver.HintHelper;
|
||||||
import sudoku.solver.HumanSolver;
|
import sudoku.solver.HumanSolver;
|
||||||
import sudoku.solver.MixedSolver;
|
import sudoku.solver.MixedSolver;
|
||||||
import sudoku.solver.Solver;
|
import sudoku.solver.Solver;
|
||||||
|
import sudoku.solver.HintHelper.Hint;
|
||||||
import sudoku.structure.MultiDoku;
|
import sudoku.structure.MultiDoku;
|
||||||
|
|
||||||
public class SudokuView extends BaseView {
|
public class SudokuView extends BaseView {
|
||||||
@@ -68,6 +70,16 @@ public class SudokuView extends BaseView {
|
|||||||
stopResolve();
|
stopResolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderHintButton() {
|
||||||
|
if (!this.resolved && centeredButton("Indice")) {
|
||||||
|
Hint hint = HintHelper.getHint(this.doku, new BacktrackingSolver());
|
||||||
|
assert (hint != null);
|
||||||
|
hint.cell().setSymbolIndex(hint.newValue());
|
||||||
|
if (this.doku.isSolved())
|
||||||
|
this.sudokuRenderer.onResolve.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void startSolve(Solver solver) {
|
private void startSolve(Solver solver) {
|
||||||
resolveThread = new Thread(() -> {
|
resolveThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -102,7 +114,6 @@ public class SudokuView extends BaseView {
|
|||||||
ImGui.beginDisabled();
|
ImGui.beginDisabled();
|
||||||
|
|
||||||
if (!this.resolved && centeredButton("Résoudre")) {
|
if (!this.resolved && centeredButton("Résoudre")) {
|
||||||
// beginSolve = true;
|
|
||||||
ImGui.openPopup("solve");
|
ImGui.openPopup("solve");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,6 +142,7 @@ public class SudokuView extends BaseView {
|
|||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
sudokuRenderer.render();
|
sudokuRenderer.render();
|
||||||
|
renderHintButton();
|
||||||
renderSolveButton();
|
renderSolveButton();
|
||||||
renderSaveButton();
|
renderSaveButton();
|
||||||
renderCancelButton();
|
renderCancelButton();
|
||||||
|
|||||||
@@ -3,15 +3,51 @@
|
|||||||
*/
|
*/
|
||||||
package sudoku;
|
package sudoku;
|
||||||
|
|
||||||
|
import gui.RenderableMultidoku;
|
||||||
|
import gui.Symbols;
|
||||||
import sudoku.io.ConsoleInterface;
|
import sudoku.io.ConsoleInterface;
|
||||||
|
import sudoku.io.SudokuPrinter;
|
||||||
|
import sudoku.io.SudokuSerializer;
|
||||||
|
import sudoku.solver.RandomSolver;
|
||||||
|
import sudoku.solver.Solver;
|
||||||
|
import sudoku.structure.MultiDoku;
|
||||||
|
import sudoku.structure.SudokuFactory;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public String getGreeting() {
|
public String getGreeting() {
|
||||||
return "Hello World!";
|
return "Hello World!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void voidTest(){
|
||||||
|
MultiDoku md = SudokuFactory.createBasicXShapedMultidoku(3, SudokuFactory.DEFAULT_CONSTRAINTS);
|
||||||
|
SudokuPrinter.printMultiDoku(RenderableMultidoku.fromMultidoku(md), Symbols.Numbers, 3, 3);
|
||||||
|
SudokuSerializer.saveMultiDoku(md);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void filledTest(){
|
||||||
|
MultiDoku md = SudokuFactory.createBasicXShapedMultidoku(3, SudokuFactory.DEFAULT_CONSTRAINTS);
|
||||||
|
new RandomSolver().solve(md);
|
||||||
|
SudokuPrinter.printMultiDoku(RenderableMultidoku.fromMultidoku(md), Symbols.Numbers, 3, 3);
|
||||||
|
SudokuSerializer.saveMultiDoku(md);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void overwriteTest(int n){
|
||||||
|
MultiDoku md = SudokuFactory.createBasicXShapedMultidoku(3, SudokuFactory.DEFAULT_CONSTRAINTS);
|
||||||
|
new RandomSolver().solve(md);
|
||||||
|
SudokuPrinter.printMultiDoku(RenderableMultidoku.fromMultidoku(md), Symbols.Numbers, 3, 3);
|
||||||
|
SudokuSerializer.saveMultiDoku(md, n);
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ConsoleInterface console = new ConsoleInterface();
|
ConsoleInterface console = new ConsoleInterface();
|
||||||
console.start();
|
/*
|
||||||
|
voidTest();
|
||||||
|
filledTest();
|
||||||
|
overwriteTest(0);
|
||||||
|
overwriteTest(17)
|
||||||
|
*/
|
||||||
|
console.welcome();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,54 +1,65 @@
|
|||||||
package sudoku.io;
|
package sudoku.io;
|
||||||
|
|
||||||
|
import gui.RenderableMultidoku;
|
||||||
|
import gui.Symbols;
|
||||||
|
import sudoku.constraint.*;
|
||||||
|
import sudoku.solver.RandomSolver;
|
||||||
|
import sudoku.structure.Difficulty;
|
||||||
|
import sudoku.structure.MultiDoku;
|
||||||
|
import sudoku.structure.SudokuFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import sudoku.constraint.Constraint;
|
|
||||||
import sudoku.solver.RandomSolver;
|
|
||||||
import sudoku.structure.Difficulty;
|
|
||||||
import sudoku.structure.MultiDoku;
|
|
||||||
import sudoku.structure.Sudoku;
|
|
||||||
import sudoku.structure.SudokuFactory;
|
|
||||||
|
|
||||||
public class ConsoleInterface {
|
public class ConsoleInterface {
|
||||||
public Scanner reader = new Scanner(System.in);
|
public Scanner reader = new Scanner(System.in);
|
||||||
|
|
||||||
public void start(){
|
public void welcome(){
|
||||||
welcome();
|
System.out.println("Welcome to our Sudoku Solver!");
|
||||||
|
System.out.println("This is the project of Melvyn Bauvent, Lilas Grenier and Simon Priblyski.");
|
||||||
|
System.out.println("Do you have a save sudoku you would like to continue? (y/n, default n)");
|
||||||
|
if (reader.next().equalsIgnoreCase("y")){
|
||||||
|
useSavedDoku();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
createDoku();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void useSavedDoku() {
|
||||||
|
System.out.println("What save should we use? Please enter the save number.");
|
||||||
|
MultiDoku md = saveChoice();
|
||||||
|
int blockWidth = md.getSubGrid(0).getBlockWidth();
|
||||||
|
int blockHeight = md.getSubGrid(0).getBlocks().getFirst().getCells().size() / blockWidth;
|
||||||
|
List<String> listSymbols = pickSymbols(blockWidth*blockHeight);
|
||||||
|
System.out.println("This is the saved sudoku:");
|
||||||
|
showMultidoku(md, listSymbols, blockWidth, blockHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createDoku(){
|
||||||
System.out.println("First of all, you need to tell me the size of the sudoku you want to generate.");
|
System.out.println("First of all, you need to tell me the size of the sudoku you want to generate.");
|
||||||
int width = getBlockWidth();
|
int width = getBlockWidth();
|
||||||
int height = getBlockHeight();
|
int height = getBlockHeight();
|
||||||
System.out.println("Your sudoku will have blocks of a " + width + " x " + height + " format.");
|
System.out.println("Your sudoku will have blocks of a " + width + " x " + height + " format.");
|
||||||
int numberOfSymbols = width * height;
|
int numberOfSymbols = width * height;
|
||||||
System.out.println("Would you like to pick the " + numberOfSymbols + " symbols from the sudoku? (y/n, default 'no' will use numbers)" );
|
List<String> listSymbols = pickSymbols(numberOfSymbols);
|
||||||
List<String> listSymbols = new ArrayList<>();
|
|
||||||
if(reader.next().equalsIgnoreCase("y")){
|
|
||||||
pickSymbols(listSymbols, numberOfSymbols);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO
|
|
||||||
System.out.println("Simon doit finir sa partie.");
|
|
||||||
assert false;
|
|
||||||
}
|
|
||||||
List<Constraint> listConstraints = getListConstraints();
|
List<Constraint> listConstraints = getListConstraints();
|
||||||
|
System.out.println("Now that we have the size of our sudoku, " +
|
||||||
|
"would you rather have a single grid ('one', default), " +
|
||||||
System.out.println("Now that we have the size of our sudoku, would you rather have a single grid ('one', default), " +
|
|
||||||
"or a a multidoku composed of 5 subgrids ('multi') ?");
|
"or a a multidoku composed of 5 subgrids ('multi') ?");
|
||||||
List<Sudoku> subGrids = new ArrayList<>();
|
|
||||||
MultiDoku doku;
|
MultiDoku doku;
|
||||||
if (reader.next().equalsIgnoreCase("multi")) {
|
if (reader.next().equalsIgnoreCase("multi")) {
|
||||||
doku = SudokuFactory.createBasicEmptyRectangleDoku(width, height, listConstraints);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
doku = SudokuFactory.createBasicXShapedMultidoku(width, height, listConstraints);
|
doku = SudokuFactory.createBasicXShapedMultidoku(width, height, listConstraints);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
doku = SudokuFactory.createBasicEmptyRectangleDoku(width, height, listConstraints);
|
||||||
|
}
|
||||||
System.out.println("Your sudoku will look like this:");
|
System.out.println("Your sudoku will look like this:");
|
||||||
// TODO printMultiDoku method not yet implemented
|
showMultidoku(doku, listSymbols, width, height);
|
||||||
SudokuPrinter.printMultiDoku(doku, width, height);
|
|
||||||
System.out.println("We now will fill this sudoku.");
|
System.out.println("We now will fill this sudoku.");
|
||||||
System.out.println("What level of difficulty would you like? ('very easy', 'easy', 'medium' (default), 'hard', 'full' (sudoku fully completed))");
|
System.out.println("What level of difficulty would you like?" +
|
||||||
|
" ('very easy', 'easy', 'medium' (default), 'hard', 'full' (sudoku fully completed))");
|
||||||
String difficulty = reader.next().toLowerCase();
|
String difficulty = reader.next().toLowerCase();
|
||||||
if (difficulty.equals("full")) {
|
if (difficulty.equals("full")) {
|
||||||
generateFullDoku(doku);
|
generateFullDoku(doku);
|
||||||
@@ -57,12 +68,23 @@ public class ConsoleInterface {
|
|||||||
generatePartialDoku(doku, difficulty);
|
generatePartialDoku(doku, difficulty);
|
||||||
}
|
}
|
||||||
System.out.println("Here's your sudoku !");
|
System.out.println("Here's your sudoku !");
|
||||||
SudokuPrinter.printMultiDoku(doku, width, height);
|
showMultidoku(doku, listSymbols, width, height);
|
||||||
|
System.out.println("You can now save it!");
|
||||||
|
saveMultiDoku(doku);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void welcome(){
|
private MultiDoku saveChoice() {
|
||||||
System.out.println("Welcome to our Sudoku Solver!");
|
int nbSave;
|
||||||
System.out.println("This is the project of Melvyn Bauvent, Lilas Grenier and Simon Priblyski.");
|
MultiDoku md = null;
|
||||||
|
do {
|
||||||
|
nbSave = reader.nextInt();
|
||||||
|
try {
|
||||||
|
md = SudokuSerializer.getSavedMultiDoku(nbSave);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("There seems to be a problem with this save, please try again.");
|
||||||
|
}
|
||||||
|
} while (md == null);
|
||||||
|
return md;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockWidth() {
|
public int getBlockWidth() {
|
||||||
@@ -93,18 +115,30 @@ public class ConsoleInterface {
|
|||||||
return (size > 0);
|
return (size > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pickSymbols(List<String> listSymbols, int numberOfSymbols) {
|
private List<String> pickSymbols(int numberOfSymbols) {
|
||||||
System.out.println("You have chosen to pick your own symbols.");
|
System.out.println("Would you like to pick the " + numberOfSymbols + " symbols from the sudoku? (y/n, default 'no' will use numbers)");
|
||||||
for (int i = 0; i < numberOfSymbols; i++) {
|
if (reader.next().equalsIgnoreCase("y")) {
|
||||||
System.out.println("Choose for the symbol number " + i + ": ");
|
List<String> listSymbols = new ArrayList<>();
|
||||||
String newSymbol = reader.next();
|
System.out.println("You have chosen to pick your own symbols.");
|
||||||
while (listSymbols.contains(newSymbol)) {
|
for (int i = 0; i < numberOfSymbols; i++) {
|
||||||
System.out.println("This symbol has already been given. Try again:");
|
System.out.println("Choose for the symbol number " + i + ": ");
|
||||||
newSymbol = reader.next();
|
String newSymbol = reader.next();
|
||||||
|
while (listSymbols.contains(newSymbol)) {
|
||||||
|
System.out.println("This symbol has already been given. Try again:");
|
||||||
|
newSymbol = reader.next();
|
||||||
|
}
|
||||||
|
listSymbols.add(newSymbol);
|
||||||
}
|
}
|
||||||
listSymbols.add(newSymbol);
|
System.out.println("You chose the symbols: " + listSymbols.toString());
|
||||||
|
return listSymbols;
|
||||||
|
} else {
|
||||||
|
System.out.println("What existing sets of symbols do you want to use? Numbers ('n', default), letters ('l'), or emojis ('e')?");
|
||||||
|
return switch (reader.next().toLowerCase()) {
|
||||||
|
case "l" -> Symbols.Letters.getSymbols();
|
||||||
|
case "e" -> Symbols.Emojis.getSymbols();
|
||||||
|
default -> Symbols.Numbers.getSymbols();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
System.out.println("You chose the symbols: " + listSymbols.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Constraint> getListConstraints() {
|
private List<Constraint> getListConstraints() {
|
||||||
@@ -135,4 +169,18 @@ public class ConsoleInterface {
|
|||||||
new RandomSolver().solve(doku);
|
new RandomSolver().solve(doku);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showMultidoku(MultiDoku doku, List<String> listSymbols, int width, int height){
|
||||||
|
showMultiDoku(RenderableMultidoku.fromMultidoku(doku), listSymbols, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showMultiDoku(RenderableMultidoku doku, List<String> listSymbols, int width, int height){
|
||||||
|
SudokuPrinter.printMultiDoku(doku, listSymbols, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveMultiDoku(MultiDoku doku){
|
||||||
|
System.out.println("Number of the file to overwrite ('-1' or unused save file number to create a new save) :");
|
||||||
|
int n = reader.nextInt();
|
||||||
|
String path = SudokuSerializer.saveMultiDoku(doku, n);
|
||||||
|
System.out.println("The path to your save is:" + path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,89 @@
|
|||||||
package sudoku.io;
|
package sudoku.io;
|
||||||
|
|
||||||
|
import gui.RenderableMultidoku;
|
||||||
|
import gui.Symbols;
|
||||||
|
import sudoku.structure.Cell;
|
||||||
import sudoku.structure.MultiDoku;
|
import sudoku.structure.MultiDoku;
|
||||||
import sudoku.structure.Sudoku;
|
import sudoku.structure.Sudoku;
|
||||||
|
|
||||||
public class SudokuPrinter {
|
import java.util.List;
|
||||||
|
|
||||||
public static void printRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight) {
|
public class SudokuPrinter {
|
||||||
for (int y = 0; y < s.getSize(); y++) {
|
public static final String ANSI_RESET = "\u001B[0m";
|
||||||
if (y % blockHeight == 0 && y > 0) {
|
public static final String ANSI_RED = "\u001B[31m";
|
||||||
System.out.println();
|
public static final String ANSI_GREEN = "\u001B[32m";
|
||||||
}
|
public static final String ANSI_YELLOW = "\u001B[33m";
|
||||||
StringBuilder line = new StringBuilder("[ ");
|
public static final String ANSI_BLUE = "\u001B[34m";
|
||||||
for (int x = 0; x < s.getSize(); x++) {
|
public static final String ANSI_PURPLE = "\u001B[35m";
|
||||||
line.append((s.getCell(x, y).getSymbolIndex() + 1)).append(" ");
|
public static final String ANSI_CYAN = "\u001B[36m";
|
||||||
if (x % blockWidth == blockWidth - 1 && x != blockWidth * blockHeight - 1) {
|
|
||||||
line.append("| ");
|
public static void printRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight, Symbols symbols) {
|
||||||
}
|
printRectangleSudoku(s, blockWidth, blockHeight, symbols.getSymbols());
|
||||||
}
|
|
||||||
line.append("]");
|
|
||||||
System.out.println(line);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toStringRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight) {
|
public static void printRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight, List<String> listSymbols){
|
||||||
|
for (int y = 0; y < s.getSize(); y++) {
|
||||||
|
if (y % blockHeight == 0 && y > 0) {
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
StringBuilder line = new StringBuilder("[ ");
|
||||||
|
for (int x = 0; x < s.getSize(); x++) {
|
||||||
|
Cell c = s.getCell(x, y);
|
||||||
|
if (c.getSymbolIndex() == Cell.NOSYMBOL) {
|
||||||
|
line.append(" ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line.append(listSymbols.get(c.getSymbolIndex())).append(" ");
|
||||||
|
}
|
||||||
|
if (x % blockWidth == blockWidth - 1 && x != blockWidth * blockHeight - 1) {
|
||||||
|
line.append("| ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line.append("]");
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printMultiDoku(final RenderableMultidoku rm, Symbols symbols, int blockWidth, int blockHeight) {
|
||||||
|
printMultiDoku(rm, symbols.getSymbols(), blockWidth, blockHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printMultiDoku(final RenderableMultidoku rm, List<String> listSymbols, int blockWidth, int blockHeight) {
|
||||||
|
StringBuilder line = new StringBuilder("\n");
|
||||||
|
int nBlockInWidth = rm.getWidth() / blockWidth;
|
||||||
|
for (int y = 0; y < rm.getHeight(); y++) {
|
||||||
|
if (y % blockHeight == 0) {
|
||||||
|
line.append("__".repeat(Math.max(0, rm.getWidth()+nBlockInWidth))).append("_\n");
|
||||||
|
}
|
||||||
|
line.append("[ ");
|
||||||
|
for (int x = 0; x < rm.getWidth(); x++) {
|
||||||
|
if (x % blockWidth == 0 && x > 0) {
|
||||||
|
line.append("| ");
|
||||||
|
}
|
||||||
|
Cell cell = rm.getCell(x, y);
|
||||||
|
if (cell != null) {
|
||||||
|
if (cell.getSymbolIndex() == Cell.NOSYMBOL) {
|
||||||
|
line.append("- ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line.append(listSymbols.get(cell.getSymbolIndex())).append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line.append("]\n");
|
||||||
|
}
|
||||||
|
line.append("__".repeat(Math.max(0, rm.getWidth()+nBlockInWidth))).append("_\n");
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toStringRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight, Symbols symbols){
|
||||||
|
return toStringRectangleSudoku(s, blockWidth, blockHeight, symbols.getSymbols());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toStringRectangleSudoku(final Sudoku s, int blockWidth, int blockHeight, List<String> listSymbols) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
for (int y = 0; y < s.getSize(); y++) {
|
for (int y = 0; y < s.getSize(); y++) {
|
||||||
// Ajouter une ligne vide entre les blocs horizontaux
|
// Ajouter une ligne vide entre les blocs horizontaux
|
||||||
@@ -32,7 +93,13 @@ public class SudokuPrinter {
|
|||||||
StringBuilder line = new StringBuilder("[ ");
|
StringBuilder line = new StringBuilder("[ ");
|
||||||
for (int x = 0; x < s.getSize(); x++) {
|
for (int x = 0; x < s.getSize(); x++) {
|
||||||
// Ajouter la valeur de la cellule
|
// Ajouter la valeur de la cellule
|
||||||
line.append((s.getCell(x, y).getSymbolIndex() + 1)).append(" ");
|
Cell cell = s.getCell(x, y);
|
||||||
|
if (cell.getSymbolIndex() == Cell.NOSYMBOL) {
|
||||||
|
line.append(" ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line.append(listSymbols.get(cell.getSymbolIndex())).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
// Ajouter un séparateur vertical entre les blocs
|
// Ajouter un séparateur vertical entre les blocs
|
||||||
if (x % blockWidth == blockWidth - 1 && x != s.getSize() - 1) {
|
if (x % blockWidth == blockWidth - 1 && x != s.getSize() - 1) {
|
||||||
@@ -45,7 +112,12 @@ public class SudokuPrinter {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printMultiDoku(final MultiDoku doku, int blockWidth, int blockHeight){
|
public static void printMultiDoku(final MultiDoku doku, int blockWidth, int blockHeight, Symbols symbols){
|
||||||
// TODO
|
if (doku.getNbSubGrids()==1) {
|
||||||
|
printRectangleSudoku(doku.getSubGrid(0), blockWidth, blockHeight, symbols);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printMultiDoku(RenderableMultidoku.fromMultidoku(doku), symbols, blockWidth, blockHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,17 +124,13 @@ public class SudokuSerializer {
|
|||||||
* @return String, the path of the save.
|
* @return String, the path of the save.
|
||||||
*/
|
*/
|
||||||
public static String saveMultiDoku(final MultiDoku doku) {
|
public static String saveMultiDoku(final MultiDoku doku) {
|
||||||
|
|
||||||
JSONObject jsonRoot = serializeSudoku(doku);
|
JSONObject jsonRoot = serializeSudoku(doku);
|
||||||
|
|
||||||
File f = new File("save", "save.json");
|
File f = new File("save", "save.json");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (f.exists()) {
|
while (f.exists()) {
|
||||||
String newName = "save-" + ++i + ".json";
|
String newName = "save-" + ++i + ".json";
|
||||||
f = new File("save", newName);
|
f = new File("save", newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (FileWriter file = new FileWriter(f)) {
|
try (FileWriter file = new FileWriter(f)) {
|
||||||
file.write(jsonRoot.toString(3));
|
file.write(jsonRoot.toString(3));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -143,6 +139,27 @@ public class SudokuSerializer {
|
|||||||
return f.getAbsolutePath();
|
return f.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String saveMultiDoku(final MultiDoku doku, final int saveToOverwrite) {
|
||||||
|
File f;
|
||||||
|
if (saveToOverwrite == 0) {
|
||||||
|
f = new File("save", "save.json");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
f = new File("save", "save-" + saveToOverwrite + ".json");
|
||||||
|
}
|
||||||
|
if (!f.exists()) {
|
||||||
|
return saveMultiDoku(doku);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try (FileWriter file = new FileWriter(f)) {
|
||||||
|
file.write(serializeSudoku(doku).toString(3));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return f.getAbsolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a MultiDoku from a pre-existing json save file.
|
* Get a MultiDoku from a pre-existing json save file.
|
||||||
*
|
*
|
||||||
|
|||||||
54
app/src/main/java/sudoku/solver/HintHelper.java
Normal file
54
app/src/main/java/sudoku/solver/HintHelper.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package sudoku.solver;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import sudoku.structure.Cell;
|
||||||
|
import sudoku.structure.MultiDoku;
|
||||||
|
|
||||||
|
public class HintHelper {
|
||||||
|
|
||||||
|
public static record Hint(Cell cell, int newValue) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Hint getHint(MultiDoku doku, Solver solver) {
|
||||||
|
doku.getStateManager().pushState();
|
||||||
|
doku.clearMutableCells();
|
||||||
|
if (!solver.solve(doku))
|
||||||
|
return null;
|
||||||
|
var stateSolved = doku.getStateManager().popAndGetState();
|
||||||
|
// find differences
|
||||||
|
Map<Cell, Integer> newValues = new HashMap<>();
|
||||||
|
for (var entry : stateSolved.entrySet()) {
|
||||||
|
Cell cell = entry.getKey();
|
||||||
|
// we only want the cells that can be filled
|
||||||
|
if (!cell.isMutable())
|
||||||
|
continue;
|
||||||
|
int oldValue = cell.getSymbolIndex();
|
||||||
|
int newValue = stateSolved.get(cell);
|
||||||
|
if (oldValue == newValue)
|
||||||
|
continue;
|
||||||
|
// we have to clear the cell
|
||||||
|
if (newValue == Cell.NOSYMBOL)
|
||||||
|
return new Hint(cell, newValue);
|
||||||
|
// we have to change the cell value
|
||||||
|
if (oldValue != Cell.NOSYMBOL && newValue != oldValue)
|
||||||
|
return new Hint(cell, newValue);
|
||||||
|
|
||||||
|
// there is a valid move
|
||||||
|
newValues.put(cell, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is too complex just for fetching a random entry, but whatever ...
|
||||||
|
Random r = new Random();
|
||||||
|
List<Cell> cells = new ArrayList<>(newValues.keySet());
|
||||||
|
Cell randomCell = cells.get(r.nextInt(cells.size()));
|
||||||
|
int randomCellValue = newValues.get(randomCell);
|
||||||
|
return new Hint(randomCell, randomCellValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import gui.Symbols;
|
||||||
import sudoku.io.SudokuPrinter;
|
import sudoku.io.SudokuPrinter;
|
||||||
import sudoku.structure.Cell;
|
import sudoku.structure.Cell;
|
||||||
import sudoku.structure.MultiDoku;
|
import sudoku.structure.MultiDoku;
|
||||||
@@ -26,7 +27,8 @@ public class HumanSolver implements Solver {
|
|||||||
logger.log(Level.FINE,
|
logger.log(Level.FINE,
|
||||||
'\n' + SudokuPrinter.toStringRectangleSudoku(sudoku,
|
'\n' + SudokuPrinter.toStringRectangleSudoku(sudoku,
|
||||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
||||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth()));
|
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth(),
|
||||||
|
Symbols.Numbers));
|
||||||
|
|
||||||
if (doku.isSolved()) {
|
if (doku.isSolved()) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Random;
|
|||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import gui.Symbols;
|
||||||
import sudoku.io.SudokuPrinter;
|
import sudoku.io.SudokuPrinter;
|
||||||
import sudoku.structure.Cell;
|
import sudoku.structure.Cell;
|
||||||
import sudoku.structure.MultiDoku;
|
import sudoku.structure.MultiDoku;
|
||||||
@@ -32,7 +33,8 @@ public class MixedSolver implements Solver{
|
|||||||
'\n' + SudokuPrinter.toStringRectangleSudoku(
|
'\n' + SudokuPrinter.toStringRectangleSudoku(
|
||||||
sudoku,
|
sudoku,
|
||||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
||||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth()));
|
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth(),
|
||||||
|
Symbols.Numbers));
|
||||||
|
|
||||||
if (doku.isSolved()) {
|
if (doku.isSolved()) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Random;
|
|||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import gui.Symbols;
|
||||||
import sudoku.io.SudokuPrinter;
|
import sudoku.io.SudokuPrinter;
|
||||||
import sudoku.structure.Cell;
|
import sudoku.structure.Cell;
|
||||||
import sudoku.structure.MultiDoku;
|
import sudoku.structure.MultiDoku;
|
||||||
@@ -18,7 +19,6 @@ public class RandomSolver implements Solver {
|
|||||||
* de backtracking.
|
* de backtracking.
|
||||||
*
|
*
|
||||||
* @param doku Multidoku, à résoudre
|
* @param doku Multidoku, à résoudre
|
||||||
* @param rand Random, pour tester aléatoirement les symboles
|
|
||||||
* @return boolean, true s'il est résolu ou false s'il ne l'est pas.
|
* @return boolean, true s'il est résolu ou false s'il ne l'est pas.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -32,7 +32,8 @@ public class RandomSolver implements Solver {
|
|||||||
logger.log(Level.FINE,
|
logger.log(Level.FINE,
|
||||||
'\n' + SudokuPrinter.toStringRectangleSudoku(sudoku,
|
'\n' + SudokuPrinter.toStringRectangleSudoku(sudoku,
|
||||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getBlockWidth(),
|
||||||
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth()));
|
sudoku.getBlockWidth() == 0 ? sudoku.getSize() : sudoku.getSize() / sudoku.getBlockWidth(),
|
||||||
|
Symbols.Numbers));
|
||||||
|
|
||||||
if (doku.isSolved()) {
|
if (doku.isSolved()) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -15,27 +15,35 @@ public class StateManager {
|
|||||||
this.doku = doku;
|
this.doku = doku;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushState() {
|
public Map<Cell, Integer> pushState() {
|
||||||
states.add(new HashMap<>());
|
states.add(saveState());
|
||||||
saveState();
|
return states.getLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void popState() {
|
public void popState() {
|
||||||
assert (states.size() > 0);
|
assert (states.size() > 0);
|
||||||
restoreState();
|
restoreState(states.pop());
|
||||||
states.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreState() {
|
public Map<Cell, Integer> popAndGetState() {
|
||||||
for (var entry : this.states.getLast().entrySet()) {
|
assert (states.size() > 0);
|
||||||
|
var currentState = saveState();
|
||||||
|
restoreState(states.pop());
|
||||||
|
return currentState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreState(Map<Cell, Integer> state) {
|
||||||
|
for (var entry : state.entrySet()) {
|
||||||
entry.getKey().setSymbolIndex(entry.getValue());
|
entry.getKey().setSymbolIndex(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveState() {
|
private Map<Cell, Integer> saveState() {
|
||||||
|
Map<Cell, Integer> state = new HashMap<>();
|
||||||
for (Cell cell : this.doku.getCells()) {
|
for (Cell cell : this.doku.getCells()) {
|
||||||
states.getLast().put(cell, cell.getSymbolIndex());
|
state.put(cell, cell.getSymbolIndex());
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package sudoku.solver;
|
package sudoku.solver;
|
||||||
|
|
||||||
|
import gui.Symbols;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import sudoku.io.SudokuPrinter;
|
import sudoku.io.SudokuPrinter;
|
||||||
import sudoku.io.SudokuSerializer;
|
import sudoku.io.SudokuSerializer;
|
||||||
@@ -38,7 +39,8 @@ class SolverTest {
|
|||||||
|
|
||||||
assert (sudokuToTest.setImmutableCellsSymbol(immutableCells));
|
assert (sudokuToTest.setImmutableCellsSymbol(immutableCells));
|
||||||
|
|
||||||
SudokuPrinter.printRectangleSudoku(dokuToTest.getSubGrid(0), 3, 3);
|
//SudokuPrinter.printRectangleSudoku(dokuToTest.getSubGrid(0), 3, 3);
|
||||||
|
SudokuPrinter.printMultiDoku(dokuToTest, 3, 3, Symbols.Numbers);
|
||||||
|
|
||||||
List<Integer> correctCells = List.of(7, 6, 0, 3, 4, 2, 8, 5, 1,
|
List<Integer> correctCells = List.of(7, 6, 0, 3, 4, 2, 8, 5, 1,
|
||||||
2, 3, 8, 1, 5, 6, 7, 0, 4,
|
2, 3, 8, 1, 5, 6, 7, 0, 4,
|
||||||
@@ -53,14 +55,15 @@ class SolverTest {
|
|||||||
sudokuResult.setCellsSymbol(correctCells);
|
sudokuResult.setCellsSymbol(correctCells);
|
||||||
|
|
||||||
System.out.println("\n****************************Doku Control\n");
|
System.out.println("\n****************************Doku Control\n");
|
||||||
SudokuPrinter.printRectangleSudoku(sudokuResult, 3, 3);
|
SudokuPrinter.printRectangleSudoku(sudokuResult, 3, 3, Symbols.Russian);
|
||||||
|
|
||||||
assert (dokuResult.isSolved());
|
assert (dokuResult.isSolved());
|
||||||
|
|
||||||
new RandomSolver().solve(dokuToTest);
|
new RandomSolver().solve(dokuToTest);
|
||||||
|
|
||||||
System.out.println("\n****************************\nDoku solved");
|
System.out.println("\n****************************\nDoku solved");
|
||||||
SudokuPrinter.printRectangleSudoku(dokuToTest.getSubGrid(0), 3, 3);
|
//SudokuPrinter.printRectangleSudoku(dokuToTest.getSubGrid(0), 3, 3);
|
||||||
|
SudokuPrinter.printMultiDoku(dokuToTest, 3, 3, Symbols.Emojis);
|
||||||
|
|
||||||
assert (dokuToTest.isSolved());
|
assert (dokuToTest.isSolved());
|
||||||
|
|
||||||
@@ -97,6 +100,7 @@ class SolverTest {
|
|||||||
|
|
||||||
new RandomSolver().solve(dokuToTest3);
|
new RandomSolver().solve(dokuToTest3);
|
||||||
|
|
||||||
SudokuPrinter.printRectangleSudoku(dokuToTest3.getSubGrid(0), 3, 3);
|
//SudokuPrinter.printRectangleSudoku(dokuToTest3.getSubGrid(0), 3, 3);
|
||||||
|
SudokuPrinter.printMultiDoku(dokuToTest3, 3, 3, Symbols.Letters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user