@logic-pad/core 0.4.6 → 0.5.0
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.
- package/assets/logic-core.global.d.ts +52 -4
- package/dist/data/primitives.d.ts +19 -1
- package/dist/data/primitives.js +20 -0
- package/dist/data/rules/lyingSymbolRule.d.ts +30 -0
- package/dist/data/rules/lyingSymbolRule.js +214 -0
- package/dist/data/rules/mysteryRule.js +1 -1
- package/dist/data/rules/offByXRule.d.ts +1 -1
- package/dist/data/rules/offByXRule.js +7 -3
- package/dist/data/rules/rules.gen.d.ts +1 -0
- package/dist/data/rules/rules.gen.js +1 -0
- package/dist/data/validate.d.ts +1 -1
- package/dist/data/validate.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
|
@@ -31,9 +31,25 @@ declare global {
|
|
|
31
31
|
Underclued = 'underclued',
|
|
32
32
|
}
|
|
33
33
|
export declare enum State {
|
|
34
|
+
/**
|
|
35
|
+
* Describes the violation of a rule.
|
|
36
|
+
*/
|
|
34
37
|
Error = 'error',
|
|
38
|
+
/**
|
|
39
|
+
* Describes that a rule is satisfied and complete in the current grid.
|
|
40
|
+
*/
|
|
35
41
|
Satisfied = 'satisfied',
|
|
42
|
+
/**
|
|
43
|
+
* Describes that a rule is not violated, but is not yet complete in the current grid.
|
|
44
|
+
*/
|
|
36
45
|
Incomplete = 'incomplete',
|
|
46
|
+
/**
|
|
47
|
+
* Describes that a rule is violated but ignored due to the effect of another rule.
|
|
48
|
+
*/
|
|
49
|
+
Ignored = 'ignored',
|
|
50
|
+
}
|
|
51
|
+
export declare namespace State {
|
|
52
|
+
function isSatisfied(state: State): boolean;
|
|
37
53
|
}
|
|
38
54
|
export type RuleState =
|
|
39
55
|
| {
|
|
@@ -45,6 +61,9 @@ declare global {
|
|
|
45
61
|
}
|
|
46
62
|
| {
|
|
47
63
|
readonly state: State.Incomplete;
|
|
64
|
+
}
|
|
65
|
+
| {
|
|
66
|
+
readonly state: State.Ignored;
|
|
48
67
|
};
|
|
49
68
|
export interface GridState {
|
|
50
69
|
final: State;
|
|
@@ -1511,6 +1530,35 @@ declare global {
|
|
|
1511
1530
|
}): this;
|
|
1512
1531
|
}
|
|
1513
1532
|
export declare const allRules: Map<string, Rule>;
|
|
1533
|
+
export declare class LyingSymbolRule
|
|
1534
|
+
extends Rule
|
|
1535
|
+
implements FinalValidationHandler
|
|
1536
|
+
{
|
|
1537
|
+
readonly count: number;
|
|
1538
|
+
private static readonly EXAMPLE_GRID;
|
|
1539
|
+
private static readonly CONFIGS;
|
|
1540
|
+
private static readonly SEARCH_VARIANTS;
|
|
1541
|
+
/**
|
|
1542
|
+
* **<count> symbols are lying and can be ignored**
|
|
1543
|
+
*
|
|
1544
|
+
* @param count Number of lying symbols
|
|
1545
|
+
*/
|
|
1546
|
+
constructor(count: number);
|
|
1547
|
+
get id(): string;
|
|
1548
|
+
get explanation(): string;
|
|
1549
|
+
get configs(): readonly AnyConfig[] | null;
|
|
1550
|
+
createExampleGrid(): GridData;
|
|
1551
|
+
get searchVariants(): SearchVariant[];
|
|
1552
|
+
validateGrid(_: GridData): RuleState;
|
|
1553
|
+
get isSingleton(): boolean;
|
|
1554
|
+
onFinalValidation(
|
|
1555
|
+
grid: GridData,
|
|
1556
|
+
solution: GridData | null,
|
|
1557
|
+
state: GridState
|
|
1558
|
+
): GridState;
|
|
1559
|
+
copyWith({ count }: { count?: number }): this;
|
|
1560
|
+
withCount(count: number): this;
|
|
1561
|
+
}
|
|
1514
1562
|
export declare class MysteryRule
|
|
1515
1563
|
extends Rule
|
|
1516
1564
|
implements FinalValidationHandler, GridChangeHandler, GridResizeHandler
|
|
@@ -1574,7 +1622,7 @@ declare global {
|
|
|
1574
1622
|
get configs(): readonly AnyConfig[] | null;
|
|
1575
1623
|
createExampleGrid(): GridData;
|
|
1576
1624
|
get searchVariants(): SearchVariant[];
|
|
1577
|
-
validateGrid(
|
|
1625
|
+
validateGrid(grid: GridData): RuleState;
|
|
1578
1626
|
onSymbolValidation(
|
|
1579
1627
|
grid: GridData,
|
|
1580
1628
|
symbol: Symbol$1,
|
|
@@ -2648,10 +2696,10 @@ declare global {
|
|
|
2648
2696
|
}
|
|
2649
2697
|
export declare const allSymbols: Map<string, Symbol$1>;
|
|
2650
2698
|
export declare function aggregateState(
|
|
2651
|
-
rules: RuleState[],
|
|
2699
|
+
rules: readonly RuleState[],
|
|
2652
2700
|
grid: GridData,
|
|
2653
|
-
symbols:
|
|
2654
|
-
): State;
|
|
2701
|
+
symbols: ReadonlyMap<string, State[]>
|
|
2702
|
+
): State.Error | State.Satisfied | State.Incomplete;
|
|
2655
2703
|
export declare function applyFinalOverrides(
|
|
2656
2704
|
grid: GridData,
|
|
2657
2705
|
solution: GridData | null,
|
|
@@ -17,9 +17,25 @@ export declare enum MajorRule {
|
|
|
17
17
|
Underclued = "underclued"
|
|
18
18
|
}
|
|
19
19
|
export declare enum State {
|
|
20
|
+
/**
|
|
21
|
+
* Describes the violation of a rule.
|
|
22
|
+
*/
|
|
20
23
|
Error = "error",
|
|
24
|
+
/**
|
|
25
|
+
* Describes that a rule is satisfied and complete in the current grid.
|
|
26
|
+
*/
|
|
21
27
|
Satisfied = "satisfied",
|
|
22
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Describes that a rule is not violated, but is not yet complete in the current grid.
|
|
30
|
+
*/
|
|
31
|
+
Incomplete = "incomplete",
|
|
32
|
+
/**
|
|
33
|
+
* Describes that a rule is violated but ignored due to the effect of another rule.
|
|
34
|
+
*/
|
|
35
|
+
Ignored = "ignored"
|
|
36
|
+
}
|
|
37
|
+
export declare namespace State {
|
|
38
|
+
function isSatisfied(state: State): boolean;
|
|
23
39
|
}
|
|
24
40
|
export type RuleState = {
|
|
25
41
|
readonly state: State.Error;
|
|
@@ -28,6 +44,8 @@ export type RuleState = {
|
|
|
28
44
|
readonly state: State.Satisfied;
|
|
29
45
|
} | {
|
|
30
46
|
readonly state: State.Incomplete;
|
|
47
|
+
} | {
|
|
48
|
+
readonly state: State.Ignored;
|
|
31
49
|
};
|
|
32
50
|
export interface GridState {
|
|
33
51
|
final: State;
|
package/dist/data/primitives.js
CHANGED
|
@@ -9,9 +9,29 @@ export var MajorRule;
|
|
|
9
9
|
})(MajorRule || (MajorRule = {}));
|
|
10
10
|
export var State;
|
|
11
11
|
(function (State) {
|
|
12
|
+
/**
|
|
13
|
+
* Describes the violation of a rule.
|
|
14
|
+
*/
|
|
12
15
|
State["Error"] = "error";
|
|
16
|
+
/**
|
|
17
|
+
* Describes that a rule is satisfied and complete in the current grid.
|
|
18
|
+
*/
|
|
13
19
|
State["Satisfied"] = "satisfied";
|
|
20
|
+
/**
|
|
21
|
+
* Describes that a rule is not violated, but is not yet complete in the current grid.
|
|
22
|
+
*/
|
|
14
23
|
State["Incomplete"] = "incomplete";
|
|
24
|
+
/**
|
|
25
|
+
* Describes that a rule is violated but ignored due to the effect of another rule.
|
|
26
|
+
*/
|
|
27
|
+
State["Ignored"] = "ignored";
|
|
28
|
+
})(State || (State = {}));
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
30
|
+
(function (State) {
|
|
31
|
+
function isSatisfied(state) {
|
|
32
|
+
return state === State.Satisfied || state === State.Ignored;
|
|
33
|
+
}
|
|
34
|
+
State.isSatisfied = isSatisfied;
|
|
15
35
|
})(State || (State = {}));
|
|
16
36
|
export var Color;
|
|
17
37
|
(function (Color) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AnyConfig } from '../config.js';
|
|
2
|
+
import { FinalValidationHandler } from '../events/onFinalValidation.js';
|
|
3
|
+
import GridData from '../grid.js';
|
|
4
|
+
import { GridState, RuleState } from '../primitives.js';
|
|
5
|
+
import Rule, { SearchVariant } from './rule.js';
|
|
6
|
+
export default class LyingSymbolRule extends Rule implements FinalValidationHandler {
|
|
7
|
+
readonly count: number;
|
|
8
|
+
private static readonly EXAMPLE_GRID;
|
|
9
|
+
private static readonly CONFIGS;
|
|
10
|
+
private static readonly SEARCH_VARIANTS;
|
|
11
|
+
/**
|
|
12
|
+
* **<count> symbols are lying and can be ignored**
|
|
13
|
+
*
|
|
14
|
+
* @param count Number of lying symbols
|
|
15
|
+
*/
|
|
16
|
+
constructor(count: number);
|
|
17
|
+
get id(): string;
|
|
18
|
+
get explanation(): string;
|
|
19
|
+
get configs(): readonly AnyConfig[] | null;
|
|
20
|
+
createExampleGrid(): GridData;
|
|
21
|
+
get searchVariants(): SearchVariant[];
|
|
22
|
+
validateGrid(_: GridData): RuleState;
|
|
23
|
+
get isSingleton(): boolean;
|
|
24
|
+
onFinalValidation(grid: GridData, solution: GridData | null, state: GridState): GridState;
|
|
25
|
+
copyWith({ count }: {
|
|
26
|
+
count?: number;
|
|
27
|
+
}): this;
|
|
28
|
+
withCount(count: number): this;
|
|
29
|
+
}
|
|
30
|
+
export declare const instance: LyingSymbolRule;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { ConfigType } from '../config.js';
|
|
2
|
+
import GridData from '../grid.js';
|
|
3
|
+
import { Color, State } from '../primitives.js';
|
|
4
|
+
import Rule from './rule.js';
|
|
5
|
+
import CustomIconSymbol from '../symbols/customIconSymbol.js';
|
|
6
|
+
import validateGrid from '../validate.js';
|
|
7
|
+
import Symbol from '../symbols/symbol.js';
|
|
8
|
+
class IgnoredSymbol extends Symbol {
|
|
9
|
+
constructor(symbol) {
|
|
10
|
+
super(symbol.x, symbol.y);
|
|
11
|
+
Object.defineProperty(this, "symbol", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true,
|
|
15
|
+
value: symbol
|
|
16
|
+
});
|
|
17
|
+
this.symbol = symbol;
|
|
18
|
+
}
|
|
19
|
+
get id() {
|
|
20
|
+
return this.symbol.id;
|
|
21
|
+
}
|
|
22
|
+
get explanation() {
|
|
23
|
+
return this.symbol.explanation;
|
|
24
|
+
}
|
|
25
|
+
get configs() {
|
|
26
|
+
return this.symbol.configs;
|
|
27
|
+
}
|
|
28
|
+
createExampleGrid() {
|
|
29
|
+
return this.symbol.createExampleGrid();
|
|
30
|
+
}
|
|
31
|
+
get necessaryForCompletion() {
|
|
32
|
+
return this.symbol.necessaryForCompletion;
|
|
33
|
+
}
|
|
34
|
+
get visibleWhenSolving() {
|
|
35
|
+
return this.symbol.visibleWhenSolving;
|
|
36
|
+
}
|
|
37
|
+
get sortOrder() {
|
|
38
|
+
return this.symbol.sortOrder;
|
|
39
|
+
}
|
|
40
|
+
validateSymbol(_grid, _solution) {
|
|
41
|
+
return State.Ignored;
|
|
42
|
+
}
|
|
43
|
+
copyWith({ symbol }) {
|
|
44
|
+
return new IgnoredSymbol(symbol ?? this.symbol);
|
|
45
|
+
}
|
|
46
|
+
withSymbol(symbol) {
|
|
47
|
+
return this.copyWith({ symbol });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class IgnoredRule extends Rule {
|
|
51
|
+
constructor(rule, state) {
|
|
52
|
+
super();
|
|
53
|
+
Object.defineProperty(this, "rule", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: rule
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(this, "state", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: state
|
|
64
|
+
});
|
|
65
|
+
this.rule = rule;
|
|
66
|
+
this.state = state;
|
|
67
|
+
}
|
|
68
|
+
get searchVariants() {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
get id() {
|
|
72
|
+
return this.rule.id;
|
|
73
|
+
}
|
|
74
|
+
get explanation() {
|
|
75
|
+
return this.rule.explanation;
|
|
76
|
+
}
|
|
77
|
+
createExampleGrid() {
|
|
78
|
+
return this.rule.createExampleGrid();
|
|
79
|
+
}
|
|
80
|
+
get necessaryForCompletion() {
|
|
81
|
+
return this.rule.necessaryForCompletion;
|
|
82
|
+
}
|
|
83
|
+
get visibleWhenSolving() {
|
|
84
|
+
return this.rule.visibleWhenSolving;
|
|
85
|
+
}
|
|
86
|
+
get isSingleton() {
|
|
87
|
+
return this.rule.isSingleton;
|
|
88
|
+
}
|
|
89
|
+
validateGrid(_grid) {
|
|
90
|
+
if (this.state === State.Error)
|
|
91
|
+
return { state: State.Error, positions: [] };
|
|
92
|
+
else
|
|
93
|
+
return { state: this.state };
|
|
94
|
+
}
|
|
95
|
+
copyWith({ rule, state }) {
|
|
96
|
+
return new IgnoredRule(rule ?? this.rule, state ?? this.state);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
class LyingSymbolRule extends Rule {
|
|
100
|
+
/**
|
|
101
|
+
* **<count> symbols are lying and can be ignored**
|
|
102
|
+
*
|
|
103
|
+
* @param count Number of lying symbols
|
|
104
|
+
*/
|
|
105
|
+
constructor(count) {
|
|
106
|
+
super();
|
|
107
|
+
Object.defineProperty(this, "count", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
configurable: true,
|
|
110
|
+
writable: true,
|
|
111
|
+
value: count
|
|
112
|
+
});
|
|
113
|
+
this.count = count;
|
|
114
|
+
}
|
|
115
|
+
get id() {
|
|
116
|
+
return `lying_symbols`;
|
|
117
|
+
}
|
|
118
|
+
get explanation() {
|
|
119
|
+
return `${this.count} symbol${this.count <= 1 ? ' is' : 's are'} *lying* and can be ignored`;
|
|
120
|
+
}
|
|
121
|
+
get configs() {
|
|
122
|
+
return LyingSymbolRule.CONFIGS;
|
|
123
|
+
}
|
|
124
|
+
createExampleGrid() {
|
|
125
|
+
return LyingSymbolRule.EXAMPLE_GRID;
|
|
126
|
+
}
|
|
127
|
+
get searchVariants() {
|
|
128
|
+
return LyingSymbolRule.SEARCH_VARIANTS;
|
|
129
|
+
}
|
|
130
|
+
validateGrid(_) {
|
|
131
|
+
return { state: State.Incomplete };
|
|
132
|
+
}
|
|
133
|
+
get isSingleton() {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
onFinalValidation(grid, solution, state) {
|
|
137
|
+
const ignoredSymbols = [];
|
|
138
|
+
state.symbols.forEach((values, key) => {
|
|
139
|
+
values.forEach((state, idx) => {
|
|
140
|
+
if (state === State.Error)
|
|
141
|
+
ignoredSymbols.push([key, idx]);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
if (ignoredSymbols.length > this.count) {
|
|
145
|
+
const thisIdx = grid.rules.findIndex(rule => rule.id === this.id);
|
|
146
|
+
return {
|
|
147
|
+
final: State.Error,
|
|
148
|
+
rules: state.rules.map((rule, idx) => idx === thisIdx ? { state: State.Error, positions: [] } : rule),
|
|
149
|
+
symbols: state.symbols,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const newSymbols = new Map();
|
|
153
|
+
grid.symbols.forEach((values, key) => {
|
|
154
|
+
values.forEach((symbol, idx) => {
|
|
155
|
+
if (!newSymbols.has(key)) {
|
|
156
|
+
newSymbols.set(key, []);
|
|
157
|
+
}
|
|
158
|
+
if (ignoredSymbols.some(([k, i]) => k === key && i === idx)) {
|
|
159
|
+
newSymbols.get(key).push(new IgnoredSymbol(symbol));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
newSymbols.get(key).push(symbol);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
const newRules = grid.rules.map(rule => rule.id === this.id
|
|
167
|
+
? new IgnoredRule(this, ignoredSymbols.length === this.count
|
|
168
|
+
? State.Satisfied
|
|
169
|
+
: grid.getTileCount(true, false, Color.Gray) === 0
|
|
170
|
+
? State.Error
|
|
171
|
+
: State.Incomplete)
|
|
172
|
+
: rule);
|
|
173
|
+
return validateGrid(grid.copyWith({ rules: newRules, symbols: newSymbols }), solution);
|
|
174
|
+
}
|
|
175
|
+
copyWith({ count }) {
|
|
176
|
+
return new LyingSymbolRule(count ?? this.count);
|
|
177
|
+
}
|
|
178
|
+
withCount(count) {
|
|
179
|
+
return this.copyWith({ count });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
Object.defineProperty(LyingSymbolRule, "EXAMPLE_GRID", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
configurable: true,
|
|
185
|
+
writable: true,
|
|
186
|
+
value: Object.freeze(GridData.create(['.']).addSymbol(new CustomIconSymbol('', GridData.create([]), 0, 0, 'MdOutlineDeblur')))
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(LyingSymbolRule, "CONFIGS", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
configurable: true,
|
|
191
|
+
writable: true,
|
|
192
|
+
value: Object.freeze([
|
|
193
|
+
{
|
|
194
|
+
type: ConfigType.Number,
|
|
195
|
+
default: 1,
|
|
196
|
+
min: 1,
|
|
197
|
+
max: 100,
|
|
198
|
+
step: 1,
|
|
199
|
+
field: 'count',
|
|
200
|
+
description: 'Number of liars',
|
|
201
|
+
configurable: true,
|
|
202
|
+
},
|
|
203
|
+
])
|
|
204
|
+
});
|
|
205
|
+
Object.defineProperty(LyingSymbolRule, "SEARCH_VARIANTS", {
|
|
206
|
+
enumerable: true,
|
|
207
|
+
configurable: true,
|
|
208
|
+
writable: true,
|
|
209
|
+
value: [
|
|
210
|
+
new LyingSymbolRule(1).searchVariant(),
|
|
211
|
+
]
|
|
212
|
+
});
|
|
213
|
+
export default LyingSymbolRule;
|
|
214
|
+
export const instance = new LyingSymbolRule(1);
|
|
@@ -20,7 +20,7 @@ export default class OffByXRule extends Rule implements SymbolValidationHandler
|
|
|
20
20
|
get configs(): readonly AnyConfig[] | null;
|
|
21
21
|
createExampleGrid(): GridData;
|
|
22
22
|
get searchVariants(): SearchVariant[];
|
|
23
|
-
validateGrid(
|
|
23
|
+
validateGrid(grid: GridData): RuleState;
|
|
24
24
|
onSymbolValidation(grid: GridData, symbol: Symbol, _validator: (grid: GridData) => State): State | undefined;
|
|
25
25
|
get isSingleton(): boolean;
|
|
26
26
|
copyWith({ number }: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConfigType } from '../config.js';
|
|
2
2
|
import GridData from '../grid.js';
|
|
3
|
-
import { State } from '../primitives.js';
|
|
3
|
+
import { Color, State } from '../primitives.js';
|
|
4
4
|
import AreaNumberSymbol from '../symbols/areaNumberSymbol.js';
|
|
5
5
|
import NumberSymbol from '../symbols/numberSymbol.js';
|
|
6
6
|
import Rule from './rule.js';
|
|
@@ -38,8 +38,12 @@ class OffByXRule extends Rule {
|
|
|
38
38
|
get searchVariants() {
|
|
39
39
|
return OffByXRule.SEARCH_VARIANTS;
|
|
40
40
|
}
|
|
41
|
-
validateGrid(
|
|
42
|
-
return {
|
|
41
|
+
validateGrid(grid) {
|
|
42
|
+
return {
|
|
43
|
+
state: grid.getTileCount(true, false, Color.Gray) === 0
|
|
44
|
+
? State.Satisfied
|
|
45
|
+
: State.Incomplete,
|
|
46
|
+
};
|
|
43
47
|
}
|
|
44
48
|
onSymbolValidation(grid, symbol, _validator) {
|
|
45
49
|
if (symbol instanceof NumberSymbol) {
|
|
@@ -5,6 +5,7 @@ export { instance as CompletePatternRule } from './completePatternRule.js';
|
|
|
5
5
|
export { instance as ConnectAllRule } from './connectAllRule.js';
|
|
6
6
|
export { instance as CustomRule } from './customRule.js';
|
|
7
7
|
export { instance as ForesightRule } from './foresightRule.js';
|
|
8
|
+
export { instance as LyingSymbolRule } from './lyingSymbolRule.js';
|
|
8
9
|
export { instance as MusicGridRule } from './musicGridRule.js';
|
|
9
10
|
export { instance as MysteryRule } from './mysteryRule.js';
|
|
10
11
|
export { instance as OffByXRule } from './offByXRule.js';
|
|
@@ -9,6 +9,7 @@ export { instance as CompletePatternRule } from './completePatternRule.js';
|
|
|
9
9
|
export { instance as ConnectAllRule } from './connectAllRule.js';
|
|
10
10
|
export { instance as CustomRule } from './customRule.js';
|
|
11
11
|
export { instance as ForesightRule } from './foresightRule.js';
|
|
12
|
+
export { instance as LyingSymbolRule } from './lyingSymbolRule.js';
|
|
12
13
|
export { instance as MusicGridRule } from './musicGridRule.js';
|
|
13
14
|
export { instance as MysteryRule } from './mysteryRule.js';
|
|
14
15
|
export { instance as OffByXRule } from './offByXRule.js';
|
package/dist/data/validate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import GridData from './grid.js';
|
|
2
2
|
import { GridState, RuleState, State } from './primitives.js';
|
|
3
|
-
export declare function aggregateState(rules: RuleState[], grid: GridData, symbols:
|
|
3
|
+
export declare function aggregateState(rules: readonly RuleState[], grid: GridData, symbols: ReadonlyMap<string, State[]>): State.Error | State.Satisfied | State.Incomplete;
|
|
4
4
|
export declare function applyFinalOverrides(grid: GridData, solution: GridData | null, state: GridState): GridState;
|
|
5
5
|
export default function validateGrid(grid: GridData, solution: GridData | null): GridState;
|
package/dist/data/validate.js
CHANGED
|
@@ -72,18 +72,18 @@ export default function validateGrid(grid, solution) {
|
|
|
72
72
|
return;
|
|
73
73
|
if (states.some(s => s === State.Error))
|
|
74
74
|
ruleStates[i] = { state: State.Error, positions: [] };
|
|
75
|
-
else if (states.length > 0 && states.every(s =>
|
|
75
|
+
else if (states.length > 0 && states.every(s => State.isSatisfied(s)))
|
|
76
76
|
ruleStates[i] = { state: State.Satisfied };
|
|
77
77
|
});
|
|
78
78
|
let final = aggregateState(ruleStates, grid, symbolStates);
|
|
79
79
|
// in addition to satisfying all rules and symbols, a solution must also fill the grid completely
|
|
80
|
-
if (!requireSolution &&
|
|
80
|
+
if (!requireSolution && State.isSatisfied(final)) {
|
|
81
81
|
final = grid.forEach(tile => tile.exists && tile.color === Color.Gray ? true : undefined)
|
|
82
82
|
? State.Incomplete
|
|
83
83
|
: State.Satisfied;
|
|
84
84
|
}
|
|
85
85
|
// return early if there is no need to validate against a solution
|
|
86
|
-
if (
|
|
86
|
+
if (State.isSatisfied(final) ||
|
|
87
87
|
!requireSolution ||
|
|
88
88
|
!solution ||
|
|
89
89
|
solution.width !== grid.width ||
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import ConnectAllRule from './data/rules/connectAllRule.js';
|
|
|
22
22
|
import CustomRule from './data/rules/customRule.js';
|
|
23
23
|
import ForesightRule from './data/rules/foresightRule.js';
|
|
24
24
|
import { allRules } from './data/rules/index.js';
|
|
25
|
+
import LyingSymbolRule from './data/rules/lyingSymbolRule.js';
|
|
25
26
|
import { ControlLine, Row } from './data/rules/musicControlLine.js';
|
|
26
27
|
import MusicGridRule from './data/rules/musicGridRule.js';
|
|
27
28
|
import MysteryRule from './data/rules/mysteryRule.js';
|
|
@@ -98,4 +99,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
|
|
|
98
99
|
import TileData from './data/tile.js';
|
|
99
100
|
import TileConnections from './data/tileConnections.js';
|
|
100
101
|
import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
|
|
101
|
-
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, State, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, CustomRule, ForesightRule, allRules, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, getShapeVariants, normalizeShape, positionsToShape, shapeEquals, tilesToShape, allSolvers, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, Solver, UndercluedSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|
|
102
|
+
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, State, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, CustomRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, getShapeVariants, normalizeShape, positionsToShape, shapeEquals, tilesToShape, allSolvers, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, Solver, UndercluedSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import ConnectAllRule from './data/rules/connectAllRule.js';
|
|
|
25
25
|
import CustomRule from './data/rules/customRule.js';
|
|
26
26
|
import ForesightRule from './data/rules/foresightRule.js';
|
|
27
27
|
import { allRules } from './data/rules/index.js';
|
|
28
|
+
import LyingSymbolRule from './data/rules/lyingSymbolRule.js';
|
|
28
29
|
import { ControlLine, Row } from './data/rules/musicControlLine.js';
|
|
29
30
|
import MusicGridRule from './data/rules/musicGridRule.js';
|
|
30
31
|
import MysteryRule from './data/rules/mysteryRule.js';
|
|
@@ -101,4 +102,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
|
|
|
101
102
|
import TileData from './data/tile.js';
|
|
102
103
|
import TileConnections from './data/tileConnections.js';
|
|
103
104
|
import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
|
|
104
|
-
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, State, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, CustomRule, ForesightRule, allRules, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, getShapeVariants, normalizeShape, positionsToShape, shapeEquals, tilesToShape, allSolvers, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, Solver, UndercluedSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|
|
105
|
+
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, State, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, CustomRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, getShapeVariants, normalizeShape, positionsToShape, shapeEquals, tilesToShape, allSolvers, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, Solver, UndercluedSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|