@logic-pad/core 0.26.0 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +31 -31
  2. package/assets/logic-core.global.d.ts +3264 -3247
  3. package/package.json +4 -1
  4. package/dist/benchmark/helper.d.ts +0 -21
  5. package/dist/benchmark/helper.js +0 -34
  6. package/dist/benchmark/prepareBench.d.ts +0 -1
  7. package/dist/benchmark/prepareBench.js +0 -140
  8. package/dist/benchmark/runBench.d.ts +0 -1
  9. package/dist/benchmark/runBench.js +0 -206
  10. package/dist/src/data/config.d.ts +0 -119
  11. package/dist/src/data/config.js +0 -72
  12. package/dist/src/data/configurable.d.ts +0 -14
  13. package/dist/src/data/configurable.js +0 -26
  14. package/dist/src/data/dataHelper.d.ts +0 -92
  15. package/dist/src/data/dataHelper.js +0 -217
  16. package/dist/src/data/events/eventHelper.d.ts +0 -1
  17. package/dist/src/data/events/eventHelper.js +0 -6
  18. package/dist/src/data/events/onFinalValidation.d.ts +0 -14
  19. package/dist/src/data/events/onFinalValidation.js +0 -4
  20. package/dist/src/data/events/onGetTile.d.ts +0 -7
  21. package/dist/src/data/events/onGetTile.js +0 -4
  22. package/dist/src/data/events/onGridChange.d.ts +0 -6
  23. package/dist/src/data/events/onGridChange.js +0 -4
  24. package/dist/src/data/events/onGridResize.d.ts +0 -9
  25. package/dist/src/data/events/onGridResize.js +0 -4
  26. package/dist/src/data/events/onSetGrid.d.ts +0 -7
  27. package/dist/src/data/events/onSetGrid.js +0 -19
  28. package/dist/src/data/events/onSymbolDisplay.d.ts +0 -16
  29. package/dist/src/data/events/onSymbolDisplay.js +0 -4
  30. package/dist/src/data/events/onSymbolMerge.d.ts +0 -10
  31. package/dist/src/data/events/onSymbolMerge.js +0 -4
  32. package/dist/src/data/events/onSymbolValidation.d.ts +0 -18
  33. package/dist/src/data/events/onSymbolValidation.js +0 -4
  34. package/dist/src/data/grid.d.ts +0 -410
  35. package/dist/src/data/grid.js +0 -1106
  36. package/dist/src/data/gridConnections.d.ts +0 -25
  37. package/dist/src/data/gridConnections.js +0 -309
  38. package/dist/src/data/gridZones.d.ts +0 -26
  39. package/dist/src/data/gridZones.js +0 -117
  40. package/dist/src/data/instruction.d.ts +0 -26
  41. package/dist/src/data/instruction.js +0 -29
  42. package/dist/src/data/primitives.d.ts +0 -138
  43. package/dist/src/data/primitives.js +0 -177
  44. package/dist/src/data/puzzle.d.ts +0 -73
  45. package/dist/src/data/puzzle.js +0 -105
  46. package/dist/src/data/rules/banPatternRule.d.ts +0 -30
  47. package/dist/src/data/rules/banPatternRule.js +0 -125
  48. package/dist/src/data/rules/cellCountPerZoneRule.d.ts +0 -23
  49. package/dist/src/data/rules/cellCountPerZoneRule.js +0 -39
  50. package/dist/src/data/rules/cellCountRule.d.ts +0 -33
  51. package/dist/src/data/rules/cellCountRule.js +0 -138
  52. package/dist/src/data/rules/completePatternRule.d.ts +0 -24
  53. package/dist/src/data/rules/completePatternRule.js +0 -46
  54. package/dist/src/data/rules/connectAllRule.d.ts +0 -29
  55. package/dist/src/data/rules/connectAllRule.js +0 -88
  56. package/dist/src/data/rules/connectZonesRule.d.ts +0 -29
  57. package/dist/src/data/rules/connectZonesRule.js +0 -111
  58. package/dist/src/data/rules/containsShapeRule.d.ts +0 -34
  59. package/dist/src/data/rules/containsShapeRule.js +0 -125
  60. package/dist/src/data/rules/customRule.d.ts +0 -34
  61. package/dist/src/data/rules/customRule.js +0 -74
  62. package/dist/src/data/rules/differentCountPerZoneRule.d.ts +0 -30
  63. package/dist/src/data/rules/differentCountPerZoneRule.js +0 -96
  64. package/dist/src/data/rules/exactCountPerZoneRule.d.ts +0 -33
  65. package/dist/src/data/rules/exactCountPerZoneRule.js +0 -99
  66. package/dist/src/data/rules/foresightRule.d.ts +0 -36
  67. package/dist/src/data/rules/foresightRule.js +0 -107
  68. package/dist/src/data/rules/index.d.ts +0 -3
  69. package/dist/src/data/rules/index.js +0 -10
  70. package/dist/src/data/rules/lyingSymbolRule.d.ts +0 -31
  71. package/dist/src/data/rules/lyingSymbolRule.js +0 -207
  72. package/dist/src/data/rules/musicControlLine.d.ts +0 -82
  73. package/dist/src/data/rules/musicControlLine.js +0 -167
  74. package/dist/src/data/rules/musicGridRule.d.ts +0 -51
  75. package/dist/src/data/rules/musicGridRule.js +0 -212
  76. package/dist/src/data/rules/mysteryRule.d.ts +0 -39
  77. package/dist/src/data/rules/mysteryRule.js +0 -146
  78. package/dist/src/data/rules/noLoopsRule.d.ts +0 -29
  79. package/dist/src/data/rules/noLoopsRule.js +0 -218
  80. package/dist/src/data/rules/offByXRule.d.ts +0 -32
  81. package/dist/src/data/rules/offByXRule.js +0 -124
  82. package/dist/src/data/rules/perfectionRule.d.ts +0 -45
  83. package/dist/src/data/rules/perfectionRule.js +0 -158
  84. package/dist/src/data/rules/regionAreaRule.d.ts +0 -34
  85. package/dist/src/data/rules/regionAreaRule.js +0 -149
  86. package/dist/src/data/rules/regionShapeRule.d.ts +0 -22
  87. package/dist/src/data/rules/regionShapeRule.js +0 -58
  88. package/dist/src/data/rules/rule.d.ts +0 -18
  89. package/dist/src/data/rules/rule.js +0 -19
  90. package/dist/src/data/rules/rules.gen.d.ts +0 -23
  91. package/dist/src/data/rules/rules.gen.js +0 -27
  92. package/dist/src/data/rules/sameCountPerZoneRule.d.ts +0 -30
  93. package/dist/src/data/rules/sameCountPerZoneRule.js +0 -95
  94. package/dist/src/data/rules/sameShapeRule.d.ts +0 -28
  95. package/dist/src/data/rules/sameShapeRule.js +0 -68
  96. package/dist/src/data/rules/symbolsPerRegionRule.d.ts +0 -38
  97. package/dist/src/data/rules/symbolsPerRegionRule.js +0 -181
  98. package/dist/src/data/rules/undercluedRule.d.ts +0 -24
  99. package/dist/src/data/rules/undercluedRule.js +0 -53
  100. package/dist/src/data/rules/uniqueShapeRule.d.ts +0 -28
  101. package/dist/src/data/rules/uniqueShapeRule.js +0 -65
  102. package/dist/src/data/rules/wrapAroundRule.d.ts +0 -36
  103. package/dist/src/data/rules/wrapAroundRule.js +0 -241
  104. package/dist/src/data/serializer/allSerializers.d.ts +0 -32
  105. package/dist/src/data/serializer/allSerializers.js +0 -71
  106. package/dist/src/data/serializer/compressor/allCompressors.d.ts +0 -14
  107. package/dist/src/data/serializer/compressor/allCompressors.js +0 -43
  108. package/dist/src/data/serializer/compressor/checksumCompressor.d.ts +0 -6
  109. package/dist/src/data/serializer/compressor/checksumCompressor.js +0 -21
  110. package/dist/src/data/serializer/compressor/compressorBase.d.ts +0 -16
  111. package/dist/src/data/serializer/compressor/compressorBase.js +0 -2
  112. package/dist/src/data/serializer/compressor/deflateCompressor.d.ts +0 -7
  113. package/dist/src/data/serializer/compressor/deflateCompressor.js +0 -17
  114. package/dist/src/data/serializer/compressor/gzipCompressor.d.ts +0 -5
  115. package/dist/src/data/serializer/compressor/gzipCompressor.js +0 -9
  116. package/dist/src/data/serializer/compressor/streamCompressor.d.ts +0 -6
  117. package/dist/src/data/serializer/compressor/streamCompressor.js +0 -41
  118. package/dist/src/data/serializer/serializerBase.d.ts +0 -32
  119. package/dist/src/data/serializer/serializerBase.js +0 -2
  120. package/dist/src/data/serializer/serializer_checksum.d.ts +0 -35
  121. package/dist/src/data/serializer/serializer_checksum.js +0 -179
  122. package/dist/src/data/serializer/serializer_v0.d.ts +0 -55
  123. package/dist/src/data/serializer/serializer_v0.js +0 -484
  124. package/dist/src/data/shapes.d.ts +0 -19
  125. package/dist/src/data/shapes.js +0 -137
  126. package/dist/src/data/solver/allSolvers.d.ts +0 -3
  127. package/dist/src/data/solver/allSolvers.js +0 -13
  128. package/dist/src/data/solver/auto/autoSolver.d.ts +0 -18
  129. package/dist/src/data/solver/auto/autoSolver.js +0 -153
  130. package/dist/src/data/solver/backtrack/backtrackSolver.d.ts +0 -11
  131. package/dist/src/data/solver/backtrack/backtrackSolver.js +0 -52
  132. package/dist/src/data/solver/backtrack/backtrackWorker.d.ts +0 -1
  133. package/dist/src/data/solver/backtrack/backtrackWorker.js +0 -308
  134. package/dist/src/data/solver/backtrack/data.d.ts +0 -47
  135. package/dist/src/data/solver/backtrack/data.js +0 -151
  136. package/dist/src/data/solver/backtrack/rules/banPattern.d.ts +0 -9
  137. package/dist/src/data/solver/backtrack/rules/banPattern.js +0 -77
  138. package/dist/src/data/solver/backtrack/rules/cellCount.d.ts +0 -7
  139. package/dist/src/data/solver/backtrack/rules/cellCount.js +0 -25
  140. package/dist/src/data/solver/backtrack/rules/connectAll.d.ts +0 -7
  141. package/dist/src/data/solver/backtrack/rules/connectAll.js +0 -44
  142. package/dist/src/data/solver/backtrack/rules/regionArea.d.ts +0 -8
  143. package/dist/src/data/solver/backtrack/rules/regionArea.js +0 -71
  144. package/dist/src/data/solver/backtrack/rules/regionShape.d.ts +0 -8
  145. package/dist/src/data/solver/backtrack/rules/regionShape.js +0 -57
  146. package/dist/src/data/solver/backtrack/rules/sameShape.d.ts +0 -8
  147. package/dist/src/data/solver/backtrack/rules/sameShape.js +0 -14
  148. package/dist/src/data/solver/backtrack/rules/symbolsPerRegion.d.ts +0 -10
  149. package/dist/src/data/solver/backtrack/rules/symbolsPerRegion.js +0 -82
  150. package/dist/src/data/solver/backtrack/rules/uniqueShape.d.ts +0 -8
  151. package/dist/src/data/solver/backtrack/rules/uniqueShape.js +0 -14
  152. package/dist/src/data/solver/backtrack/symbols/areaNumber.d.ts +0 -9
  153. package/dist/src/data/solver/backtrack/symbols/areaNumber.js +0 -75
  154. package/dist/src/data/solver/backtrack/symbols/dart.d.ts +0 -8
  155. package/dist/src/data/solver/backtrack/symbols/dart.js +0 -45
  156. package/dist/src/data/solver/backtrack/symbols/directionLinker.d.ts +0 -11
  157. package/dist/src/data/solver/backtrack/symbols/directionLinker.js +0 -121
  158. package/dist/src/data/solver/backtrack/symbols/focus.d.ts +0 -9
  159. package/dist/src/data/solver/backtrack/symbols/focus.js +0 -48
  160. package/dist/src/data/solver/backtrack/symbols/galaxy.d.ts +0 -9
  161. package/dist/src/data/solver/backtrack/symbols/galaxy.js +0 -14
  162. package/dist/src/data/solver/backtrack/symbols/letter.d.ts +0 -9
  163. package/dist/src/data/solver/backtrack/symbols/letter.js +0 -93
  164. package/dist/src/data/solver/backtrack/symbols/lotus.d.ts +0 -11
  165. package/dist/src/data/solver/backtrack/symbols/lotus.js +0 -55
  166. package/dist/src/data/solver/backtrack/symbols/minesweeper.d.ts +0 -9
  167. package/dist/src/data/solver/backtrack/symbols/minesweeper.js +0 -44
  168. package/dist/src/data/solver/backtrack/symbols/myopia.d.ts +0 -7
  169. package/dist/src/data/solver/backtrack/symbols/myopia.js +0 -73
  170. package/dist/src/data/solver/backtrack/symbols/viewpoint.d.ts +0 -7
  171. package/dist/src/data/solver/backtrack/symbols/viewpoint.js +0 -51
  172. package/dist/src/data/solver/cspuz/cspuzSolver.d.ts +0 -13
  173. package/dist/src/data/solver/cspuz/cspuzSolver.js +0 -117
  174. package/dist/src/data/solver/cspuz/cspuzWorker.d.ts +0 -1
  175. package/dist/src/data/solver/cspuz/cspuzWorker.js +0 -82
  176. package/dist/src/data/solver/cspuz/jsonify.d.ts +0 -3
  177. package/dist/src/data/solver/cspuz/jsonify.js +0 -211
  178. package/dist/src/data/solver/eventIteratingSolver.d.ts +0 -8
  179. package/dist/src/data/solver/eventIteratingSolver.js +0 -54
  180. package/dist/src/data/solver/solver.d.ts +0 -77
  181. package/dist/src/data/solver/solver.js +0 -59
  182. package/dist/src/data/solver/universal/universalSolver.d.ts +0 -7
  183. package/dist/src/data/solver/universal/universalSolver.js +0 -13
  184. package/dist/src/data/solver/universal/universalWorker.d.ts +0 -1
  185. package/dist/src/data/solver/universal/universalWorker.js +0 -128
  186. package/dist/src/data/symbols/areaNumberSymbol.d.ts +0 -31
  187. package/dist/src/data/symbols/areaNumberSymbol.js +0 -80
  188. package/dist/src/data/symbols/customIconSymbol.d.ts +0 -35
  189. package/dist/src/data/symbols/customIconSymbol.js +0 -94
  190. package/dist/src/data/symbols/customSymbol.d.ts +0 -25
  191. package/dist/src/data/symbols/customSymbol.js +0 -45
  192. package/dist/src/data/symbols/customTextSymbol.d.ts +0 -35
  193. package/dist/src/data/symbols/customTextSymbol.js +0 -95
  194. package/dist/src/data/symbols/dartSymbol.d.ts +0 -36
  195. package/dist/src/data/symbols/dartSymbol.js +0 -96
  196. package/dist/src/data/symbols/directionLinkerSymbol.d.ts +0 -29
  197. package/dist/src/data/symbols/directionLinkerSymbol.js +0 -232
  198. package/dist/src/data/symbols/everyLetterSymbol.d.ts +0 -32
  199. package/dist/src/data/symbols/everyLetterSymbol.js +0 -119
  200. package/dist/src/data/symbols/focusSymbol.d.ts +0 -40
  201. package/dist/src/data/symbols/focusSymbol.js +0 -159
  202. package/dist/src/data/symbols/galaxySymbol.d.ts +0 -27
  203. package/dist/src/data/symbols/galaxySymbol.js +0 -61
  204. package/dist/src/data/symbols/hiddenSymbol.d.ts +0 -38
  205. package/dist/src/data/symbols/hiddenSymbol.js +0 -113
  206. package/dist/src/data/symbols/houseSymbol.d.ts +0 -33
  207. package/dist/src/data/symbols/houseSymbol.js +0 -104
  208. package/dist/src/data/symbols/index.d.ts +0 -3
  209. package/dist/src/data/symbols/index.js +0 -10
  210. package/dist/src/data/symbols/letterSymbol.d.ts +0 -32
  211. package/dist/src/data/symbols/letterSymbol.js +0 -118
  212. package/dist/src/data/symbols/lotusSymbol.d.ts +0 -30
  213. package/dist/src/data/symbols/lotusSymbol.js +0 -132
  214. package/dist/src/data/symbols/minesweeperSymbol.d.ts +0 -33
  215. package/dist/src/data/symbols/minesweeperSymbol.js +0 -106
  216. package/dist/src/data/symbols/myopiaSymbol.d.ts +0 -37
  217. package/dist/src/data/symbols/myopiaSymbol.js +0 -182
  218. package/dist/src/data/symbols/numberSymbol.d.ts +0 -19
  219. package/dist/src/data/symbols/numberSymbol.js +0 -32
  220. package/dist/src/data/symbols/symbol.d.ts +0 -29
  221. package/dist/src/data/symbols/symbol.js +0 -87
  222. package/dist/src/data/symbols/symbols.gen.d.ts +0 -14
  223. package/dist/src/data/symbols/symbols.gen.js +0 -18
  224. package/dist/src/data/symbols/viewpointSymbol.d.ts +0 -32
  225. package/dist/src/data/symbols/viewpointSymbol.js +0 -95
  226. package/dist/src/data/tile.d.ts +0 -26
  227. package/dist/src/data/tile.js +0 -56
  228. package/dist/src/data/tileConnections.d.ts +0 -25
  229. package/dist/src/data/tileConnections.js +0 -74
  230. package/dist/src/data/validate.d.ts +0 -5
  231. package/dist/src/data/validate.js +0 -131
  232. package/dist/src/data/validateAsync.d.ts +0 -15
  233. package/dist/src/data/validateAsync.js +0 -71
  234. package/dist/src/data/validateAsyncWorker.d.ts +0 -1
  235. package/dist/src/data/validateAsyncWorker.js +0 -9
  236. package/dist/src/index.d.ts +0 -108
  237. package/dist/src/index.js +0 -111
  238. package/dist/src/polyfill/streamPolyfill.d.ts +0 -2
  239. package/dist/src/polyfill/streamPolyfill.js +0 -1
