@logic-pad/core 0.16.0 → 0.17.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.
@@ -3083,6 +3083,26 @@ declare global {
3083
3083
  }): this;
3084
3084
  withRevealLocation(revealLocation: boolean): this;
3085
3085
  }
3086
+ export declare class HouseSymbol extends Symbol$1 {
3087
+ readonly x: number;
3088
+ readonly y: number;
3089
+ readonly title = 'House';
3090
+ private static readonly CONFIGS;
3091
+ private static readonly EXAMPLE_GRID;
3092
+ /**
3093
+ * **Houses must connect to exactly one other house**
3094
+ *
3095
+ * @param x - The x-coordinate of the symbol.
3096
+ * @param y - The y-coordinate of the symbol.
3097
+ */
3098
+ constructor(x: number, y: number);
3099
+ get id(): string;
3100
+ get explanation(): string;
3101
+ get configs(): readonly AnyConfig[] | null;
3102
+ createExampleGrid(): GridData;
3103
+ validateSymbol(grid: GridData): State;
3104
+ copyWith({ x, y }: { x?: number; y?: number }): this;
3105
+ }
3086
3106
  export declare const allSymbols: Map<string, Symbol$1>;
3087
3107
  export declare function aggregateState(
3088
3108
  rules: readonly RuleState[],
@@ -0,0 +1,28 @@
1
+ import { AnyConfig } from '../config.js';
2
+ import GridData from '../grid.js';
3
+ import { State } from '../primitives.js';
4
+ import Symbol from './symbol.js';
5
+ export default class HouseSymbol extends Symbol {
6
+ readonly x: number;
7
+ readonly y: number;
8
+ readonly title = "House";
9
+ private static readonly CONFIGS;
10
+ private static readonly EXAMPLE_GRID;
11
+ /**
12
+ * **Houses must connect to exactly one other house**
13
+ *
14
+ * @param x - The x-coordinate of the symbol.
15
+ * @param y - The y-coordinate of the symbol.
16
+ */
17
+ constructor(x: number, y: number);
18
+ get id(): string;
19
+ get explanation(): string;
20
+ get configs(): readonly AnyConfig[] | null;
21
+ createExampleGrid(): GridData;
22
+ validateSymbol(grid: GridData): State;
23
+ copyWith({ x, y }: {
24
+ x?: number;
25
+ y?: number;
26
+ }): this;
27
+ }
28
+ export declare const instance: HouseSymbol;
@@ -0,0 +1,121 @@
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
+ class HouseSymbol extends Symbol {
7
+ /**
8
+ * **Houses must connect to exactly one other house**
9
+ *
10
+ * @param x - The x-coordinate of the symbol.
11
+ * @param y - The y-coordinate of the symbol.
12
+ */
13
+ constructor(x, y) {
14
+ super(x, y);
15
+ Object.defineProperty(this, "x", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: x
20
+ });
21
+ Object.defineProperty(this, "y", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: y
26
+ });
27
+ Object.defineProperty(this, "title", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: 'House'
32
+ });
33
+ }
34
+ get id() {
35
+ return `house`;
36
+ }
37
+ get explanation() {
38
+ return '*Houses* must connect to *exactly one* other house';
39
+ }
40
+ get configs() {
41
+ return HouseSymbol.CONFIGS;
42
+ }
43
+ createExampleGrid() {
44
+ return HouseSymbol.EXAMPLE_GRID;
45
+ }
46
+ validateSymbol(grid) {
47
+ const thisX = Math.floor(this.x);
48
+ const thisY = Math.floor(this.y);
49
+ let complete = true;
50
+ const visited = array(grid.width, grid.height, () => false);
51
+ const connected = array(grid.width, grid.height, () => false);
52
+ const color = grid.getTile(thisX, thisY).color;
53
+ grid.iterateArea({ x: thisX, y: thisY }, tile => color === Color.Gray ||
54
+ tile.color === Color.Gray ||
55
+ tile.color === color, (tile, x, y) => {
56
+ visited[y][x] = true;
57
+ if (tile.color === Color.Gray)
58
+ complete = false;
59
+ });
60
+ grid.iterateArea({ x: thisX, y: thisY }, tile => tile.color === color, (_, x, y) => {
61
+ connected[y][x] = true;
62
+ });
63
+ let connectedHouses = 0;
64
+ let possibleHouses = 0;
65
+ for (const symbol of grid.symbols.get(this.id) ?? []) {
66
+ if (symbol !== this && symbol instanceof HouseSymbol) {
67
+ const symbolX = Math.floor(symbol.x);
68
+ const symbolY = Math.floor(symbol.y);
69
+ if (connected[symbolY][symbolX])
70
+ connectedHouses++;
71
+ else if (visited[symbolY][symbolX])
72
+ possibleHouses++;
73
+ }
74
+ }
75
+ if (color !== Color.Gray &&
76
+ (connectedHouses > 1 || connectedHouses + possibleHouses < 1)) {
77
+ return State.Error;
78
+ }
79
+ return complete || (connectedHouses === 1 && possibleHouses === 0)
80
+ ? State.Satisfied
81
+ : State.Incomplete;
82
+ }
83
+ copyWith({ x, y }) {
84
+ return new HouseSymbol(x ?? this.x, y ?? this.y);
85
+ }
86
+ }
87
+ Object.defineProperty(HouseSymbol, "CONFIGS", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: Object.freeze([
92
+ {
93
+ type: ConfigType.Number,
94
+ default: 0,
95
+ field: 'x',
96
+ description: 'X',
97
+ configurable: false,
98
+ },
99
+ {
100
+ type: ConfigType.Number,
101
+ default: 0,
102
+ field: 'y',
103
+ description: 'Y',
104
+ configurable: false,
105
+ },
106
+ ])
107
+ });
108
+ Object.defineProperty(HouseSymbol, "EXAMPLE_GRID", {
109
+ enumerable: true,
110
+ configurable: true,
111
+ writable: true,
112
+ value: Object.freeze(GridData.create(['bbbww', 'wwwbw', 'wbbbw', 'wwwww'])
113
+ .addSymbol(new HouseSymbol(0, 0))
114
+ .addSymbol(new HouseSymbol(2, 0))
115
+ .addSymbol(new HouseSymbol(3, 0))
116
+ .addSymbol(new HouseSymbol(2, 1))
117
+ .addSymbol(new HouseSymbol(3, 1))
118
+ .addSymbol(new HouseSymbol(1, 2)))
119
+ });
120
+ export default HouseSymbol;
121
+ export const instance = new HouseSymbol(0, 0);
@@ -5,6 +5,7 @@ export { instance as DartSymbol } from './dartSymbol.js';
5
5
  export { instance as FocusSymbol } from './focusSymbol.js';
