@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.
- package/README.md +31 -31
- package/assets/logic-core.global.d.ts +3264 -3262
- package/package.json +4 -1
- package/dist/benchmark/helper.d.ts +0 -21
- package/dist/benchmark/helper.js +0 -34
- package/dist/benchmark/prepareBench.d.ts +0 -1
- package/dist/benchmark/prepareBench.js +0 -140
- package/dist/benchmark/runBench.d.ts +0 -1
- package/dist/benchmark/runBench.js +0 -206
- package/dist/src/data/config.d.ts +0 -119
- package/dist/src/data/config.js +0 -72
- package/dist/src/data/configurable.d.ts +0 -14
- package/dist/src/data/configurable.js +0 -26
- package/dist/src/data/dataHelper.d.ts +0 -92
- package/dist/src/data/dataHelper.js +0 -217
- package/dist/src/data/events/eventHelper.d.ts +0 -1
- package/dist/src/data/events/eventHelper.js +0 -6
- package/dist/src/data/events/onFinalValidation.d.ts +0 -14
- package/dist/src/data/events/onFinalValidation.js +0 -4
- package/dist/src/data/events/onGetTile.d.ts +0 -7
- package/dist/src/data/events/onGetTile.js +0 -4
- package/dist/src/data/events/onGridChange.d.ts +0 -6
- package/dist/src/data/events/onGridChange.js +0 -4
- package/dist/src/data/events/onGridResize.d.ts +0 -9
- package/dist/src/data/events/onGridResize.js +0 -4
- package/dist/src/data/events/onSetGrid.d.ts +0 -7
- package/dist/src/data/events/onSetGrid.js +0 -19
- package/dist/src/data/events/onSymbolDisplay.d.ts +0 -16
- package/dist/src/data/events/onSymbolDisplay.js +0 -4
- package/dist/src/data/events/onSymbolMerge.d.ts +0 -10
- package/dist/src/data/events/onSymbolMerge.js +0 -4
- package/dist/src/data/events/onSymbolValidation.d.ts +0 -18
- package/dist/src/data/events/onSymbolValidation.js +0 -4
- package/dist/src/data/grid.d.ts +0 -410
- package/dist/src/data/grid.js +0 -1106
- package/dist/src/data/gridConnections.d.ts +0 -25
- package/dist/src/data/gridConnections.js +0 -309
- package/dist/src/data/gridZones.d.ts +0 -26
- package/dist/src/data/gridZones.js +0 -117
- package/dist/src/data/instruction.d.ts +0 -26
- package/dist/src/data/instruction.js +0 -29
- package/dist/src/data/primitives.d.ts +0 -138
- package/dist/src/data/primitives.js +0 -177
- package/dist/src/data/puzzle.d.ts +0 -73
- package/dist/src/data/puzzle.js +0 -105
- package/dist/src/data/rules/banPatternRule.d.ts +0 -30
- package/dist/src/data/rules/banPatternRule.js +0 -125
- package/dist/src/data/rules/cellCountPerZoneRule.d.ts +0 -23
- package/dist/src/data/rules/cellCountPerZoneRule.js +0 -39
- package/dist/src/data/rules/cellCountRule.d.ts +0 -33
- package/dist/src/data/rules/cellCountRule.js +0 -138
- package/dist/src/data/rules/completePatternRule.d.ts +0 -24
- package/dist/src/data/rules/completePatternRule.js +0 -46
- package/dist/src/data/rules/connectAllRule.d.ts +0 -29
- package/dist/src/data/rules/connectAllRule.js +0 -88
- package/dist/src/data/rules/connectZonesRule.d.ts +0 -29
- package/dist/src/data/rules/connectZonesRule.js +0 -111
- package/dist/src/data/rules/containsShapeRule.d.ts +0 -34
- package/dist/src/data/rules/containsShapeRule.js +0 -125
- package/dist/src/data/rules/customRule.d.ts +0 -34
- package/dist/src/data/rules/customRule.js +0 -74
- package/dist/src/data/rules/differentCountPerZoneRule.d.ts +0 -30
- package/dist/src/data/rules/differentCountPerZoneRule.js +0 -96
- package/dist/src/data/rules/exactCountPerZoneRule.d.ts +0 -33
- package/dist/src/data/rules/exactCountPerZoneRule.js +0 -99
- package/dist/src/data/rules/foresightRule.d.ts +0 -36
- package/dist/src/data/rules/foresightRule.js +0 -107
- package/dist/src/data/rules/index.d.ts +0 -3
- package/dist/src/data/rules/index.js +0 -10
- package/dist/src/data/rules/lyingSymbolRule.d.ts +0 -31
- package/dist/src/data/rules/lyingSymbolRule.js +0 -207
- package/dist/src/data/rules/musicControlLine.d.ts +0 -82
- package/dist/src/data/rules/musicControlLine.js +0 -167
- package/dist/src/data/rules/musicGridRule.d.ts +0 -51
- package/dist/src/data/rules/musicGridRule.js +0 -212
- package/dist/src/data/rules/mysteryRule.d.ts +0 -39
- package/dist/src/data/rules/mysteryRule.js +0 -146
- package/dist/src/data/rules/noLoopsRule.d.ts +0 -29
- package/dist/src/data/rules/noLoopsRule.js +0 -218
- package/dist/src/data/rules/offByXRule.d.ts +0 -32
- package/dist/src/data/rules/offByXRule.js +0 -124
- package/dist/src/data/rules/perfectionRule.d.ts +0 -45
- package/dist/src/data/rules/perfectionRule.js +0 -158
- package/dist/src/data/rules/regionAreaRule.d.ts +0 -34
- package/dist/src/data/rules/regionAreaRule.js +0 -149
- package/dist/src/data/rules/regionShapeRule.d.ts +0 -22
- package/dist/src/data/rules/regionShapeRule.js +0 -58
- package/dist/src/data/rules/rule.d.ts +0 -18
- package/dist/src/data/rules/rule.js +0 -19
- package/dist/src/data/rules/rules.gen.d.ts +0 -23
- package/dist/src/data/rules/rules.gen.js +0 -27
- package/dist/src/data/rules/sameCountPerZoneRule.d.ts +0 -30
- package/dist/src/data/rules/sameCountPerZoneRule.js +0 -95
- package/dist/src/data/rules/sameShapeRule.d.ts +0 -28
- package/dist/src/data/rules/sameShapeRule.js +0 -68
- package/dist/src/data/rules/symbolsPerRegionRule.d.ts +0 -38
- package/dist/src/data/rules/symbolsPerRegionRule.js +0 -181
- package/dist/src/data/rules/undercluedRule.d.ts +0 -24
- package/dist/src/data/rules/undercluedRule.js +0 -53
- package/dist/src/data/rules/uniqueShapeRule.d.ts +0 -28
- package/dist/src/data/rules/uniqueShapeRule.js +0 -65
- package/dist/src/data/rules/wrapAroundRule.d.ts +0 -36
- package/dist/src/data/rules/wrapAroundRule.js +0 -241
- package/dist/src/data/serializer/allSerializers.d.ts +0 -32
- package/dist/src/data/serializer/allSerializers.js +0 -71
- package/dist/src/data/serializer/compressor/allCompressors.d.ts +0 -14
- package/dist/src/data/serializer/compressor/allCompressors.js +0 -43
- package/dist/src/data/serializer/compressor/checksumCompressor.d.ts +0 -6
- package/dist/src/data/serializer/compressor/checksumCompressor.js +0 -21
- package/dist/src/data/serializer/compressor/compressorBase.d.ts +0 -16
- package/dist/src/data/serializer/compressor/compressorBase.js +0 -2
- package/dist/src/data/serializer/compressor/deflateCompressor.d.ts +0 -7
- package/dist/src/data/serializer/compressor/deflateCompressor.js +0 -17
- package/dist/src/data/serializer/compressor/gzipCompressor.d.ts +0 -5
- package/dist/src/data/serializer/compressor/gzipCompressor.js +0 -9
- package/dist/src/data/serializer/compressor/streamCompressor.d.ts +0 -6
- package/dist/src/data/serializer/compressor/streamCompressor.js +0 -41
- package/dist/src/data/serializer/serializerBase.d.ts +0 -32
- package/dist/src/data/serializer/serializerBase.js +0 -2
- package/dist/src/data/serializer/serializer_checksum.d.ts +0 -35
- package/dist/src/data/serializer/serializer_checksum.js +0 -179
- package/dist/src/data/serializer/serializer_v0.d.ts +0 -55
- package/dist/src/data/serializer/serializer_v0.js +0 -484
- package/dist/src/data/shapes.d.ts +0 -19
- package/dist/src/data/shapes.js +0 -137
- package/dist/src/data/solver/allSolvers.d.ts +0 -3
- package/dist/src/data/solver/allSolvers.js +0 -13
- package/dist/src/data/solver/auto/autoSolver.d.ts +0 -18
- package/dist/src/data/solver/auto/autoSolver.js +0 -156
- package/dist/src/data/solver/backtrack/backtrackSolver.d.ts +0 -11
- package/dist/src/data/solver/backtrack/backtrackSolver.js +0 -54
- package/dist/src/data/solver/backtrack/backtrackWorker.d.ts +0 -1
- package/dist/src/data/solver/backtrack/backtrackWorker.js +0 -312
- package/dist/src/data/solver/backtrack/data.d.ts +0 -47
- package/dist/src/data/solver/backtrack/data.js +0 -151
- package/dist/src/data/solver/backtrack/rules/banPattern.d.ts +0 -9
- package/dist/src/data/solver/backtrack/rules/banPattern.js +0 -77
- package/dist/src/data/solver/backtrack/rules/cellCount.d.ts +0 -7
- package/dist/src/data/solver/backtrack/rules/cellCount.js +0 -25
- package/dist/src/data/solver/backtrack/rules/connectAll.d.ts +0 -7
- package/dist/src/data/solver/backtrack/rules/connectAll.js +0 -44
- package/dist/src/data/solver/backtrack/rules/regionArea.d.ts +0 -8
- package/dist/src/data/solver/backtrack/rules/regionArea.js +0 -71
- package/dist/src/data/solver/backtrack/rules/regionShape.d.ts +0 -8
- package/dist/src/data/solver/backtrack/rules/regionShape.js +0 -57
- package/dist/src/data/solver/backtrack/rules/sameShape.d.ts +0 -8
- package/dist/src/data/solver/backtrack/rules/sameShape.js +0 -14
- package/dist/src/data/solver/backtrack/rules/symbolsPerRegion.d.ts +0 -10
- package/dist/src/data/solver/backtrack/rules/symbolsPerRegion.js +0 -82
- package/dist/src/data/solver/backtrack/rules/uniqueShape.d.ts +0 -8
- package/dist/src/data/solver/backtrack/rules/uniqueShape.js +0 -14
- package/dist/src/data/solver/backtrack/symbols/areaNumber.d.ts +0 -9
- package/dist/src/data/solver/backtrack/symbols/areaNumber.js +0 -75
- package/dist/src/data/solver/backtrack/symbols/dart.d.ts +0 -8
- package/dist/src/data/solver/backtrack/symbols/dart.js +0 -45
- package/dist/src/data/solver/backtrack/symbols/directionLinker.d.ts +0 -11
- package/dist/src/data/solver/backtrack/symbols/directionLinker.js +0 -121
- package/dist/src/data/solver/backtrack/symbols/focus.d.ts +0 -9
- package/dist/src/data/solver/backtrack/symbols/focus.js +0 -48
- package/dist/src/data/solver/backtrack/symbols/galaxy.d.ts +0 -9
- package/dist/src/data/solver/backtrack/symbols/galaxy.js +0 -14
- package/dist/src/data/solver/backtrack/symbols/letter.d.ts +0 -9
- package/dist/src/data/solver/backtrack/symbols/letter.js +0 -95
- package/dist/src/data/solver/backtrack/symbols/lotus.d.ts +0 -11
- package/dist/src/data/solver/backtrack/symbols/lotus.js +0 -55
- package/dist/src/data/solver/backtrack/symbols/minesweeper.d.ts +0 -9
- package/dist/src/data/solver/backtrack/symbols/minesweeper.js +0 -44
- package/dist/src/data/solver/backtrack/symbols/myopia.d.ts +0 -7
- package/dist/src/data/solver/backtrack/symbols/myopia.js +0 -73
- package/dist/src/data/solver/backtrack/symbols/viewpoint.d.ts +0 -7
- package/dist/src/data/solver/backtrack/symbols/viewpoint.js +0 -51
- package/dist/src/data/solver/cspuz/cspuzSolver.d.ts +0 -13
- package/dist/src/data/solver/cspuz/cspuzSolver.js +0 -124
- package/dist/src/data/solver/cspuz/cspuzWorker.d.ts +0 -1
- package/dist/src/data/solver/cspuz/cspuzWorker.js +0 -82
- package/dist/src/data/solver/cspuz/jsonify.d.ts +0 -3
- package/dist/src/data/solver/cspuz/jsonify.js +0 -215
- package/dist/src/data/solver/eventIteratingSolver.d.ts +0 -8
- package/dist/src/data/solver/eventIteratingSolver.js +0 -54
- package/dist/src/data/solver/solver.d.ts +0 -77
- package/dist/src/data/solver/solver.js +0 -59
- package/dist/src/data/solver/universal/universalSolver.d.ts +0 -7
- package/dist/src/data/solver/universal/universalSolver.js +0 -13
- package/dist/src/data/solver/universal/universalWorker.d.ts +0 -1
- package/dist/src/data/solver/universal/universalWorker.js +0 -128
- package/dist/src/data/symbols/areaNumberSymbol.d.ts +0 -31
- package/dist/src/data/symbols/areaNumberSymbol.js +0 -80
- package/dist/src/data/symbols/customIconSymbol.d.ts +0 -35
- package/dist/src/data/symbols/customIconSymbol.js +0 -94
- package/dist/src/data/symbols/customSymbol.d.ts +0 -25
- package/dist/src/data/symbols/customSymbol.js +0 -45
- package/dist/src/data/symbols/customTextSymbol.d.ts +0 -35
- package/dist/src/data/symbols/customTextSymbol.js +0 -95
- package/dist/src/data/symbols/dartSymbol.d.ts +0 -36
- package/dist/src/data/symbols/dartSymbol.js +0 -96
- package/dist/src/data/symbols/directionLinkerSymbol.d.ts +0 -29
- package/dist/src/data/symbols/directionLinkerSymbol.js +0 -232
- package/dist/src/data/symbols/everyLetterSymbol.d.ts +0 -32
- package/dist/src/data/symbols/everyLetterSymbol.js +0 -119
- package/dist/src/data/symbols/focusSymbol.d.ts +0 -40
- package/dist/src/data/symbols/focusSymbol.js +0 -159
- package/dist/src/data/symbols/galaxySymbol.d.ts +0 -27
- package/dist/src/data/symbols/galaxySymbol.js +0 -61
- package/dist/src/data/symbols/hiddenSymbol.d.ts +0 -38
- package/dist/src/data/symbols/hiddenSymbol.js +0 -113
- package/dist/src/data/symbols/houseSymbol.d.ts +0 -33
- package/dist/src/data/symbols/houseSymbol.js +0 -104
- package/dist/src/data/symbols/index.d.ts +0 -3
- package/dist/src/data/symbols/index.js +0 -10
- package/dist/src/data/symbols/letterSymbol.d.ts +0 -32
- package/dist/src/data/symbols/letterSymbol.js +0 -118
- package/dist/src/data/symbols/lotusSymbol.d.ts +0 -30
- package/dist/src/data/symbols/lotusSymbol.js +0 -132
- package/dist/src/data/symbols/minesweeperSymbol.d.ts +0 -33
- package/dist/src/data/symbols/minesweeperSymbol.js +0 -106
- package/dist/src/data/symbols/myopiaSymbol.d.ts +0 -37
- package/dist/src/data/symbols/myopiaSymbol.js +0 -182
- package/dist/src/data/symbols/numberSymbol.d.ts +0 -19
- package/dist/src/data/symbols/numberSymbol.js +0 -32
- package/dist/src/data/symbols/symbol.d.ts +0 -29
- package/dist/src/data/symbols/symbol.js +0 -87
- package/dist/src/data/symbols/symbols.gen.d.ts +0 -15
- package/dist/src/data/symbols/symbols.gen.js +0 -19
- package/dist/src/data/symbols/unsupportedSymbol.d.ts +0 -23
- package/dist/src/data/symbols/unsupportedSymbol.js +0 -47
- package/dist/src/data/symbols/viewpointSymbol.d.ts +0 -32
- package/dist/src/data/symbols/viewpointSymbol.js +0 -95
- package/dist/src/data/tile.d.ts +0 -26
- package/dist/src/data/tile.js +0 -56
- package/dist/src/data/tileConnections.d.ts +0 -25
- package/dist/src/data/tileConnections.js +0 -74
- package/dist/src/data/validate.d.ts +0 -5
- package/dist/src/data/validate.js +0 -131
- package/dist/src/data/validateAsync.d.ts +0 -15
- package/dist/src/data/validateAsync.js +0 -71
- package/dist/src/data/validateAsyncWorker.d.ts +0 -1
- package/dist/src/data/validateAsyncWorker.js +0 -9
- package/dist/src/index.d.ts +0 -109
- package/dist/src/index.js +0 -112
- package/dist/src/polyfill/streamPolyfill.d.ts +0 -2
- package/dist/src/polyfill/streamPolyfill.js +0 -1
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { ConfigType } from '../config.js';
|
|
2
|
-
import GridData from '../grid.js';
|
|
3
|
-
import { array } from '../dataHelper.js';
|
|
4
|
-
import { Color, State } from '../primitives.js';
|
|
5
|
-
import Symbol from './symbol.js';
|
|
6
|
-
export default class LetterSymbol extends Symbol {
|
|
7
|
-
x;
|
|
8
|
-
y;
|
|
9
|
-
letter;
|
|
10
|
-
title = 'Letter';
|
|
11
|
-
static CONFIGS = Object.freeze([
|
|
12
|
-
{
|
|
13
|
-
type: ConfigType.Number,
|
|
14
|
-
default: 0,
|
|
15
|
-
field: 'x',
|
|
16
|
-
description: 'X',
|
|
17
|
-
configurable: false,
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: ConfigType.Number,
|
|
21
|
-
default: 0,
|
|
22
|
-
field: 'y',
|
|
23
|
-
description: 'Y',
|
|
24
|
-
configurable: false,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: ConfigType.String,
|
|
28
|
-
default: 'A',
|
|
29
|
-
field: 'letter',
|
|
30
|
-
description: 'Letter',
|
|
31
|
-
explanation: 'Use single uppercase letters by convention.',
|
|
32
|
-
configurable: true,
|
|
33
|
-
},
|
|
34
|
-
]);
|
|
35
|
-
static EXAMPLE_GRID = Object.freeze(GridData.create(['bbbww', 'wwbbw', 'wwbbb', 'bwwww'])
|
|
36
|
-
.addSymbol(new LetterSymbol(0, 0, 'B'))
|
|
37
|
-
.addSymbol(new LetterSymbol(3, 0, 'A'))
|
|
38
|
-
.addSymbol(new LetterSymbol(4, 1, 'A'))
|
|
39
|
-
.addSymbol(new LetterSymbol(3, 2, 'B'))
|
|
40
|
-
.addSymbol(new LetterSymbol(1, 1, 'C'))
|
|
41
|
-
.addSymbol(new LetterSymbol(0, 2, 'C'))
|
|
42
|
-
.addSymbol(new LetterSymbol(4, 3, 'C')));
|
|
43
|
-
/**
|
|
44
|
-
* **Letters must be sorted into one type per area**
|
|
45
|
-
*
|
|
46
|
-
* @param x - The x-coordinate of the symbol.
|
|
47
|
-
* @param y - The y-coordinate of the symbol.
|
|
48
|
-
* @param letter - The letter of the symbol.
|
|
49
|
-
*/
|
|
50
|
-
constructor(x, y, letter) {
|
|
51
|
-
super(x, y);
|
|
52
|
-
this.x = x;
|
|
53
|
-
this.y = y;
|
|
54
|
-
this.letter = letter;
|
|
55
|
-
this.letter = letter;
|
|
56
|
-
}
|
|
57
|
-
get id() {
|
|
58
|
-
return `letter`;
|
|
59
|
-
}
|
|
60
|
-
get explanation() {
|
|
61
|
-
return '*Letters* must be sorted into one type per area';
|
|
62
|
-
}
|
|
63
|
-
get configs() {
|
|
64
|
-
return LetterSymbol.CONFIGS;
|
|
65
|
-
}
|
|
66
|
-
createExampleGrid() {
|
|
67
|
-
return LetterSymbol.EXAMPLE_GRID;
|
|
68
|
-
}
|
|
69
|
-
validateSymbol(grid) {
|
|
70
|
-
if (!this.validateSubtilePlacement(grid))
|
|
71
|
-
return State.Error;
|
|
72
|
-
const thisX = Math.floor(this.x);
|
|
73
|
-
const thisY = Math.floor(this.y);
|
|
74
|
-
let complete = true;
|
|
75
|
-
const visited = array(grid.width, grid.height, () => false);
|
|
76
|
-
const connected = array(grid.width, grid.height, () => false);
|
|
77
|
-
const color = grid.getTile(thisX, thisY).color;
|
|
78
|
-
if (color !== Color.Gray) {
|
|
79
|
-
grid.iterateArea({ x: thisX, y: thisY }, tile => tile.color === Color.Gray || tile.color === color, (tile, x, y) => {
|
|
80
|
-
visited[y][x] = true;
|
|
81
|
-
if (tile.color === Color.Gray)
|
|
82
|
-
complete = false;
|
|
83
|
-
});
|
|
84
|
-
grid.iterateArea({ x: thisX, y: thisY }, tile => tile.color === color, (_, x, y) => {
|
|
85
|
-
connected[y][x] = true;
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
complete = false;
|
|
90
|
-
}
|
|
91
|
-
for (const symbol of grid.symbols.get(this.id) ?? []) {
|
|
92
|
-
if (symbol !== this && symbol instanceof LetterSymbol) {
|
|
93
|
-
const symbolX = Math.floor(symbol.x);
|
|
94
|
-
const symbolY = Math.floor(symbol.y);
|
|
95
|
-
if (symbol.letter === this.letter) {
|
|
96
|
-
const theirColor = grid.getTile(symbolX, symbolY).color;
|
|
97
|
-
if ((color !== Color.Gray && !visited[symbolY][symbolX]) ||
|
|
98
|
-
(color !== Color.Gray &&
|
|
99
|
-
theirColor !== Color.Gray &&
|
|
100
|
-
theirColor !== color)) {
|
|
101
|
-
return State.Error;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (color !== Color.Gray && connected[symbolY][symbolX]) {
|
|
105
|
-
return State.Error;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return complete ? State.Satisfied : State.Incomplete;
|
|
110
|
-
}
|
|
111
|
-
copyWith({ x, y, letter, }) {
|
|
112
|
-
return new LetterSymbol(x ?? this.x, y ?? this.y, letter ?? this.letter);
|
|
113
|
-
}
|
|
114
|
-
withLetter(letter) {
|
|
115
|
-
return this.copyWith({ letter });
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
export const instance = new LetterSymbol(0, 0, 'A');
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AnyConfig } from '../config.js';
|
|
2
|
-
import GridData from '../grid.js';
|
|
3
|
-
import { Orientation, State } from '../primitives.js';
|
|
4
|
-
import DirectionLinkerSymbol from './directionLinkerSymbol.js';
|
|
5
|
-
export default class LotusSymbol extends DirectionLinkerSymbol {
|
|
6
|
-
readonly x: number;
|
|
7
|
-
readonly y: number;
|
|
8
|
-
readonly orientation: Orientation;
|
|
9
|
-
readonly title = "Lotus";
|
|
10
|
-
private static readonly linkedDirectionsFromOrientation;
|
|
11
|
-
/**
|
|
12
|
-
* **Areas containing this symbol must be symmetrical**
|
|
13
|
-
*
|
|
14
|
-
* @param x - The x-coordinate of the symbol.
|
|
15
|
-
* @param y - The y-coordinate of the symbol.
|
|
16
|
-
* @param orientation - The orientation of the symbol.
|
|
17
|
-
*/
|
|
18
|
-
constructor(x: number, y: number, orientation: Orientation);
|
|
19
|
-
get id(): string;
|
|
20
|
-
get explanation(): string;
|
|
21
|
-
get configs(): readonly AnyConfig[] | null;
|
|
22
|
-
createExampleGrid(): GridData;
|
|
23
|
-
validateSymbol(grid: GridData): State;
|
|
24
|
-
copyWith({ x, y, orientation, }: {
|
|
25
|
-
x?: number;
|
|
26
|
-
y?: number;
|
|
27
|
-
orientation?: Orientation;
|
|
28
|
-
}): this;
|
|
29
|
-
}
|
|
30
|
-
export declare const instance: LotusSymbol;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { ConfigType } from '../config.js';
|
|
2
|
-
import GridData from '../grid.js';
|
|
3
|
-
import { Direction, Orientation, State } from '../primitives.js';
|
|
4
|
-
import DirectionLinkerSymbol from './directionLinkerSymbol.js';
|
|
5
|
-
export default class LotusSymbol extends DirectionLinkerSymbol {
|
|
6
|
-
x;
|
|
7
|
-
y;
|
|
8
|
-
orientation;
|
|
9
|
-
title = 'Lotus';
|
|
10
|
-
static linkedDirectionsFromOrientation = {
|
|
11
|
-
[Orientation.Up]: {
|
|
12
|
-
[Direction.Left]: Direction.Right,
|
|
13
|
-
[Direction.Up]: Direction.Up,
|
|
14
|
-
[Direction.Right]: Direction.Left,
|
|
15
|
-
[Direction.Down]: Direction.Down,
|
|
16
|
-
},
|
|
17
|
-
[Orientation.UpRight]: {
|
|
18
|
-
[Direction.Left]: Direction.Down,
|
|
19
|
-
[Direction.Up]: Direction.Right,
|
|
20
|
-
[Direction.Right]: Direction.Up,
|
|
21
|
-
[Direction.Down]: Direction.Left,
|
|
22
|
-
},
|
|
23
|
-
[Orientation.Right]: {
|
|
24
|
-
[Direction.Left]: Direction.Left,
|
|
25
|
-
[Direction.Up]: Direction.Down,
|
|
26
|
-
[Direction.Right]: Direction.Right,
|
|
27
|
-
[Direction.Down]: Direction.Up,
|
|
28
|
-
},
|
|
29
|
-
[Orientation.DownRight]: {
|
|
30
|
-
[Direction.Left]: Direction.Up,
|
|
31
|
-
[Direction.Up]: Direction.Left,
|
|
32
|
-
[Direction.Right]: Direction.Down,
|
|
33
|
-
[Direction.Down]: Direction.Right,
|
|
34
|
-
},
|
|
35
|
-
[Orientation.Down]: {
|
|
36
|
-
[Direction.Left]: Direction.Right,
|
|
37
|
-
[Direction.Up]: Direction.Up,
|
|
38
|
-
[Direction.Right]: Direction.Left,
|
|
39
|
-
[Direction.Down]: Direction.Down,
|
|
40
|
-
},
|
|
41
|
-
[Orientation.DownLeft]: {
|
|
42
|
-
[Direction.Left]: Direction.Down,
|
|
43
|
-
[Direction.Up]: Direction.Right,
|
|
44
|
-
[Direction.Right]: Direction.Up,
|
|
45
|
-
[Direction.Down]: Direction.Left,
|
|
46
|
-
},
|
|
47
|
-
[Orientation.Left]: {
|
|
48
|
-
[Direction.Left]: Direction.Left,
|
|
49
|
-
[Direction.Up]: Direction.Down,
|
|
50
|
-
[Direction.Right]: Direction.Right,
|
|
51
|
-
[Direction.Down]: Direction.Up,
|
|
52
|
-
},
|
|
53
|
-
[Orientation.UpLeft]: {
|
|
54
|
-
[Direction.Left]: Direction.Up,
|
|
55
|
-
[Direction.Up]: Direction.Left,
|
|
56
|
-
[Direction.Right]: Direction.Down,
|
|
57
|
-
[Direction.Down]: Direction.Right,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* **Areas containing this symbol must be symmetrical**
|
|
62
|
-
*
|
|
63
|
-
* @param x - The x-coordinate of the symbol.
|
|
64
|
-
* @param y - The y-coordinate of the symbol.
|
|
65
|
-
* @param orientation - The orientation of the symbol.
|
|
66
|
-
*/
|
|
67
|
-
constructor(x, y, orientation) {
|
|
68
|
-
super(x, y);
|
|
69
|
-
this.x = x;
|
|
70
|
-
this.y = y;
|
|
71
|
-
this.orientation = orientation;
|
|
72
|
-
super.changeDirections(LotusSymbol.linkedDirectionsFromOrientation[orientation]);
|
|
73
|
-
}
|
|
74
|
-
get id() {
|
|
75
|
-
return `lotus`;
|
|
76
|
-
}
|
|
77
|
-
get explanation() {
|
|
78
|
-
return `Areas containing this symbol must be *symmetrical*`;
|
|
79
|
-
}
|
|
80
|
-
get configs() {
|
|
81
|
-
return Object.freeze([
|
|
82
|
-
{
|
|
83
|
-
type: ConfigType.Number,
|
|
84
|
-
default: 0,
|
|
85
|
-
field: 'x',
|
|
86
|
-
description: 'X',
|
|
87
|
-
configurable: false,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
type: ConfigType.Number,
|
|
91
|
-
default: 0,
|
|
92
|
-
field: 'y',
|
|
93
|
-
description: 'Y',
|
|
94
|
-
configurable: false,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: ConfigType.Orientation,
|
|
98
|
-
default: Orientation.Up,
|
|
99
|
-
field: 'orientation',
|
|
100
|
-
description: 'Orientation',
|
|
101
|
-
configurable: true,
|
|
102
|
-
},
|
|
103
|
-
]);
|
|
104
|
-
}
|
|
105
|
-
createExampleGrid() {
|
|
106
|
-
return Object.freeze(GridData.create(['wwbww', 'bwbwb', 'bwwwb', 'bwwwb']).addSymbol(new LotusSymbol(2, 2, Orientation.Up)));
|
|
107
|
-
}
|
|
108
|
-
validateSymbol(grid) {
|
|
109
|
-
if (this.orientation === Orientation.DownLeft ||
|
|
110
|
-
this.orientation === Orientation.DownRight ||
|
|
111
|
-
this.orientation === Orientation.UpLeft ||
|
|
112
|
-
this.orientation === Orientation.UpRight) {
|
|
113
|
-
if (this.x % 1 === 0 || this.y % 1 === 0)
|
|
114
|
-
if (this.x % 1 !== 0 || this.y % 1 !== 0) {
|
|
115
|
-
if (!grid.getTile(Math.floor(this.x), Math.floor(this.y)).exists &&
|
|
116
|
-
!grid.getTile(Math.ceil(this.x), Math.ceil(this.y)).exists &&
|
|
117
|
-
!grid.getTile(Math.floor(this.x), Math.ceil(this.y)).exists &&
|
|
118
|
-
!grid.getTile(Math.ceil(this.x), Math.floor(this.y)).exists) {
|
|
119
|
-
return State.Satisfied;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return State.Error;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return super.validateSymbol(grid);
|
|
127
|
-
}
|
|
128
|
-
copyWith({ x, y, orientation, }) {
|
|
129
|
-
return new LotusSymbol(x ?? this.x, y ?? this.y, orientation ?? this.orientation);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
export const instance = new LotusSymbol(0, 0, Orientation.Up);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AnyConfig } from '../config.js';
|
|
2
|
-
import GridData from '../grid.js';
|
|
3
|
-
import NumberSymbol from './numberSymbol.js';
|
|
4
|
-
export default class MinesweeperSymbol extends NumberSymbol {
|
|
5
|
-
readonly title = "Minesweeper Number";
|
|
6
|
-
private static readonly CONFIGS;
|
|
7
|
-
private static readonly EXAMPLE_GRID;
|
|
8
|
-
/**
|
|
9
|
-
* **Minesweeper Numbers count opposite cells in 8 adjacent spaces**
|
|
10
|
-
*
|
|
11
|
-
* @param x - The x-coordinate of the symbol.
|
|
12
|
-
* @param y - The y-coordinate of the symbol.
|
|
13
|
-
* @param number - The number of cells seen by the symbol.
|
|
14
|
-
*/
|
|
15
|
-
constructor(x: number, y: number, number: number);
|
|
16
|
-
get id(): string;
|
|
17
|
-
get placementStep(): number;
|
|
18
|
-
get explanation(): string;
|
|
19
|
-
get configs(): readonly AnyConfig[] | null;
|
|
20
|
-
createExampleGrid(): GridData;
|
|
21
|
-
private countForColor;
|
|
22
|
-
countTiles(grid: GridData): {
|
|
23
|
-
completed: number;
|
|
24
|
-
possible: number;
|
|
25
|
-
};
|
|
26
|
-
copyWith({ x, y, number, }: {
|
|
27
|
-
x?: number;
|
|
28
|
-
y?: number;
|
|
29
|
-
number?: number;
|
|
30
|
-
}): this;
|
|
31
|
-
withNumber(number: number): this;
|
|
32
|
-
}
|
|
33
|
-
export declare const instance: MinesweeperSymbol;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { ConfigType } from '../config.js';
|
|
2
|
-
import GridData from '../grid.js';
|
|
3
|
-
import { Color } from '../primitives.js';
|
|
4
|
-
import NumberSymbol from './numberSymbol.js';
|
|
5
|
-
export default class MinesweeperSymbol extends NumberSymbol {
|
|
6
|
-
title = 'Minesweeper Number';
|
|
7
|
-
static CONFIGS = Object.freeze([
|
|
8
|
-
{
|
|
9
|
-
type: ConfigType.Number,
|
|
10
|
-
default: 0,
|
|
11
|
-
field: 'x',
|
|
12
|
-
description: 'X',
|
|
13
|
-
configurable: false,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: ConfigType.Number,
|
|
17
|
-
default: 0,
|
|
18
|
-
field: 'y',
|
|
19
|
-
description: 'Y',
|
|
20
|
-
configurable: false,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: ConfigType.Number,
|
|
24
|
-
default: 1,
|
|
25
|
-
field: 'number',
|
|
26
|
-
description: 'Number',
|
|
27
|
-
configurable: true,
|
|
28
|
-
},
|
|
29
|
-
]);
|
|
30
|
-
static EXAMPLE_GRID = Object.freeze(GridData.create(['wwbww', 'wwbwb', 'wwbwb', 'bwwww'])
|
|
31
|
-
.addSymbol(new MinesweeperSymbol(1, 1, 3))
|
|
32
|
-
.addSymbol(new MinesweeperSymbol(3, 1, 5))
|
|
33
|
-
.addSymbol(new MinesweeperSymbol(4, 1, 4))
|
|
34
|
-
.addSymbol(new MinesweeperSymbol(2, 3, 1)));
|
|
35
|
-
/**
|
|
36
|
-
* **Minesweeper Numbers count opposite cells in 8 adjacent spaces**
|
|
37
|
-
*
|
|
38
|
-
* @param x - The x-coordinate of the symbol.
|
|
39
|
-
* @param y - The y-coordinate of the symbol.
|
|
40
|
-
* @param number - The number of cells seen by the symbol.
|
|
41
|
-
*/
|
|
42
|
-
constructor(x, y, number) {
|
|
43
|
-
super(x, y, number);
|
|
44
|
-
}
|
|
45
|
-
get id() {
|
|
46
|
-
return `minesweeper`;
|
|
47
|
-
}
|
|
48
|
-
get placementStep() {
|
|
49
|
-
return 1;
|
|
50
|
-
}
|
|
51
|
-
get explanation() {
|
|
52
|
-
return `*Minesweeper Numbers* count opposite cells in 8 adjacent spaces`;
|
|
53
|
-
}
|
|
54
|
-
get configs() {
|
|
55
|
-
return MinesweeperSymbol.CONFIGS;
|
|
56
|
-
}
|
|
57
|
-
createExampleGrid() {
|
|
58
|
-
return MinesweeperSymbol.EXAMPLE_GRID;
|
|
59
|
-
}
|
|
60
|
-
countForColor(grid, color) {
|
|
61
|
-
let gray = 0;
|
|
62
|
-
let opposite = 0;
|
|
63
|
-
const visited = [];
|
|
64
|
-
for (let y = this.y - 1; y <= this.y + 1; y++) {
|
|
65
|
-
for (let x = this.x - 1; x <= this.x + 1; x++) {
|
|
66
|
-
if (x === this.x && y === this.y)
|
|
67
|
-
continue;
|
|
68
|
-
if (grid.wrapAround.value) {
|
|
69
|
-
const pos = grid.toArrayCoordinates(x, y);
|
|
70
|
-
if (visited.some(v => v.x === pos.x && v.y === pos.y))
|
|
71
|
-
continue;
|
|
72
|
-
visited.push(pos);
|
|
73
|
-
}
|
|
74
|
-
const tile = grid.getTile(x, y);
|
|
75
|
-
if (!tile.exists)
|
|
76
|
-
continue;
|
|
77
|
-
if (tile.color === Color.Gray)
|
|
78
|
-
gray++;
|
|
79
|
-
else if (tile.color !== color)
|
|
80
|
-
opposite++;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return { completed: opposite, possible: opposite + gray };
|
|
84
|
-
}
|
|
85
|
-
countTiles(grid) {
|
|
86
|
-
if (Math.floor(this.x) !== this.x || Math.floor(this.y) !== this.y)
|
|
87
|
-
return { completed: 0, possible: Number.MAX_SAFE_INTEGER };
|
|
88
|
-
const color = grid.getTile(this.x, this.y).color;
|
|
89
|
-
if (color === Color.Gray) {
|
|
90
|
-
const dark = this.countForColor(grid, Color.Dark);
|
|
91
|
-
const light = this.countForColor(grid, Color.Light);
|
|
92
|
-
return {
|
|
93
|
-
completed: Math.min(dark.completed, light.completed),
|
|
94
|
-
possible: Math.max(dark.possible, light.possible),
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return this.countForColor(grid, color);
|
|
98
|
-
}
|
|
99
|
-
copyWith({ x, y, number, }) {
|
|
100
|
-
return new MinesweeperSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
|
|
101
|
-
}
|
|
102
|
-
withNumber(number) {
|
|
103
|
-
return this.copyWith({ number });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
export const instance = new MinesweeperSymbol(0, 0, 1);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AnyConfig } from '../config.js';
|
|
2
|
-
import { SymbolMergeHandler } from '../events/onSymbolMerge.js';
|
|
3
|
-
import GridData from '../grid.js';
|
|
4
|
-
import { OrientationToggle, State } from '../primitives.js';
|
|
5
|
-
import Symbol from './symbol.js';
|
|
6
|
-
export default class MyopiaSymbol extends Symbol implements SymbolMergeHandler {
|
|
7
|
-
readonly diagonals: boolean;
|
|
8
|
-
readonly directions: OrientationToggle;
|
|
9
|
-
get title(): "Framed Myopia Arrow" | "Myopia Arrow";
|
|
10
|
-
private static readonly CONFIGS;
|
|
11
|
-
private static readonly EXAMPLE_GRID;
|
|
12
|
-
private static readonly EXAMPLE_DIAGONAL_GRID;
|
|
13
|
-
/**
|
|
14
|
-
* **Viewpoint Numbers count visible cells in the four directions**
|
|
15
|
-
* @param x - The x-coordinate of the symbol.
|
|
16
|
-
* @param y - The y-coordinate of the symbol.
|
|
17
|
-
* @param diagonals - Whether the symbol should consider diagonal directions.
|
|
18
|
-
* @param directions - The directions in which an arrow is pointing.
|
|
19
|
-
*/
|
|
20
|
-
constructor(x: number, y: number, diagonals: boolean, directions: OrientationToggle);
|
|
21
|
-
get id(): string;
|
|
22
|
-
get placementStep(): number;
|
|
23
|
-
get explanation(): string;
|
|
24
|
-
get configs(): readonly AnyConfig[] | null;
|
|
25
|
-
createExampleGrid(): GridData;
|
|
26
|
-
validateSymbol(grid: GridData): State;
|
|
27
|
-
descriptionEquals(other: Symbol): boolean;
|
|
28
|
-
copyWith({ x, y, diagonals, directions, }: {
|
|
29
|
-
x?: number;
|
|
30
|
-
y?: number;
|
|
31
|
-
diagonals?: boolean;
|
|
32
|
-
directions?: OrientationToggle;
|
|
33
|
-
}): this;
|
|
34
|
-
withDirections(directions: OrientationToggle): this;
|
|
35
|
-
withDiagonals(diagonals: boolean): this;
|
|
36
|
-
}
|
|
37
|
-
export declare const instance: MyopiaSymbol;
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { ConfigType } from '../config.js';
|
|
2
|
-
import { move } from '../dataHelper.js';
|
|
3
|
-
import GridData from '../grid.js';
|
|
4
|
-
import { Color, ORIENTATIONS, Orientation, State, orientationToggle, } from '../primitives.js';
|
|
5
|
-
import Symbol from './symbol.js';
|
|
6
|
-
export default class MyopiaSymbol extends Symbol {
|
|
7
|
-
diagonals;
|
|
8
|
-
directions;
|
|
9
|
-
get title() {
|
|
10
|
-
return this.diagonals ? 'Framed Myopia Arrow' : 'Myopia Arrow';
|
|
11
|
-
}
|
|
12
|
-
static CONFIGS = Object.freeze([
|
|
13
|
-
{
|
|
14
|
-
type: ConfigType.Number,
|
|
15
|
-
default: 0,
|
|
16
|
-
field: 'x',
|
|
17
|
-
description: 'X',
|
|
18
|
-
configurable: false,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
type: ConfigType.Number,
|
|
22
|
-
default: 0,
|
|
23
|
-
field: 'y',
|
|
24
|
-
description: 'Y',
|
|
25
|
-
configurable: false,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
type: ConfigType.Boolean,
|
|
29
|
-
default: false,
|
|
30
|
-
field: 'diagonals',
|
|
31
|
-
description: 'Include diagonal directions',
|
|
32
|
-
explanation: 'Whether to check diagonals as well. Must be enabled for diagonal arrows.',
|
|
33
|
-
configurable: true,
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: ConfigType.OrientationToggle,
|
|
37
|
-
default: orientationToggle(Orientation.Up, Orientation.Right),
|
|
38
|
-
field: 'directions',
|
|
39
|
-
description: 'Directions',
|
|
40
|
-
explanation: 'The directions in which an arrow is pointing. A dot will be displayed if no arrows are present.',
|
|
41
|
-
configurable: true,
|
|
42
|
-
},
|
|
43
|
-
]);
|
|
44
|
-
static EXAMPLE_GRID = Object.freeze(GridData.create(['wbwww', 'bwwwb', 'wwwww', 'wbwww']).withSymbols([
|
|
45
|
-
new MyopiaSymbol(1, 1, false, orientationToggle(Orientation.Up, Orientation.Left)),
|
|
46
|
-
new MyopiaSymbol(4, 3, false, orientationToggle(Orientation.Up)),
|
|
47
|
-
]));
|
|
48
|
-
static EXAMPLE_DIAGONAL_GRID = Object.freeze(GridData.create(['wbwww', 'bwwwb', 'wwwww', 'wbwww']).withSymbols([
|
|
49
|
-
new MyopiaSymbol(1, 2, true, orientationToggle(Orientation.UpLeft, Orientation.Down)),
|
|
50
|
-
new MyopiaSymbol(3, 2, true, orientationToggle(Orientation.UpRight)),
|
|
51
|
-
]));
|
|
52
|
-
/**
|
|
53
|
-
* **Viewpoint Numbers count visible cells in the four directions**
|
|
54
|
-
* @param x - The x-coordinate of the symbol.
|
|
55
|
-
* @param y - The y-coordinate of the symbol.
|
|
56
|
-
* @param diagonals - Whether the symbol should consider diagonal directions.
|
|
57
|
-
* @param directions - The directions in which an arrow is pointing.
|
|
58
|
-
*/
|
|
59
|
-
constructor(x, y, diagonals, directions) {
|
|
60
|
-
super(x, y);
|
|
61
|
-
this.diagonals = diagonals;
|
|
62
|
-
this.directions = directions;
|
|
63
|
-
this.directions = directions;
|
|
64
|
-
this.diagonals =
|
|
65
|
-
directions[Orientation.DownLeft] ||
|
|
66
|
-
directions[Orientation.DownRight] ||
|
|
67
|
-
directions[Orientation.UpLeft] ||
|
|
68
|
-
directions[Orientation.UpRight]
|
|
69
|
-
? true
|
|
70
|
-
: diagonals;
|
|
71
|
-
}
|
|
72
|
-
get id() {
|
|
73
|
-
return `myopia`;
|
|
74
|
-
}
|
|
75
|
-
get placementStep() {
|
|
76
|
-
return 1;
|
|
77
|
-
}
|
|
78
|
-
get explanation() {
|
|
79
|
-
return this.diagonals
|
|
80
|
-
? '*Framed myopia arrows* point to *all* the closest opposite cells in 8 directions'
|
|
81
|
-
: '*Myopia arrows* point to *all* the closest cells of the opposite color';
|
|
82
|
-
}
|
|
83
|
-
get configs() {
|
|
84
|
-
return MyopiaSymbol.CONFIGS;
|
|
85
|
-
}
|
|
86
|
-
createExampleGrid() {
|
|
87
|
-
return this.diagonals
|
|
88
|
-
? MyopiaSymbol.EXAMPLE_DIAGONAL_GRID
|
|
89
|
-
: MyopiaSymbol.EXAMPLE_GRID;
|
|
90
|
-
}
|
|
91
|
-
validateSymbol(grid) {
|
|
92
|
-
const tile = grid.getTile(this.x, this.y);
|
|
93
|
-
if (!tile.exists || tile.color === Color.Gray)
|
|
94
|
-
return State.Incomplete;
|
|
95
|
-
const allDirections = this.diagonals
|
|
96
|
-
? ORIENTATIONS
|
|
97
|
-
: [Orientation.Up, Orientation.Down, Orientation.Left, Orientation.Right];
|
|
98
|
-
const map = {
|
|
99
|
-
up: { min: 0, max: 0, complete: true },
|
|
100
|
-
down: { min: 0, max: 0, complete: true },
|
|
101
|
-
left: { min: 0, max: 0, complete: true },
|
|
102
|
-
right: { min: 0, max: 0, complete: true },
|
|
103
|
-
'up-left': { min: 0, max: 0, complete: true },
|
|
104
|
-
'up-right': { min: 0, max: 0, complete: true },
|
|
105
|
-
'down-left': { min: 0, max: 0, complete: true },
|
|
106
|
-
'down-right': { min: 0, max: 0, complete: true },
|
|
107
|
-
};
|
|
108
|
-
const pos = { x: this.x, y: this.y };
|
|
109
|
-
allDirections.forEach(direction => {
|
|
110
|
-
let stopped = false;
|
|
111
|
-
grid.iterateDirectionAll(move(pos, direction), direction, t => {
|
|
112
|
-
if (!t.exists)
|
|
113
|
-
return true;
|
|
114
|
-
if (t.color === tile.color)
|
|
115
|
-
return true;
|
|
116
|
-
stopped = true;
|
|
117
|
-
return false;
|
|
118
|
-
}, () => {
|
|
119
|
-
map[direction].min++;
|
|
120
|
-
});
|
|
121
|
-
if (!stopped && map[direction].min === 0)
|
|
122
|
-
map[direction].min = Number.MAX_SAFE_INTEGER;
|
|
123
|
-
stopped = false;
|
|
124
|
-
grid.iterateDirectionAll(move(pos, direction), direction, t => {
|
|
125
|
-
if (!t.exists)
|
|
126
|
-
return true;
|
|
127
|
-
if (t.color === tile.color || t.color === Color.Gray)
|
|
128
|
-
return true;
|
|
129
|
-
stopped = true;
|
|
130
|
-
return false;
|
|
131
|
-
}, t => {
|
|
132
|
-
map[direction].max++;
|
|
133
|
-
if (t.exists && t.color === Color.Gray)
|
|
134
|
-
map[direction].complete = false;
|
|
135
|
-
});
|
|
136
|
-
if (!stopped)
|
|
137
|
-
map[direction].max = Number.MAX_SAFE_INTEGER;
|
|
138
|
-
});
|
|
139
|
-
const pointedDirections = allDirections.filter(d => this.directions[d]);
|
|
140
|
-
const otherDirections = allDirections.filter(d => !this.directions[d]);
|
|
141
|
-
for (let i = 0; i < pointedDirections.length; i++) {
|
|
142
|
-
const direction1 = pointedDirections[i];
|
|
143
|
-
for (let j = i + 1; j < pointedDirections.length; j++) {
|
|
144
|
-
const direction2 = pointedDirections[j];
|
|
145
|
-
if (map[direction1].min > map[direction2].max)
|
|
146
|
-
return State.Error;
|
|
147
|
-
if (map[direction2].min > map[direction1].max)
|
|
148
|
-
return State.Error;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (Math.min(...otherDirections.map(d => map[d].max)) <=
|
|
152
|
-
Math.max(...pointedDirections.map(d => map[d].min)))
|
|
153
|
-
return State.Error;
|
|
154
|
-
if (pointedDirections.length === 0 &&
|
|
155
|
-
otherDirections.some(d => map[d].max !== Number.MAX_SAFE_INTEGER))
|
|
156
|
-
return State.Error;
|
|
157
|
-
if (pointedDirections.some(d => map[d].complete && map[d].max === Number.MAX_SAFE_INTEGER))
|
|
158
|
-
return State.Error;
|
|
159
|
-
if (pointedDirections.length > 0 &&
|
|
160
|
-
otherDirections.length > 0 &&
|
|
161
|
-
pointedDirections.every(d => map[d].complete) &&
|
|
162
|
-
Math.max(...pointedDirections.map(d => map[d].max)) <
|
|
163
|
-
Math.min(...otherDirections.map(d => map[d].min)))
|
|
164
|
-
return State.Satisfied;
|
|
165
|
-
if (allDirections.every(d => map[d].complete))
|
|
166
|
-
return State.Satisfied;
|
|
167
|
-
return State.Incomplete;
|
|
168
|
-
}
|
|
169
|
-
descriptionEquals(other) {
|
|
170
|
-
return this.id === other.id && this.explanation === other.explanation;
|
|
171
|
-
}
|
|
172
|
-
copyWith({ x, y, diagonals, directions, }) {
|
|
173
|
-
return new MyopiaSymbol(x ?? this.x, y ?? this.y, diagonals ?? this.diagonals, directions ?? this.directions);
|
|
174
|
-
}
|
|
175
|
-
withDirections(directions) {
|
|
176
|
-
return this.copyWith({ directions });
|
|
177
|
-
}
|
|
178
|
-
withDiagonals(diagonals) {
|
|
179
|
-
return this.copyWith({ diagonals });
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
export const instance = new MyopiaSymbol(0, 0, false, orientationToggle(Orientation.Up, Orientation.Right));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import GridData from '../grid.js';
|
|
2
|
-
import { State } from '../primitives.js';
|
|
3
|
-
import Symbol from './symbol.js';
|
|
4
|
-
/**
|
|
5
|
-
* All symbols which contain a number should extend this class to be compatible with off by X rules.
|
|
6
|
-
*/
|
|
7
|
-
export default abstract class NumberSymbol extends Symbol {
|
|
8
|
-
readonly x: number;
|
|
9
|
-
readonly y: number;
|
|
10
|
-
readonly number: number;
|
|
11
|
-
constructor(x: number, y: number, number: number);
|
|
12
|
-
abstract countTiles(grid: GridData): {
|
|
13
|
-
completed: number;
|
|
14
|
-
possible: number;
|
|
15
|
-
} | null;
|
|
16
|
-
validateSymbol(grid: GridData): State;
|
|
17
|
-
withNumber(number: number): this;
|
|
18
|
-
}
|
|
19
|
-
export declare const instance: undefined;
|