@@ -1,7 +0,0 @@
1
- import EventIteratingSolver from '../eventIteratingSolver.js';
2
- export default class UniversalSolver extends EventIteratingSolver {
3
- readonly id = "universal";
4
- readonly author = "romain22222, Lysine";
5
- readonly description = "A backtracking solver that supports all rules and symbols (including underclued) but is less optimized.";
6
- protected createWorker(): Worker;
7
- }
@@ -1,13 +0,0 @@
1
- import EventIteratingSolver from '../eventIteratingSolver.js';
2
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
3
- ('vite-apply-code-mod');
4
- export default class UniversalSolver extends EventIteratingSolver {
5
- id = 'universal';
6
- author = 'romain22222, Lysine';
7
- description = 'A backtracking solver that supports all rules and symbols (including underclued) but is less optimized.';
8
- createWorker() {
9
- return new Worker(new URL('./universalWorker.js', import.meta.url), {
10
- type: 'module',
11
- });
12
- }
13
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,128 +0,0 @@
1
- import { Color, State } from '../../primitives.js';
2
- import { Serializer } from '../../serializer/allSerializers.js';
3
- import { instance as undercluedInstance } from '../../rules/undercluedRule.js';
4
- import { array } from '../../dataHelper.js';
5
- import validateGrid from '../../validate.js';
6
- function gridToRawTiles(grid) {
7
- return array(grid.width, grid.height, (x, y) => grid.getTile(x, y).color);
8
- }
9
- function rawTilesToGrid(rawTiles, grid) {
10
- return grid.copyWith({
11
- tiles: array(grid.width, grid.height, (x, y) => grid.getTile(x, y).withColor(rawTiles[y][x])),
12
- }, false, false);
13
- }
14
- function getNextTile(grid, rawTiles) {
15
- for (let y = 0; y < grid.height; y++) {
16
- for (let x = 0; x < grid.width; x++) {
17
- const tile = grid.getTile(x, y);
18
- if (!tile.exists || tile.fixed)
19
- continue;
20
- if (rawTiles[y][x] === Color.Gray)
21
- return [{ x, y }, Color.Dark];
22
- }
23
- }
24
- return undefined;
25
- }
26
- function backtrack(grid, rawTiles, submitSolution) {
27
- // Find the best empty cell to guess
28
- const target = getNextTile(grid, rawTiles);
29
- // Found a solution
30
- if (!target)
31
- return !submitSolution(rawTiles);
32
- const [pos, color] = target;
33
- const positions = grid.connections.getConnectedTiles(pos);
34
- for (let i = 0; i <= 1; i++) {
35
- const tile = i === 0 ? color : color === Color.Dark ? Color.Light : Color.Dark;
36
- positions.forEach(({ x, y }) => (rawTiles[y][x] = tile));
37
- const newGrid = rawTilesToGrid(rawTiles, grid);
38
- const isValid = validateGrid(newGrid, null);
39
- if (isValid.final !== State.Error &&
40
- backtrack(newGrid, rawTiles, submitSolution))
41
- return true;
42
- }
43
- positions.forEach(({ x, y }) => (rawTiles[y][x] = Color.Gray));
44
- return false;
45
- }
46
- function solveNormal(input, submitSolution) {
47
- const isValid = validateGrid(input, null);
48
- if (isValid.final === State.Error) {
49
- return;
50
- }
51
- // Call backtrack
52
- backtrack(input, gridToRawTiles(input), rawTiles => submitSolution(rawTiles ? rawTilesToGrid(rawTiles, input) : null));
53
- }
54
- function solveUnderclued(input) {
55
- let grid = input;
56
- const possibles = array(grid.width, grid.height, () => ({
57
- dark: false,
58
- light: false,
59
- }));
60
- function search(x, y, tile, color) {
61
- const newGrid = grid.copyWith({
62
- tiles: grid.setTile(x, y, tile.withColor(color)),
63
- }, false, false);
64
- // Solve
65
- let solution;
66
- solveNormal(newGrid, sol => {
67
- solution = sol;
68
- return false;
69
- });
70
- if (!solution)
71
- return false;
72
- // Update the new possible states
73
- solution.forEach((solTile, solX, solY) => {
74
- if (solTile.color === Color.Dark) {
75
- possibles[solY][solX].dark = true;
76
- }
77
- else {
78
- possibles[solY][solX].light = true;
79
- }
80
- });
81
- return true;
82
- }
83
- for (let y = 0; y < grid.height; y++) {
84
- for (let x = 0; x < grid.width; x++) {
85
- const tile = grid.getTile(x, y);
86
- if (!tile.exists || tile.color !== Color.Gray)
87
- continue;
88
- // We can skip this solve if it is proved to be solvable
89
- const darkPossible = possibles[y][x].dark || search(x, y, tile, Color.Dark);
90
- const lightPossible = possibles[y][x].light || search(x, y, tile, Color.Light);
91
- // No solution
92
- if (!darkPossible && !lightPossible)
93
- return null;
94
- if (darkPossible && !lightPossible)
95
- grid = grid.copyWith({
96
- tiles: grid.setTile(x, y, tile.withColor(Color.Dark)),
97
- }, false, false);
98
- if (!darkPossible && lightPossible)
99
- grid = grid.copyWith({
100
- tiles: grid.setTile(x, y, tile.withColor(Color.Light)),
101
- }, false, false);
102
- }
103
- }
104
- return grid;
105
- }
106
- function solve(grid, submitSolution) {
107
- if (grid.findRule(rule => rule.id === undercluedInstance.id)) {
108
- submitSolution(solveUnderclued(grid));
109
- }
110
- else {
111
- solveNormal(grid, submitSolution);
112
- }
113
- }
114
- onmessage = e => {
115
- const grid = Serializer.parseGrid(e.data);
116
- let count = 0;
117
- solve(grid, solution => {
118
- // if (solution) {
119
- // if (solution.resetTiles().colorEquals(solution)) {
120
- // solution = null;
121
- // }
122
- // }
123
- postMessage(solution ? Serializer.stringifyGrid(solution) : null);
124
- count += 1;
125
- return count < 2;
126
- });
127
- postMessage(null);
128
- };
@@ -1,31 +0,0 @@
1
- import { AnyConfig } from '../config.js';
2
- import GridData from '../grid.js';
3
- import NumberSymbol from './numberSymbol.js';
4
- export default class AreaNumberSymbol extends NumberSymbol {
5
- readonly title = "Area Number";
6
- private static readonly CONFIGS;
7
- private static readonly EXAMPLE_GRID;
8
- /**
9
- * **Area Numbers must equal region sizes**
10
- *
11
- * @param x - The x-coordinate of the symbol.
12
- * @param y - The y-coordinate of the symbol.
13
- * @param number - The area number.
14
- */
15
- constructor(x: number, y: number, number: number);
16
- get id(): string;
17
- get explanation(): string;
18
- get configs(): readonly AnyConfig[] | null;
19
- createExampleGrid(): GridData;
20
- countTiles(grid: GridData): {
21
- completed: number;
22
- possible: number;
23
- } | null;
24
- copyWith({ x, y, number, }: {
25
- x?: number;
26
- y?: number;
27
- number?: number;
28
- }): this;
29
- withNumber(number: number): this;
30
- }
31
- export declare const instance: AreaNumberSymbol;
@@ -1,80 +0,0 @@
1
- import { ConfigType } from '../config.js';
2
- import GridData from '../grid.js';
3
- import { Color } from '../primitives.js';
4
- import NumberSymbol from './numberSymbol.js';
5
- export default class AreaNumberSymbol extends NumberSymbol {
6
- title = 'Area Number';
7
- static CONFIGS = Object.freeze([
8
- {
9
- type: ConfigType.Number,
10
- default: 0,
11
- field: 'x',
12
- description: 'X',
13
- configurable: false,
14
- },
15
- {
16
- type: ConfigType.Number,
17
- default: 0,
18
- field: 'y',
19
- description: 'Y',
20
- configurable: false,
21
- },
22
- {
23
- type: ConfigType.Number,
24
- default: 1,
25
- field: 'number',
26
- description: 'Number',
27
- configurable: true,
28
- },
29
- ]);
30
- static EXAMPLE_GRID = Object.freeze(GridData.create(['wbbbb', 'wbbwb', 'bbwwb', 'bbbbb'])
31
- .addSymbol(new AreaNumberSymbol(2, 2, 3))
32
- .addSymbol(new AreaNumberSymbol(0, 1, 2)));
33
- /**
34
- * **Area Numbers must equal region sizes**
35
- *
36
- * @param x - The x-coordinate of the symbol.
37
- * @param y - The y-coordinate of the symbol.
38
- * @param number - The area number.
39
- */
40
- constructor(x, y, number) {
41
- super(x, y, number);
42
- }
43
- get id() {
44
- return `number`;
45
- }
46
- get explanation() {
47
- return `*Area Numbers* must equal region sizes`;
48
- }
49
- get configs() {
50
- return AreaNumberSymbol.CONFIGS;
51
- }
52
- createExampleGrid() {
53
- return AreaNumberSymbol.EXAMPLE_GRID;
54
- }
55
- countTiles(grid) {
56
- if (!this.validateSubtilePlacement(grid))
57
- return null;
58
- const thisX = Math.floor(this.x);
59
- const thisY = Math.floor(this.y);
60
- const color = grid.getTile(thisX, thisY).color;
61
- if (color === Color.Gray)
62
- return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
63
- let completeCount = 0;
64
- let grayCount = 0;
65
- grid.iterateArea({ x: thisX, y: thisY }, tile => tile.color === Color.Gray || tile.color === color, () => {
66
- grayCount++;
67
- });
68
- grid.iterateArea({ x: thisX, y: thisY }, tile => tile.color === color, () => {
69
- completeCount++;
70
- });
71
- return { completed: completeCount, possible: grayCount };
72
- }
73
- copyWith({ x, y, number, }) {
74
- return new AreaNumberSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
75
- }
76
- withNumber(number) {
77
- return this.copyWith({ number });
78
- }
79
- }
80
- export const instance = new AreaNumberSymbol(0, 0, 1);
@@ -1,35 +0,0 @@
1
- import { AnyConfig } from '../config.js';
2
- import GridData from '../grid.js';
3
- import CustomSymbol from './customSymbol.js';
4
- export default class CustomIconSymbol extends CustomSymbol {
5
- readonly icon: string;
6
- readonly rotation: number;
7
- readonly title = "Custom Icon Symbol";
8
- get configExplanation(): string;
9
- private static readonly EXAMPLE_GRID;
10
- private static readonly CONFIGS;
11
- /**
12
- * **A custom icon symbol**
13
- *
14
- * @param description - The description of the symbol. Leave this empty to hide the description.
15
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
16
- * @param x - The x-coordinate of the symbol.
17
- * @param y - The y-coordinate of the symbol.
18
- * @param icon - The icon to display. All available icons can be found at https://react-icons.github.io/react-icons/icons/md/
19
- * @param rotation - The rotation of the icon in degrees.
20
- */
21
- constructor(description: string, grid: GridData, x: number, y: number, icon: string, rotation?: number);
22
- get id(): string;
23
- get configs(): readonly AnyConfig[] | null;
24
- copyWith({ description, grid, x, y, icon, rotation, }: {
25
- description?: string;
26
- grid?: GridData;
27
- x?: number;
28
- y?: number;
29
- icon?: string;
30
- rotation?: number;
31
- }): this;
32
- withIcon(icon: string): this;
33
- withRotation(rotation: number): this;
34
- }
35
- export declare const instance: CustomIconSymbol;
@@ -1,94 +0,0 @@
1
- import { ConfigType } from '../config.js';
2
- import GridData from '../grid.js';
3
- import CustomSymbol from './customSymbol.js';
4
- export default class CustomIconSymbol extends CustomSymbol {
5
- icon;
6
- rotation;
7
- title = 'Custom Icon Symbol';
8
- get configExplanation() {
9
- return 'A customizable symbol. Your provided solution may override auto-validation.';
10
- }
11
- static EXAMPLE_GRID = Object.freeze(GridData.create(5, 4));
12
- static CONFIGS = Object.freeze([
13
- {
14
- type: ConfigType.Number,
15
- default: 0,
16
- field: 'x',
17
- description: 'X',
18
- configurable: false,
19
- },
20
- {
21
- type: ConfigType.Number,
22
- default: 0,
23
- field: 'y',
24
- description: 'Y',
25
- configurable: false,
26
- },
27
- {
28
- type: ConfigType.String,
29
- default: 'A *custom* text symbol',
30
- placeholder: 'Enter description. Emphasize with *asterisks*.',
31
- field: 'description',
32
- description: 'Description',
33
- explanation: 'A short descriptive text. Use *asterisks* to highlight keywords. Leave empty to hide the description.',
34
- configurable: true,
35
- },
36
- {
37
- type: ConfigType.Grid,
38
- default: CustomIconSymbol.EXAMPLE_GRID,
39
- field: 'grid',
40
- description: 'Thumbnail Grid',
41
- explanation: 'An example grid showing the symbol.',
42
- configurable: true,
43
- },
44
- {
45
- type: ConfigType.Icon,
46
- default: 'MdQuestionMark',
47
- field: 'icon',
48
- description: 'Icon',
49
- explanation: 'The icon displayed on the grid. All available icons at https://react-icons.github.io/react-icons/icons/md/',
50
- configurable: true,
51
- },
52
- {
53
- type: ConfigType.Number,
54
- default: 0,
55
- field: 'rotation',
56
- description: 'Rotation',
57
- explanation: 'Rotate the symbol by the given degrees.',
58
- configurable: true,
59
- },
60
- ]);
61
- /**
62
- * **A custom icon symbol**
63
- *
64
- * @param description - The description of the symbol. Leave this empty to hide the description.
65
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
66
- * @param x - The x-coordinate of the symbol.
67
- * @param y - The y-coordinate of the symbol.
68
- * @param icon - The icon to display. All available icons can be found at https://react-icons.github.io/react-icons/icons/md/
69
- * @param rotation - The rotation of the icon in degrees.
70
- */
71
- constructor(description, grid, x, y, icon, rotation = 0) {
72
- super(description, grid, x, y);
73
- this.icon = icon;
74
- this.rotation = rotation;
75
- this.icon = icon;
76
- this.rotation = rotation;
77
- }
78
- get id() {
79
- return `custom_icon`;
80
- }
81
- get configs() {
82
- return CustomIconSymbol.CONFIGS;
83
- }
84
- copyWith({ description, grid, x, y, icon, rotation, }) {
85
- return new CustomIconSymbol(description ?? this.description, grid ?? this.grid, x ?? this.x, y ?? this.y, icon ?? this.icon, rotation ?? this.rotation);
86
- }
87
- withIcon(icon) {
88
- return this.copyWith({ icon });
89
- }
90
- withRotation(rotation) {
91
- return this.copyWith({ rotation });
92
- }
93
- }
94
- export const instance = new CustomIconSymbol('A *custom* icon symbol', GridData.create(5, 4), 0, 0, 'MdQuestionMark');
@@ -1,25 +0,0 @@
1
- import { SymbolMergeHandler } from '../events/onSymbolMerge.js';
2
- import GridData from '../grid.js';
3
- import { State } from '../primitives.js';
4
- import Symbol from './symbol.js';
5
- export default abstract class CustomSymbol extends Symbol implements SymbolMergeHandler {
6
- readonly description: string;
7
- readonly grid: GridData;
8
- /**
9
- * **A custom symbol**
10
- *
11
- * @param description - The description of the symbol. Leave this empty to hide the description.
12
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
13
- * @param x - The x-coordinate of the symbol.
14
- * @param y - The y-coordinate of the symbol.
15
- */
16
- constructor(description: string, grid: GridData, x: number, y: number);
17
- get explanation(): string;
18
- createExampleGrid(): GridData;
19
- validateSymbol(_grid: GridData): State;
20
- get validateWithSolution(): boolean;
21
- descriptionEquals(other: Symbol): boolean;
22
- withDescription(description: string): this;
23
- withGrid(grid: GridData): this;
24
- }
25
- export declare const instance: undefined;
@@ -1,45 +0,0 @@
1
- import { State } from '../primitives.js';
2
- import Symbol from './symbol.js';
3
- export default class CustomSymbol extends Symbol {
4
- description;
5
- grid;
6
- /**
7
- * **A custom symbol**
8
- *
9
- * @param description - The description of the symbol. Leave this empty to hide the description.
10
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
11
- * @param x - The x-coordinate of the symbol.
12
- * @param y - The y-coordinate of the symbol.
13
- */
14
- constructor(description, grid, x, y) {
15
- super(x, y);
16
- this.description = description;
17
- this.grid = grid;
18
- this.description = description;
19
- this.grid = grid;
20
- }
21
- get explanation() {
22
- return this.description;
23
- }
24
- createExampleGrid() {
25
- return this.grid;
26
- }
27
- validateSymbol(_grid) {
28
- return State.Incomplete;
29
- }
30
- get validateWithSolution() {
31
- return true;
32
- }
33
- descriptionEquals(other) {
34
- return (this.id === other.id &&
35
- this.explanation === other.explanation &&
36
- this.createExampleGrid().equals(other.createExampleGrid()));
37
- }
38
- withDescription(description) {
39
- return this.copyWith({ description });
40
- }
41
- withGrid(grid) {
42
- return this.copyWith({ grid });
43
- }
44
- }
45
- export const instance = undefined;
@@ -1,35 +0,0 @@
1
- import { AnyConfig } from '../config.js';
2
- import GridData from '../grid.js';
3
- import CustomSymbol from './customSymbol.js';
4
- export default class CustomTextSymbol extends CustomSymbol {
5
- readonly text: string;
6
- readonly rotation: number;
7
- readonly title = "Custom Text Symbol";
8
- get configExplanation(): string;
9
- private static readonly EXAMPLE_GRID;
10
- private static readonly CONFIGS;
11
- /**
12
- * **A custom text symbol**
13
- *
14
- * @param description - The description of the symbol. Leave this empty to hide the description.
15
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
16
- * @param x - The x-coordinate of the symbol.
17
- * @param y - The y-coordinate of the symbol.
18
- * @param text - The text to display.
19
- * @param rotation - The rotation of the text in degrees.
20
- */
21
- constructor(description: string, grid: GridData, x: number, y: number, text: string, rotation?: number);
22
- get id(): string;
23
- get configs(): readonly AnyConfig[] | null;
24
- copyWith({ description, grid, x, y, text, rotation, }: {
25
- description?: string;
26
- grid?: GridData;
27
- x?: number;
28
- y?: number;
29
- text?: string;
30
- rotation?: number;
31
- }): this;
32
- withText(text: string): this;
33
- withRotation(rotation: number): this;
34
- }
35
- export declare const instance: CustomTextSymbol;
@@ -1,95 +0,0 @@
1
- import { ConfigType } from '../config.js';
2
- import GridData from '../grid.js';
3
- import CustomSymbol from './customSymbol.js';
4
- export default class CustomTextSymbol extends CustomSymbol {
5
- text;
6
- rotation;
7
- title = 'Custom Text Symbol';
8
- get configExplanation() {
9
- return 'A customizable symbol. Your provided solution may override auto-validation.';
10
- }
11
- static EXAMPLE_GRID = Object.freeze(GridData.create(5, 4));
12
- static CONFIGS = Object.freeze([
13
- {
14
- type: ConfigType.Number,
15
- default: 0,
16
- field: 'x',
17
- description: 'X',
18
- configurable: false,
19
- },
20
- {
21
- type: ConfigType.Number,
22
- default: 0,
23
- field: 'y',
24
- description: 'Y',
25
- configurable: false,
26
- },
27
- {
28
- type: ConfigType.String,
29
- default: 'A *custom* text symbol',
30
- placeholder: 'Enter description. Emphasize with *asterisks*.',
31
- field: 'description',
32
- description: 'Description',
33
- explanation: 'A short descriptive text. Use *asterisks* to highlight keywords. Leave empty to hide the description.',
34
- configurable: true,
35
- },
36
- {
37
- type: ConfigType.Grid,
38
- default: CustomTextSymbol.EXAMPLE_GRID,
39
- field: 'grid',
40
- description: 'Thumbnail Grid',
41
- explanation: 'An example grid showing the symbol.',
42
- configurable: true,
43
- },
44
- {
45
- type: ConfigType.String,
46
- default: 'X',
47
- placeholder: 'Short text to be displayed on the symbol',
48
- field: 'text',
49
- description: 'Text',
50
- explanation: 'The text displayed on the grid. You should use no more than 2 lines of 4 characters each.',
51
- configurable: true,
52
- },
53
- {
54
- type: ConfigType.Number,
55
- default: 0,
56
- field: 'rotation',
57
- description: 'Rotation',
58
- explanation: 'Rotate the symbol by the given degrees.',
59
- configurable: true,
60
- },
61
- ]);
62
- /**
63
- * **A custom text symbol**
64
- *
65
- * @param description - The description of the symbol. Leave this empty to hide the description.
66
- * @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
67
- * @param x - The x-coordinate of the symbol.
68
- * @param y - The y-coordinate of the symbol.
69
- * @param text - The text to display.
70
- * @param rotation - The rotation of the text in degrees.
71
- */
72
- constructor(description, grid, x, y, text, rotation = 0) {
73
- super(description, grid, x, y);
74
- this.text = text;
75
- this.rotation = rotation;
76
- this.text = text;
77
- this.rotation = rotation;
78
- }
79
- get id() {
80
- return `custom_text`;
81
- }
82
- get configs() {
83
- return CustomTextSymbol.CONFIGS;
84
- }
85
- copyWith({ description, grid, x, y, text, rotation, }) {
86
- return new CustomTextSymbol(description ?? this.description, grid ?? this.grid, x ?? this.x, y ?? this.y, text ?? this.text, rotation ?? this.rotation);
87
- }
88
- withText(text) {
89
- return this.copyWith({ text });
90
- }
91
- withRotation(rotation) {
92
- return this.copyWith({ rotation });
93
- }
94
- }
95
- export const instance = new CustomTextSymbol('A *custom* text symbol', GridData.create(5, 4), 0, 0, 'X');
@@ -1,36 +0,0 @@
1
- import { AnyConfig } from '../config.js';
2
- import GridData from '../grid.js';
3
- import { Orientation } from '../primitives.js';
4
- import NumberSymbol from './numberSymbol.js';
5
- export default class DartSymbol extends NumberSymbol {
6
- readonly orientation: Orientation;
7
- readonly title = "Dart";
8
- private static readonly CONFIGS;
9
- private static readonly EXAMPLE_GRID;
10
- /**
11
- * **Darts count opposite color cells in that direction**
12
- *
13
- * @param x - The x-coordinate of the symbol.
14
- * @param y - The y-coordinate of the symbol.
15
- * @param number - The number of cells seen by the symbol.
16
- * @param orientation - The orientation of the symbol.
17
- */
18
- constructor(x: number, y: number, number: number, orientation: Orientation);
19
- get id(): string;
20
- get placementStep(): number;
21
- get explanation(): string;
22
- get configs(): readonly AnyConfig[] | null;
23
- createExampleGrid(): GridData;
24
- countTiles(grid: GridData): {
25
- completed: number;
26
- possible: number;
27
- };
28
- copyWith({ x, y, number, orientation, }: {
29
- x?: number;
30
- y?: number;
31
- number?: number;
32
- orientation?: Orientation;
33
- }): this;
34
- withNumber(number: number): this;
35
- }
36
- export declare const instance: DartSymbol;