6
6
  export { instance as GalaxySymbol } from './galaxySymbol.js';
7
7
  export { instance as HiddenSymbol } from './hiddenSymbol.js';
8
+ export { instance as HouseSymbol } from './houseSymbol.js';
8
9
  export { instance as LetterSymbol } from './letterSymbol.js';
9
10
  export { instance as LotusSymbol } from './lotusSymbol.js';
10
11
  export { instance as MinesweeperSymbol } from './minesweeperSymbol.js';
@@ -9,6 +9,7 @@ export { instance as DartSymbol } from './dartSymbol.js';
9
9
  export { instance as FocusSymbol } from './focusSymbol.js';
10
10
  export { instance as GalaxySymbol } from './galaxySymbol.js';
11
11
  export { instance as HiddenSymbol } from './hiddenSymbol.js';
12
+ export { instance as HouseSymbol } from './houseSymbol.js';
12
13
  export { instance as LetterSymbol } from './letterSymbol.js';
13
14
  export { instance as LotusSymbol } from './lotusSymbol.js';
14
15
  export { instance as MinesweeperSymbol } from './minesweeperSymbol.js';
package/dist/index.d.ts CHANGED
@@ -100,6 +100,7 @@ import DirectionLinkerSymbol from './data/symbols/directionLinkerSymbol.js';
100
100
  import FocusSymbol from './data/symbols/focusSymbol.js';
101
101
  import GalaxySymbol from './data/symbols/galaxySymbol.js';
102
102
  import HiddenSymbol from './data/symbols/hiddenSymbol.js';
103
+ import HouseSymbol from './data/symbols/houseSymbol.js';
103
104
  import { allSymbols } from './data/symbols/index.js';
104
105
  import LetterSymbol from './data/symbols/letterSymbol.js';
105
106
  import LotusSymbol from './data/symbols/lotusSymbol.js';
@@ -112,4 +113,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
112
113
  import TileData from './data/tile.js';
113
114
  import TileConnections from './data/tileConnections.js';
114
115
  import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
115
- export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
116
+ export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
package/dist/index.js CHANGED
@@ -103,6 +103,7 @@ import DirectionLinkerSymbol from './data/symbols/directionLinkerSymbol.js';
103
103
  import FocusSymbol from './data/symbols/focusSymbol.js';
104
104
  import GalaxySymbol from './data/symbols/galaxySymbol.js';
105
105
  import HiddenSymbol from './data/symbols/hiddenSymbol.js';
106
+ import HouseSymbol from './data/symbols/houseSymbol.js';
106
107
  import { allSymbols } from './data/symbols/index.js';
107
108
  import LetterSymbol from './data/symbols/letterSymbol.js';
108
109
  import LotusSymbol from './data/symbols/lotusSymbol.js';
@@ -115,4 +116,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
115
116
  import TileData from './data/tile.js';
116
117
  import TileConnections from './data/tileConnections.js';
117
118
  import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
118
- export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
119
+ export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",