@logic-pad/core 0.15.0 → 0.15.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.
- package/assets/logic-core.global.d.ts +2 -0
- 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/dist/data/symbols/focusSymbol.d.ts +1 -0
- package/dist/data/symbols/focusSymbol.js +15 -6
- package/dist/data/symbols/minesweeperSymbol.d.ts +1 -0
- package/dist/data/symbols/minesweeperSymbol.js +15 -6
- package/package.json +1 -1
|
@@ -2518,6 +2518,7 @@ declare global {
|
|
|
2518
2518
|
get explanation(): string;
|
|
2519
2519
|
get configs(): readonly AnyConfig[] | null;
|
|
2520
2520
|
createExampleGrid(): GridData;
|
|
2521
|
+
private countForColor;
|
|
2521
2522
|
countTiles(grid: GridData): {
|
|
2522
2523
|
completed: number;
|
|
2523
2524
|
possible: number;
|
|
@@ -2663,6 +2664,7 @@ declare global {
|
|
|
2663
2664
|
get explanation(): string;
|
|
2664
2665
|
get configs(): readonly AnyConfig[] | null;
|
|
2665
2666
|
createExampleGrid(): GridData;
|
|
2667
|
+
private countForColor;
|
|
2666
2668
|
countTiles(grid: GridData): {
|
|
2667
2669
|
completed: number;
|
|
2668
2670
|
possible: number;
|
|
@@ -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);
|
|
@@ -17,6 +17,7 @@ export default class FocusSymbol extends NumberSymbol {
|
|
|
17
17
|
get explanation(): string;
|
|
18
18
|
get configs(): readonly AnyConfig[] | null;
|
|
19
19
|
createExampleGrid(): GridData;
|
|
20
|
+
private countForColor;
|
|
20
21
|
countTiles(grid: GridData): {
|
|
21
22
|
completed: number;
|
|
22
23
|
possible: number;
|
|
@@ -39,12 +39,7 @@ class FocusSymbol extends NumberSymbol {
|
|
|
39
39
|
createExampleGrid() {
|
|
40
40
|
return FocusSymbol.EXAMPLE_GRID;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
|
|
44
|
-
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
45
|
-
const color = grid.getTile(this.x, this.y).color;
|
|
46
|
-
if (color === Color.Gray)
|
|
47
|
-
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
42
|
+
countForColor(grid, color) {
|
|
48
43
|
let gray = 0;
|
|
49
44
|
let same = 0;
|
|
50
45
|
const visited = [];
|
|
@@ -67,6 +62,20 @@ class FocusSymbol extends NumberSymbol {
|
|
|
67
62
|
}
|
|
68
63
|
return { completed: same, possible: same + gray };
|
|
69
64
|
}
|
|
65
|
+
countTiles(grid) {
|
|
66
|
+
if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
|
|
67
|
+
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
68
|
+
const color = grid.getTile(this.x, this.y).color;
|
|
69
|
+
if (color === Color.Gray) {
|
|
70
|
+
const dark = this.countForColor(grid, Color.Dark);
|
|
71
|
+
const light = this.countForColor(grid, Color.Light);
|
|
72
|
+
return {
|
|
73
|
+
completed: Math.min(dark.completed, light.completed),
|
|
74
|
+
possible: Math.max(dark.possible, light.possible),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return this.countForColor(grid, color);
|
|
78
|
+
}
|
|
70
79
|
copyWith({ x, y, number, }) {
|
|
71
80
|
return new FocusSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
|
|
72
81
|
}
|
|
@@ -18,6 +18,7 @@ export default class MinesweeperSymbol extends NumberSymbol {
|
|
|
18
18
|
get explanation(): string;
|
|
19
19
|
get configs(): readonly AnyConfig[] | null;
|
|
20
20
|
createExampleGrid(): GridData;
|
|
21
|
+
private countForColor;
|
|
21
22
|
countTiles(grid: GridData): {
|
|
22
23
|
completed: number;
|
|
23
24
|
possible: number;
|
|
@@ -34,12 +34,7 @@ class MinesweeperSymbol extends NumberSymbol {
|
|
|
34
34
|
createExampleGrid() {
|
|
35
35
|
return MinesweeperSymbol.EXAMPLE_GRID;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
|
|
39
|
-
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
40
|
-
const color = grid.getTile(this.x, this.y).color;
|
|
41
|
-
if (color === Color.Gray)
|
|
42
|
-
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
37
|
+
countForColor(grid, color) {
|
|
43
38
|
let gray = 0;
|
|
44
39
|
let opposite = 0;
|
|
45
40
|
const visited = [];
|
|
@@ -64,6 +59,20 @@ class MinesweeperSymbol extends NumberSymbol {
|
|
|
64
59
|
}
|
|
65
60
|
return { completed: opposite, possible: opposite + gray };
|
|
66
61
|
}
|
|
62
|
+
countTiles(grid) {
|
|
63
|
+
if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
|
|
64
|
+
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
65
|
+
const color = grid.getTile(this.x, this.y).color;
|
|
66
|
+
if (color === Color.Gray) {
|
|
67
|
+
const dark = this.countForColor(grid, Color.Dark);
|
|
68
|
+
const light = this.countForColor(grid, Color.Light);
|
|
69
|
+
return {
|
|
70
|
+
completed: Math.min(dark.completed, light.completed),
|
|
71
|
+
possible: Math.max(dark.possible, light.possible),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return this.countForColor(grid, color);
|
|
75
|
+
}
|
|
67
76
|
copyWith({ x, y, number, }) {
|
|
68
77
|
return new MinesweeperSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
|
|
69
78
|
}
|