@logic-pad/core 0.26.1 → 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 (241) hide show
  1. package/README.md +31 -31
  2. package/assets/logic-core.global.d.ts +3264 -3262
  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 -156
  130. package/dist/src/data/solver/backtrack/backtrackSolver.d.ts +0 -11
  131. package/dist/src/data/solver/backtrack/backtrackSolver.js +0 -54
  132. package/dist/src/data/solver/backtrack/backtrackWorker.d.ts +0 -1
  133. package/dist/src/data/solver/backtrack/backtrackWorker.js +0 -312
  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 -95
  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 -124
  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 -215
  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 -15
  223. package/dist/src/data/symbols/symbols.gen.js +0 -19
  224. package/dist/src/data/symbols/unsupportedSymbol.d.ts +0 -23
  225. package/dist/src/data/symbols/unsupportedSymbol.js +0 -47
  226. package/dist/src/data/symbols/viewpointSymbol.d.ts +0 -32
  227. package/dist/src/data/symbols/viewpointSymbol.js +0 -95
  228. package/dist/src/data/tile.d.ts +0 -26
  229. package/dist/src/data/tile.js +0 -56
  230. package/dist/src/data/tileConnections.d.ts +0 -25
  231. package/dist/src/data/tileConnections.js +0 -74
  232. package/dist/src/data/validate.d.ts +0 -5
  233. package/dist/src/data/validate.js +0 -131
  234. package/dist/src/data/validateAsync.d.ts +0 -15
  235. package/dist/src/data/validateAsync.js +0 -71
  236. package/dist/src/data/validateAsyncWorker.d.ts +0 -1
  237. package/dist/src/data/validateAsyncWorker.js +0 -9
  238. package/dist/src/index.d.ts +0 -109
  239. package/dist/src/index.js +0 -112
  240. package/dist/src/polyfill/streamPolyfill.d.ts +0 -2
  241. package/dist/src/polyfill/streamPolyfill.js +0 -1
