@logic-pad/core 0.14.0 → 0.15.1
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 +6 -0
- package/dist/data/config.d.ts +6 -1
- package/dist/data/config.js +7 -0
- package/dist/data/rules/banPatternRule.js +1 -1
- package/dist/data/rules/containsShapeRule.js +1 -1
- package/dist/data/serializer/serializer_checksum.js +11 -1
- package/dist/data/serializer/serializer_v0.js +2 -0
- package/dist/data/shapes.js +5 -1
- package/dist/data/solver/backtrack/backtrackSolver.js +1 -0
- package/dist/data/solver/cspuz/cspuzSolver.js +1 -0
- package/dist/data/solver/cspuz/cspuzWorker.js +1 -1
- package/dist/data/solver/universal/universalSolver.js +1 -0
- package/package.json +1 -1
|
@@ -1231,6 +1231,7 @@ declare global {
|
|
|
1231
1231
|
Orientation = 'orientation',
|
|
1232
1232
|
OrientationToggle = 'orientationToggle',
|
|
1233
1233
|
Tile = 'tile',
|
|
1234
|
+
Shape = 'shape',
|
|
1234
1235
|
Grid = 'grid',
|
|
1235
1236
|
NullableGrid = 'nullableGrid',
|
|
1236
1237
|
Icon = 'icon',
|
|
@@ -1295,6 +1296,10 @@ declare global {
|
|
|
1295
1296
|
readonly type: ConfigType.Tile;
|
|
1296
1297
|
readonly resizable: boolean;
|
|
1297
1298
|
}
|
|
1299
|
+
export interface ShapeConfig extends Config<GridData> {
|
|
1300
|
+
readonly type: ConfigType.Shape;
|
|
1301
|
+
readonly resizable: boolean;
|
|
1302
|
+
}
|
|
1298
1303
|
export interface GridConfig extends Config<GridData> {
|
|
1299
1304
|
readonly type: ConfigType.Grid;
|
|
1300
1305
|
}
|
|
@@ -1328,6 +1333,7 @@ declare global {
|
|
|
1328
1333
|
| OrientationConfig
|
|
1329
1334
|
| OrientationToggleConfig
|
|
1330
1335
|
| TileConfig
|
|
1336
|
+
| ShapeConfig
|
|
1331
1337
|
| GridConfig
|
|
1332
1338
|
| NullableGridConfig
|
|
1333
1339
|
| IconConfig
|
package/dist/data/config.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare enum ConfigType {
|
|
|
15
15
|
Orientation = "orientation",
|
|
16
16
|
OrientationToggle = "orientationToggle",
|
|
17
17
|
Tile = "tile",
|
|
18
|
+
Shape = "shape",
|
|
18
19
|
Grid = "grid",
|
|
19
20
|
NullableGrid = "nullableGrid",
|
|
20
21
|
Icon = "icon",
|
|
@@ -79,6 +80,10 @@ export interface TileConfig extends Config<GridData> {
|
|
|
79
80
|
readonly type: ConfigType.Tile;
|
|
80
81
|
readonly resizable: boolean;
|
|
81
82
|
}
|
|
83
|
+
export interface ShapeConfig extends Config<GridData> {
|
|
84
|
+
readonly type: ConfigType.Shape;
|
|
85
|
+
readonly resizable: boolean;
|
|
86
|
+
}
|
|
82
87
|
export interface GridConfig extends Config<GridData> {
|
|
83
88
|
readonly type: ConfigType.Grid;
|
|
84
89
|
}
|
|
@@ -98,7 +103,7 @@ export interface NullableNoteConfig extends Config<string | null> {
|
|
|
98
103
|
export interface SolvePathConfig extends Config<Position[]> {
|
|
99
104
|
readonly type: ConfigType.SolvePath;
|
|
100
105
|
}
|
|
101
|
-
export type AnyConfig = BooleanConfig | NullableBooleanConfig | NumberConfig | NullableNumberConfig | StringConfig | ColorConfig | ComparisonConfig | WrappingConfig | DirectionConfig | DirectionToggleConfig | OrientationConfig | OrientationToggleConfig | TileConfig | GridConfig | NullableGridConfig | IconConfig | ControlLinesConfig | NullableNoteConfig | SolvePathConfig;
|
|
106
|
+
export type AnyConfig = BooleanConfig | NullableBooleanConfig | NumberConfig | NullableNumberConfig | StringConfig | ColorConfig | ComparisonConfig | WrappingConfig | DirectionConfig | DirectionToggleConfig | OrientationConfig | OrientationToggleConfig | TileConfig | ShapeConfig | GridConfig | NullableGridConfig | IconConfig | ControlLinesConfig | NullableNoteConfig | SolvePathConfig;
|
|
102
107
|
/**
|
|
103
108
|
* Compare two config values for equality, using an appropriate method for the config type.
|
|
104
109
|
*
|
package/dist/data/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DIRECTIONS, ORIENTATIONS, } from './primitives.js';
|
|
2
|
+
import { normalizeShape, shapeEquals, tilesToShape } from './shapes.js';
|
|
2
3
|
export var ConfigType;
|
|
3
4
|
(function (ConfigType) {
|
|
4
5
|
ConfigType["Boolean"] = "boolean";
|
|
@@ -14,6 +15,7 @@ export var ConfigType;
|
|
|
14
15
|
ConfigType["Orientation"] = "orientation";
|
|
15
16
|
ConfigType["OrientationToggle"] = "orientationToggle";
|
|
16
17
|
ConfigType["Tile"] = "tile";
|
|
18
|
+
ConfigType["Shape"] = "shape";
|
|
17
19
|
ConfigType["Grid"] = "grid";
|
|
18
20
|
ConfigType["NullableGrid"] = "nullableGrid";
|
|
19
21
|
ConfigType["Icon"] = "icon";
|
|
@@ -40,6 +42,11 @@ export function configEquals(type, a, b) {
|
|
|
40
42
|
if (type === ConfigType.Tile || type === ConfigType.Grid) {
|
|
41
43
|
return a.equals(b);
|
|
42
44
|
}
|
|
45
|
+
if (type === ConfigType.Shape) {
|
|
46
|
+
const aShape = normalizeShape(tilesToShape(a.tiles));
|
|
47
|
+
const bShape = normalizeShape(tilesToShape(b.tiles));
|
|
48
|
+
return shapeEquals(aShape, bShape);
|
|
49
|
+
}
|
|
43
50
|
if (type === ConfigType.NullableGrid) {
|
|
44
51
|
if (a === null && b === null)
|
|
45
52
|
return true;
|
|
@@ -2,6 +2,7 @@ import { ConfigType, } from '../config.js';
|
|
|
2
2
|
import SerializerV0, { orientationChars } from './serializer_v0.js';
|
|
3
3
|
import { DIRECTIONS, ORIENTATIONS, } from '../primitives.js';
|
|
4
4
|
import { escape } from '../dataHelper.js';
|
|
5
|
+
import { normalizeShape, tilesToShape } from '../shapes.js';
|
|
5
6
|
export default class SerializerChecksum extends SerializerV0 {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
@@ -9,7 +10,7 @@ export default class SerializerChecksum extends SerializerV0 {
|
|
|
9
10
|
enumerable: true,
|
|
10
11
|
configurable: true,
|
|
11
12
|
writable: true,
|
|
12
|
-
value:
|
|
13
|
+
value: 3
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
parseTile(_str) {
|
|
@@ -91,6 +92,13 @@ export default class SerializerChecksum extends SerializerV0 {
|
|
|
91
92
|
return (config.field +
|
|
92
93
|
'=' +
|
|
93
94
|
escape(this.stringifyGrid(instruction[config.field])));
|
|
95
|
+
case ConfigType.Shape:
|
|
96
|
+
return (config.field +
|
|
97
|
+
'=' +
|
|
98
|
+
escape(normalizeShape(tilesToShape(instruction[config.field].tiles))
|
|
99
|
+
.elements.map(elm => `${elm.x}-${elm.y}-${elm.color}`)
|
|
100
|
+
.sort()
|
|
101
|
+
.join('/')));
|
|
94
102
|
case ConfigType.NullableGrid:
|
|
95
103
|
return (config.field +
|
|
96
104
|
'=' +
|
|
@@ -137,6 +145,7 @@ export default class SerializerChecksum extends SerializerV0 {
|
|
|
137
145
|
}
|
|
138
146
|
stringifyRules(rules) {
|
|
139
147
|
return `R${rules
|
|
148
|
+
.filter(rule => rule.necessaryForCompletion)
|
|
140
149
|
.map(rule => this.stringifyRule(rule))
|
|
141
150
|
.sort()
|
|
142
151
|
.join(':')}`;
|
|
@@ -147,6 +156,7 @@ export default class SerializerChecksum extends SerializerV0 {
|
|
|
147
156
|
stringifySymbols(symbols) {
|
|
148
157
|
return `S${Array.from(symbols.values())
|
|
149
158
|
.flat()
|
|
159
|
+
.filter(symbol => symbol.necessaryForCompletion)
|
|
150
160
|
.map(symbol => this.stringifySymbol(symbol))
|
|
151
161
|
.sort()
|
|
152
162
|
.join(':')}`;
|
|
@@ -147,6 +147,7 @@ export default class SerializerV0 extends SerializerBase {
|
|
|
147
147
|
? ''
|
|
148
148
|
: escape(String(instruction[config.field]))));
|
|
149
149
|
case ConfigType.Tile:
|
|
150
|
+
case ConfigType.Shape:
|
|
150
151
|
case ConfigType.Grid:
|
|
151
152
|
return (config.field +
|
|
152
153
|
'=' +
|
|
@@ -215,6 +216,7 @@ export default class SerializerV0 extends SerializerBase {
|
|
|
215
216
|
case ConfigType.Icon:
|
|
216
217
|
return [config.field, unescape(value)];
|
|
217
218
|
case ConfigType.Tile:
|
|
219
|
+
case ConfigType.Shape:
|
|
218
220
|
case ConfigType.Grid:
|
|
219
221
|
return [config.field, this.parseGrid(unescape(value))];
|
|
220
222
|
case ConfigType.NullableGrid:
|
package/dist/data/shapes.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import GridConnections from './gridConnections.js';
|
|
2
|
+
import GridZones from './gridZones.js';
|
|
1
3
|
import { Color } from './primitives.js';
|
|
2
4
|
const colorIndex = {
|
|
3
5
|
[Color.Dark]: 2,
|
|
@@ -129,5 +131,7 @@ export function sanitizePatternGrid(pattern, tileMapper = t => t) {
|
|
|
129
131
|
: t.copyWith({ exists: true, color: Color.Gray, fixed: false })))))
|
|
130
132
|
// strip all symbols and rules
|
|
131
133
|
.withRules([])
|
|
132
|
-
.withSymbols(new Map())
|
|
134
|
+
.withSymbols(new Map())
|
|
135
|
+
.withConnections(new GridConnections())
|
|
136
|
+
.withZones(new GridZones()));
|
|
133
137
|
}
|
|
@@ -16,6 +16,7 @@ import { instance as myopiaInstance } from '../../symbols/myopiaSymbol.js';
|
|
|
16
16
|
import { instance as viewpointInstance } from '../../symbols/viewpointSymbol.js';
|
|
17
17
|
import { instance as connectAllInstance } from '../../rules/connectAllRule.js';
|
|
18
18
|
import EventIteratingSolver from '../eventIteratingSolver.js';
|
|
19
|
+
('vite-apply-code-mod');
|
|
19
20
|
class BacktrackSolver extends EventIteratingSolver {
|
|
20
21
|
constructor() {
|
|
21
22
|
super(...arguments);
|
|
@@ -17,6 +17,7 @@ import { instance as connectAllInstance } from '../../rules/connectAllRule.js';
|
|
|
17
17
|
import EventIteratingSolver from '../eventIteratingSolver.js';
|
|
18
18
|
import GridData from '../../grid.js';
|
|
19
19
|
import { Color } from '../../primitives.js';
|
|
20
|
+
('vite-apply-code-mod');
|
|
20
21
|
class CspuzSolver extends EventIteratingSolver {
|
|
21
22
|
constructor() {
|
|
22
23
|
super(...arguments);
|
|
@@ -68,7 +68,7 @@ onmessage = e => {
|
|
|
68
68
|
puzzleData.tiles[y][x].fixed = true;
|
|
69
69
|
puzzleData.tiles[y][x].color = color;
|
|
70
70
|
}
|
|
71
|
-
else if (!tweaked) {
|
|
71
|
+
else if (!tweaked && puzzleData.tiles[y][x].exists) {
|
|
72
72
|
const positions = grid.connections.getConnectedTiles({ x, y });
|
|
73
73
|
const newColor = solverResult[y][x] === 'dark' ? 'light' : 'dark';
|
|
74
74
|
positions.forEach(({ x: px, y: py }) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { instance as undercluedInstance } from '../../rules/undercluedRule.js';
|
|
2
2
|
import EventIteratingSolver from '../eventIteratingSolver.js';
|
|
3
|
+
('vite-apply-code-mod');
|
|
3
4
|
export default class UniversalSolver extends EventIteratingSolver {
|
|
4
5
|
constructor() {
|
|
5
6
|
super(...arguments);
|