@logic-pad/core 0.4.4 → 0.4.6
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 +17 -3439
- package/dist/data/events/onSymbolDisplay.d.ts +2 -1
- package/dist/data/rules/banPatternRule.js +3 -1
- package/dist/data/rules/musicControlLine.js +1 -1
- package/dist/data/rules/musicGridRule.d.ts +5 -2
- package/dist/data/rules/musicGridRule.js +26 -11
- package/dist/data/serializer/serializer_v0.js +4 -2
- package/dist/data/solver/backtrack/symbols/directionLinker.js +7 -6
- package/dist/data/solver/z3/z3SolverContext.d.ts +2 -797
- package/dist/data/symbols/hiddenSymbol.d.ts +5 -9
- package/dist/data/symbols/hiddenSymbol.js +19 -29
- package/dist/data/symbols/symbol.d.ts +1 -1
- package/dist/data/validate.js +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { AnyConfig } from '../config.js';
|
|
2
2
|
import { SymbolDisplayHandler } from '../events/onSymbolDisplay.js';
|
|
3
3
|
import GridData from '../grid.js';
|
|
4
|
-
import {
|
|
4
|
+
import { State } from '../primitives.js';
|
|
5
5
|
import Symbol from './symbol.js';
|
|
6
6
|
export default class HiddenSymbol extends Symbol implements SymbolDisplayHandler {
|
|
7
7
|
readonly x: number;
|
|
8
8
|
readonly y: number;
|
|
9
|
-
readonly color: Color;
|
|
10
9
|
readonly revealLocation: boolean;
|
|
11
10
|
private static readonly CONFIGS;
|
|
12
11
|
private static readonly EXAMPLE_GRID;
|
|
@@ -15,10 +14,9 @@ export default class HiddenSymbol extends Symbol implements SymbolDisplayHandler
|
|
|
15
14
|
*
|
|
16
15
|
* @param x - The x-coordinate of the symbol.
|
|
17
16
|
* @param y - The y-coordinate of the symbol.
|
|
18
|
-
* @param color - The target color of the cell.
|
|
19
17
|
* @param revealLocation - Whether to reveal the location of the symbol.
|
|
20
18
|
*/
|
|
21
|
-
constructor(x: number, y: number,
|
|
19
|
+
constructor(x: number, y: number, revealLocation?: boolean);
|
|
22
20
|
get id(): string;
|
|
23
21
|
get explanation(): string;
|
|
24
22
|
get configs(): readonly AnyConfig[] | null;
|
|
@@ -26,15 +24,13 @@ export default class HiddenSymbol extends Symbol implements SymbolDisplayHandler
|
|
|
26
24
|
get necessaryForCompletion(): boolean;
|
|
27
25
|
get visibleWhenSolving(): boolean;
|
|
28
26
|
get sortOrder(): number;
|
|
29
|
-
validateSymbol(grid: GridData): State;
|
|
30
|
-
onSymbolDisplay(grid: GridData, symbol: Symbol, editing: boolean): boolean;
|
|
31
|
-
copyWith({ x, y,
|
|
27
|
+
validateSymbol(grid: GridData, solution: GridData | null): State;
|
|
28
|
+
onSymbolDisplay(grid: GridData, solution: GridData | null, symbol: Symbol, editing: boolean): boolean;
|
|
29
|
+
copyWith({ x, y, revealLocation, }: {
|
|
32
30
|
x?: number;
|
|
33
31
|
y?: number;
|
|
34
|
-
color?: Color;
|
|
35
32
|
revealLocation?: boolean;
|
|
36
33
|
}): this;
|
|
37
|
-
withColor(color: Color): this;
|
|
38
34
|
withRevealLocation(revealLocation: boolean): this;
|
|
39
35
|
}
|
|
40
36
|
export declare const instance: HiddenSymbol;
|
|
@@ -9,10 +9,9 @@ class HiddenSymbol extends Symbol {
|
|
|
9
9
|
*
|
|
10
10
|
* @param x - The x-coordinate of the symbol.
|
|
11
11
|
* @param y - The y-coordinate of the symbol.
|
|
12
|
-
* @param color - The target color of the cell.
|
|
13
12
|
* @param revealLocation - Whether to reveal the location of the symbol.
|
|
14
13
|
*/
|
|
15
|
-
constructor(x, y,
|
|
14
|
+
constructor(x, y, revealLocation = false) {
|
|
16
15
|
super(x, y);
|
|
17
16
|
Object.defineProperty(this, "x", {
|
|
18
17
|
enumerable: true,
|
|
@@ -26,19 +25,12 @@ class HiddenSymbol extends Symbol {
|
|
|
26
25
|
writable: true,
|
|
27
26
|
value: y
|
|
28
27
|
});
|
|
29
|
-
Object.defineProperty(this, "color", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: color
|
|
34
|
-
});
|
|
35
28
|
Object.defineProperty(this, "revealLocation", {
|
|
36
29
|
enumerable: true,
|
|
37
30
|
configurable: true,
|
|
38
31
|
writable: true,
|
|
39
32
|
value: revealLocation
|
|
40
33
|
});
|
|
41
|
-
this.color = color;
|
|
42
34
|
this.revealLocation = revealLocation;
|
|
43
35
|
}
|
|
44
36
|
get id() {
|
|
@@ -62,14 +54,20 @@ class HiddenSymbol extends Symbol {
|
|
|
62
54
|
get sortOrder() {
|
|
63
55
|
return 0;
|
|
64
56
|
}
|
|
65
|
-
validateSymbol(grid) {
|
|
57
|
+
validateSymbol(grid, solution) {
|
|
66
58
|
const thisX = Math.floor(this.x);
|
|
67
59
|
const thisY = Math.floor(this.y);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
const thisColor = grid.getTile(thisX, thisY).color;
|
|
61
|
+
if (solution) {
|
|
62
|
+
return thisColor === solution.getTile(thisX, thisY).color
|
|
63
|
+
? State.Satisfied
|
|
64
|
+
: State.Incomplete;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return thisColor !== Color.Gray ? State.Satisfied : State.Incomplete;
|
|
68
|
+
}
|
|
71
69
|
}
|
|
72
|
-
onSymbolDisplay(grid, symbol, editing) {
|
|
70
|
+
onSymbolDisplay(grid, solution, symbol, editing) {
|
|
73
71
|
if (editing)
|
|
74
72
|
return true;
|
|
75
73
|
const thisX = Math.floor(this.x);
|
|
@@ -78,17 +76,17 @@ class HiddenSymbol extends Symbol {
|
|
|
78
76
|
const symY = Math.floor(symbol.y);
|
|
79
77
|
if (thisX !== symX || thisY !== symY)
|
|
80
78
|
return true;
|
|
81
|
-
const
|
|
79
|
+
const thisColor = grid.getTile(thisX, thisY).color;
|
|
80
|
+
const colorMatch = solution
|
|
81
|
+
? thisColor === solution.getTile(thisX, thisY).color
|
|
82
|
+
: thisColor !== Color.Gray;
|
|
82
83
|
if (symbol.id === this.id) {
|
|
83
84
|
return !colorMatch;
|
|
84
85
|
}
|
|
85
86
|
return colorMatch;
|
|
86
87
|
}
|
|
87
|
-
copyWith({ x, y,
|
|
88
|
-
return new HiddenSymbol(x ?? this.x, y ?? this.y,
|
|
89
|
-
}
|
|
90
|
-
withColor(color) {
|
|
91
|
-
return this.copyWith({ color });
|
|
88
|
+
copyWith({ x, y, revealLocation, }) {
|
|
89
|
+
return new HiddenSymbol(x ?? this.x, y ?? this.y, revealLocation ?? this.revealLocation);
|
|
92
90
|
}
|
|
93
91
|
withRevealLocation(revealLocation) {
|
|
94
92
|
return this.copyWith({ revealLocation });
|
|
@@ -113,14 +111,6 @@ Object.defineProperty(HiddenSymbol, "CONFIGS", {
|
|
|
113
111
|
description: 'Y',
|
|
114
112
|
configurable: false,
|
|
115
113
|
},
|
|
116
|
-
{
|
|
117
|
-
type: ConfigType.Color,
|
|
118
|
-
default: Color.Light,
|
|
119
|
-
field: 'color',
|
|
120
|
-
allowGray: true,
|
|
121
|
-
description: 'Show on color',
|
|
122
|
-
configurable: true,
|
|
123
|
-
},
|
|
124
114
|
{
|
|
125
115
|
type: ConfigType.Boolean,
|
|
126
116
|
default: false,
|
|
@@ -138,4 +128,4 @@ Object.defineProperty(HiddenSymbol, "EXAMPLE_GRID", {
|
|
|
138
128
|
))
|
|
139
129
|
});
|
|
140
130
|
export default HiddenSymbol;
|
|
141
|
-
export const instance = new HiddenSymbol(0, 0
|
|
131
|
+
export const instance = new HiddenSymbol(0, 0);
|
|
@@ -6,7 +6,7 @@ export default abstract class Symbol extends Instruction implements GridResizeHa
|
|
|
6
6
|
readonly x: number;
|
|
7
7
|
readonly y: number;
|
|
8
8
|
constructor(x: number, y: number);
|
|
9
|
-
abstract validateSymbol(grid: GridData): State;
|
|
9
|
+
abstract validateSymbol(grid: GridData, solution: GridData | null): State;
|
|
10
10
|
modeVariant(_mode: Mode): Symbol | null;
|
|
11
11
|
onGridResize(_grid: GridData, mode: 'insert' | 'remove', direction: 'row' | 'column', index: number): this | null;
|
|
12
12
|
/**
|
package/dist/data/validate.js
CHANGED
|
@@ -64,7 +64,7 @@ export default function validateGrid(grid, solution) {
|
|
|
64
64
|
grid.symbols.forEach((symbolList, id) => symbolStates.set(id, symbolList.map(s => {
|
|
65
65
|
if (s.validateWithSolution)
|
|
66
66
|
requireSolution = true;
|
|
67
|
-
return applySymbolOverrides(grid, grid.rules, s, g => s.validateSymbol(g));
|
|
67
|
+
return applySymbolOverrides(grid, grid.rules, s, g => s.validateSymbol(g, solution));
|
|
68
68
|
})));
|
|
69
69
|
// apply the result of symbol overrides to the rules that provided them
|
|
70
70
|
symbolOverrideStates.forEach((states, i) => {
|