@@ -1,207 +0,0 @@
1
- import { ConfigType } from '../config.js';
2
- import GridData from '../grid.js';
3
- import { Color, Orientation, State, } from '../primitives.js';
4
- import Rule from './rule.js';
5
- import validateGrid from '../validate.js';
6
- import Symbol from '../symbols/symbol.js';
7
- import LetterSymbol from '../symbols/letterSymbol.js';
8
- import GalaxySymbol from '../symbols/galaxySymbol.js';
9
- import LotusSymbol from '../symbols/lotusSymbol.js';
10
- import AreaNumberSymbol from '../symbols/areaNumberSymbol.js';
11
- class IgnoredSymbol extends Symbol {
12
- symbol;
13
- state;
14
- title = 'Ignored Symbol';
15
- constructor(symbol, state) {
16
- super(symbol.x, symbol.y);
17
- this.symbol = symbol;
18
- this.state = state;
19
- this.symbol = symbol;
20
- this.state = state;
21
- }
22
- get id() {
23
- return `ignored_${this.symbol.id}`;
24
- }
25
- get explanation() {
26
- return this.symbol.explanation;
27
- }
28
- get configs() {
29
- return [];
30
- }
31
- createExampleGrid() {
32
- return this.symbol.createExampleGrid();
33
- }
34
- get necessaryForCompletion() {
35
- return this.symbol.necessaryForCompletion;
36
- }
37
- get visibleWhenSolving() {
38
- return this.symbol.visibleWhenSolving;
39
- }
40
- get sortOrder() {
41
- return this.symbol.sortOrder;
42
- }
43
- validateSymbol(_grid, _solution) {
44
- return this.state;
45
- }
46
- copyWith({ symbol, state }) {
47
- return new IgnoredSymbol(symbol ?? this.symbol, state ?? this.state);
48
- }
49
- withSymbol(symbol) {
50
- return this.copyWith({ symbol });
51
- }
52
- equals(other) {
53
- return other === this;
54
- }
55
- }
56
- class IgnoredRule extends Rule {
57
- rule;
58
- state;
59
- title = 'Ignored Rule';
60
- constructor(rule, state) {
61
- super();
62
- this.rule = rule;
63
- this.state = state;
64
- this.rule = rule;
65
- this.state = state;
66
- }
67
- get searchVariants() {
68
- return [];
69
- }
70
- get id() {
71
- return `ignored_${this.rule.id}`;
72
- }
73
- get explanation() {
74
- return this.rule.explanation;
75
- }
76
- get configs() {
77
- return [];
78
- }
79
- createExampleGrid() {
80
- return this.rule.createExampleGrid();
81
- }
82
- get necessaryForCompletion() {
83
- return this.rule.necessaryForCompletion;
84
- }
85
- get visibleWhenSolving() {
86
- return this.rule.visibleWhenSolving;
87
- }
88
- get isSingleton() {
89
- return this.rule.isSingleton;
90
- }
91
- validateGrid(_grid) {
92
- if (this.state === State.Error)
93
- return { state: State.Error, positions: [] };
94
- else
95
- return { state: this.state };
96
- }
97
- copyWith({ rule, state }) {
98
- return new IgnoredRule(rule ?? this.rule, state ?? this.state);
99
- }
100
- equals(other) {
101
- return other === this;
102
- }
103
- }
104
- export default class LyingSymbolRule extends Rule {
105
- count;
106
- title = 'Lying Symbols';
107
- static EXAMPLE_GRID = Object.freeze(GridData.create(['bbbbw', 'wwbbb', 'bbbbw', 'wbbww']).withSymbols([
108
- new LetterSymbol(4, 0, 'A'),
109
- new GalaxySymbol(1, 1),
110
- new LotusSymbol(2, 2, Orientation.Up),
111
- new LetterSymbol(0, 3, 'A'),
112
- new AreaNumberSymbol(4, 3, 1),
113
- ]));
114
- static CONFIGS = Object.freeze([
115
- {
116
- type: ConfigType.Number,
117
- default: 1,
118
- min: 1,
119
- max: 100,
120
- step: 1,
121
- field: 'count',
122
- description: 'Number of liars',
123
- explanation: 'Number of symbols that are not satisfied in the final solution.',
124
- configurable: true,
125
- },
126
- ]);
127
- static SEARCH_VARIANTS = [
128
- new LyingSymbolRule(1).searchVariant(),
129
- ];
130
- /**
131
- * **<count> symbols are lying and are incorrect**
132
- *
133
- * @param count Number of lying symbols
134
- */
135
- constructor(count) {
136
- super();
137
- this.count = count;
138
- this.count = count;
139
- }
140
- get id() {
141
- return `lying_symbols`;
142
- }
143
- get explanation() {
144
- return `${this.count} symbol${this.count <= 1 ? ' is' : 's are'} *lying* and ${this.count <= 1 ? 'is' : 'are'} incorrect`;
145
- }
146
- get configs() {
147
- return LyingSymbolRule.CONFIGS;
148
- }
149
- createExampleGrid() {
150
- return LyingSymbolRule.EXAMPLE_GRID;
151
- }
152
- get searchVariants() {
153
- return LyingSymbolRule.SEARCH_VARIANTS;
154
- }
155
- validateGrid(_) {
156
- return { state: State.Incomplete };
157
- }
158
- get isSingleton() {
159
- return true;
160
- }
161
- onFinalValidation(grid, solution, state) {
162
- const ignoredSymbols = [];
163
- state.symbols.forEach((values, key) => {
164
- values.forEach((state, idx) => {
165
- if (state === State.Error)
166
- ignoredSymbols.push([key, idx]);
167
- });
168
- });
169
- if (ignoredSymbols.length > this.count) {
170
- const thisIdx = grid.rules.findIndex(rule => rule.id === this.id);
171
- return {
172
- final: State.Error,
173
- rules: state.rules.map((rule, idx) => idx === thisIdx ? { state: State.Error, positions: [] } : rule),
174
- symbols: state.symbols,
175
- };
176
- }
177
- const newSymbols = new Map();
178
- grid.symbols.forEach((values, key) => {
179
- values.forEach((symbol, idx) => {
180
- if (!newSymbols.has(key)) {
181
- newSymbols.set(key, []);
182
- }
183
- if (ignoredSymbols.some(([k, i]) => k === key && i === idx)) {
184
- newSymbols.get(key).push(new IgnoredSymbol(symbol, State.Ignored));
185
- }
186
- else {
187
- newSymbols.get(key).push(symbol);
188
- }
189
- });
190
- });
191
- const newRules = grid.rules.map(rule => rule.id === this.id
192
- ? new IgnoredRule(this, ignoredSymbols.length === this.count
193
- ? State.Satisfied
194
- : grid.getTileCount(true, false, Color.Gray) === 0
195
- ? State.Error
196
- : State.Incomplete)
197
- : rule);
198
- return validateGrid(grid.copyWith({ rules: newRules, symbols: newSymbols }), solution);
199
- }
200
- copyWith({ count }) {
201
- return new LyingSymbolRule(count ?? this.count);
202
- }
203
- withCount(count) {
204
- return this.copyWith({ count });
205
- }
206
- }
207
- export const instance = new LyingSymbolRule(1);
@@ -1,82 +0,0 @@
1
- import { AnyConfig } from '../config.js';
2
- import Configurable from '../configurable.js';
3
- import { Instrument } from '../primitives.js';
4
- export declare class Row extends Configurable {
5
- /**
6
- * The note to play at this row, or null to keep the current note from the previous control line.
7
- * If this is null from the first control line, the note will be silent.
8
- */
9
- readonly note: string | null;
10
- /**
11
- * The instrument to play the note with, or null to keep the current instrument from the previous control line.
12
- * If this is null from the first control line, the instrument will be "piano".
13
- * This has no effect if the current note is a drum sample.
14
- */
15
- readonly instrument: Instrument | null;
16
- /**
17
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
18
- * Ranges from 0 to 1
19
- */
20
- readonly velocity: number | null;
21
- readonly title = "Music Grid - Row";
22
- readonly configExplanation = "Configure the playback settings from this tile onwards.";
23
- private static readonly CONFIGS;
24
- constructor(
25
- /**
26
- * The note to play at this row, or null to keep the current note from the previous control line.
27
- * If this is null from the first control line, the note will be silent.
28
- */
29
- note: string | null,
30
- /**
31
- * The instrument to play the note with, or null to keep the current instrument from the previous control line.
32
- * If this is null from the first control line, the instrument will be "piano".
33
- * This has no effect if the current note is a drum sample.
34
- */
35
- instrument: Instrument | null,
36
- /**
37
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
38
- * Ranges from 0 to 1
39
- */
40
- velocity: number | null);
41
- get configs(): readonly AnyConfig[] | null;
42
- copyWith({ note, instrument, velocity, }: {
43
- note?: string | null;
44
- instrument?: Instrument | null;
45
- velocity?: number | null;
46
- }): this;
47
- }
48
- export declare class ControlLine extends Configurable {
49
- readonly column: number;
50
- readonly bpm: number | null;
51
- readonly pedal: boolean | null;
52
- readonly checkpoint: boolean;
53
- readonly rows: readonly Row[];
54
- readonly title = "Music Grid - Control Line";
55
- readonly configExplanation = "Configure the playback settings from this point onwards.";
56
- private static readonly CONFIGS;
57
- /**
58
- * Configure playback settings, taking effect at the given column (inclusive)
59
- * @param column The column at which the settings take effect
60
- * @param bpm The new beats per minute, or null to keep the current value from the previous control line
61
- * @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
62
- * @param checkpoint Whether this control line is a checkpoint
63
- * @param rows The notes to play at each row. This list is automatically resized to match the height of the grid. You may pass in an empty list if none of the rows need to be changed.
64
- */
65
- constructor(column: number, bpm: number | null, pedal: boolean | null, checkpoint: boolean, rows: readonly Row[]);
66
- get configs(): readonly AnyConfig[] | null;
67
- copyWith({ column, bpm, pedal, checkpoint, rows, }: {
68
- column?: number;
69
- bpm?: number | null;
70
- pedal?: boolean | null;
71
- checkpoint?: boolean;
72
- rows?: readonly Row[];
73
- }): this;
74
- withColumn(column: number): this;
75
- withBpm(bpm: number | null): this;
76
- withPedal(pedal: boolean | null): this;
77
- withCheckpoint(checkpoint: boolean): this;
78
- withRows(rows: readonly Row[]): this;
79
- equals(other: ControlLine): boolean;
80
- get isEmpty(): boolean;
81
- }
82
- export declare const instance: undefined;
@@ -1,167 +0,0 @@
1
- import { ConfigType } from '../config.js';
2
- import Configurable from '../configurable.js';
3
- import { Instrument } from '../primitives.js';
4
- export class Row extends Configurable {
5
- note;
6
- instrument;
7
- velocity;
8
- title = 'Music Grid - Row';
9
- configExplanation = 'Configure the playback settings from this tile onwards.';
10
- static CONFIGS = Object.freeze([
11
- {
12
- type: ConfigType.NullableNote,
13
- default: 'C4',
14
- field: 'note',
15
- description: 'Note',
16
- explanation: 'The musical note or sample to play.',
17
- configurable: true,
18
- },
19
- {
20
- type: ConfigType.NullableInstrument,
21
- default: Instrument.Piano,
22
- field: 'instrument',
23
- description: 'Instrument',
24
- explanation: 'The musical instrument to use. This has no effect if the current note is a drum sample.',
25
- configurable: true,
26
- },
27
- {
28
- type: ConfigType.NullableNumber,
29
- default: 0.5,
30
- min: 0,
31
- max: 1,
32
- step: 0.2,
33
- field: 'velocity',
34
- description: 'Velocity',
35
- explanation: 'The volume to play the note at.',
36
- configurable: true,
37
- },
38
- ]);
39
- constructor(
40
- /**
41
- * The note to play at this row, or null to keep the current note from the previous control line.
42
- * If this is null from the first control line, the note will be silent.
43
- */
44
- note,
45
- /**
46
- * The instrument to play the note with, or null to keep the current instrument from the previous control line.
47
- * If this is null from the first control line, the instrument will be "piano".
48
- * This has no effect if the current note is a drum sample.
49
- */
50
- instrument,
51
- /**
52
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
53
- * Ranges from 0 to 1
54
- */
55
- velocity) {
56
- super();
57
- this.note = note;
58
- this.instrument = instrument;
59
- this.velocity = velocity;
60
- this.note = note;
61
- this.instrument = instrument;
62
- this.velocity = velocity;
63
- }
64
- get configs() {
65
- return Row.CONFIGS;
66
- }
67
- copyWith({ note, instrument, velocity, }) {
68
- return new Row(note !== undefined ? note : this.note, instrument !== undefined ? instrument : this.instrument, velocity !== undefined ? velocity : this.velocity);
69
- }
70
- }
71
- export class ControlLine extends Configurable {
72
- column;
73
- bpm;
74
- pedal;
75
- checkpoint;
76
- rows;
77
- title = 'Music Grid - Control Line';
78
- configExplanation = 'Configure the playback settings from this point onwards.';
79
- static CONFIGS = Object.freeze([
80
- {
81
- type: ConfigType.NullableNumber,
82
- default: 120,
83
- min: 20,
84
- max: 1000,
85
- field: 'bpm',
86
- description: 'BPM',
87
- explanation: 'Beats per minute for the playback.',
88
- configurable: true,
89
- },
90
- {
91
- type: ConfigType.NullableBoolean,
92
- default: false,
93
- field: 'pedal',
94
- description: 'Pedal',
95
- explanation: 'For piano notes, whether the pedal is pressed to sustain the sound.',
96
- configurable: true,
97
- },
98
- {
99
- type: ConfigType.Boolean,
100
- default: false,
101
- field: 'checkpoint',
102
- description: 'Checkpoint',
103
- explanation: 'Whether players can start playback from this position.',
104
- configurable: true,
105
- },
106
- ]);
107
- /**
108
- * Configure playback settings, taking effect at the given column (inclusive)
109
- * @param column The column at which the settings take effect
110
- * @param bpm The new beats per minute, or null to keep the current value from the previous control line
111
- * @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
112
- * @param checkpoint Whether this control line is a checkpoint
113
- * @param rows The notes to play at each row. This list is automatically resized to match the height of the grid. You may pass in an empty list if none of the rows need to be changed.
114
- */
115
- constructor(column, bpm, pedal, checkpoint, rows) {
116
- super();
117
- this.column = column;
118
- this.bpm = bpm;
119
- this.pedal = pedal;
120
- this.checkpoint = checkpoint;
121
- this.rows = rows;
122
- this.column = Math.floor(column);
123
- this.bpm = bpm;
124
- this.pedal = pedal;
125
- this.checkpoint = checkpoint;
126
- this.rows = rows;
127
- }
128
- get configs() {
129
- return ControlLine.CONFIGS;
130
- }
131
- copyWith({ column, bpm, pedal, checkpoint, rows, }) {
132
- return new ControlLine(column ?? this.column, bpm !== undefined ? bpm : this.bpm, pedal !== undefined ? pedal : this.pedal, checkpoint ?? this.checkpoint, rows ?? this.rows);
133
- }
134
- withColumn(column) {
135
- return this.copyWith({ column });
136
- }
137
- withBpm(bpm) {
138
- return this.copyWith({ bpm });
139
- }
140
- withPedal(pedal) {
141
- return this.copyWith({ pedal });
142
- }
143
- withCheckpoint(checkpoint) {
144
- return this.copyWith({ checkpoint });
145
- }
146
- withRows(rows) {
147
- return this.copyWith({ rows });
148
- }
149
- equals(other) {
150
- return (this.column === other.column &&
151
- this.bpm === other.bpm &&
152
- this.pedal === other.pedal &&
153
- this.checkpoint === other.checkpoint &&
154
- this.rows.length === other.rows.length &&
155
- this.rows.every((row, i) => {
156
- const otherRow = other.rows[i];
157
- return row.note === otherRow.note && row.velocity === otherRow.velocity;
158
- }));
159
- }
160
- get isEmpty() {
161
- return (this.bpm === null &&
162
- this.pedal === null &&
163
- !this.checkpoint &&
164
- !this.rows.some(row => row.note !== null || row.velocity !== null));
165
- }
166
- }
167
- export const instance = undefined;
@@ -1,51 +0,0 @@
1
- import { AnyConfig } from '../config.js';
2
- import { GridChangeHandler } from '../events/onGridChange.js';
3
- import { GridResizeHandler } from '../events/onGridResize.js';
4
- import { SetGridHandler } from '../events/onSetGrid.js';
5
- import GridData from '../grid.js';
6
- import { RuleState } from '../primitives.js';
7
- import { ControlLine } from './musicControlLine.js';
8
- import Rule, { SearchVariant } from './rule.js';
9
- export default class MusicGridRule extends Rule implements GridChangeHandler, SetGridHandler, GridResizeHandler {
10
- readonly controlLines: readonly ControlLine[];
11
- readonly track: GridData | null;
12
- readonly normalizeVelocity: boolean;
13
- readonly title = "Music Grid";
14
- get configExplanation(): string;
15
- private static readonly EXAMPLE_GRID;
16
- private static readonly CONFIGS;
17
- private static readonly SEARCH_VARIANTS;
18
- /**
19
- * **Music Grid: Listen to the solution**
20
- * @param controlLines Denote changes in the playback settings. At least one control line at column 0 should be present to enable playback.
21
- * @param track The grid to be played when "listen" is clicked. Set as null to play the solution.
22
- * @param normalizeVelocity Whether to normalize the velocity of the notes by their pitch such that lower notes are played softer.
23
- */
24
- constructor(controlLines: readonly ControlLine[], track: GridData | null, normalizeVelocity?: boolean);
25
- get id(): string;
26
- get explanation(): string;
27
- get configs(): readonly AnyConfig[] | null;
28
- createExampleGrid(): GridData;
29
- get searchVariants(): SearchVariant[];
30
- validateGrid(_grid: GridData): RuleState;
31
- onSetGrid(_oldGrid: GridData, newGrid: GridData, _solution: GridData | null): GridData;
32
- onGridChange(newGrid: GridData): this;
33
- onGridResize(_grid: GridData, mode: 'insert' | 'remove', direction: 'row' | 'column', index: number): this | null;
34
- /**
35
- * Add or replace a control line.
36
- * @param controlLine The control line to set.
37
- * @returns A new rule with the control line set.
38
- */
39
- setControlLine(controlLine: ControlLine): this;
40
- withTrack(track: GridData | null): this;
41
- copyWith({ controlLines, track, normalizeVelocity, }: {
42
- controlLines?: readonly ControlLine[];
43
- track?: GridData | null;
44
- normalizeVelocity?: boolean;
45
- }): this;
46
- get validateWithSolution(): boolean;
47
- get isSingleton(): boolean;
48
- static mergeControlLines(...lines: ControlLine[]): ControlLine;
49
- static deduplicateControlLines(lines: readonly ControlLine[]): ControlLine[];
50
- }
51
- export declare const instance: MusicGridRule;