@logic-pad/core 0.11.0 → 0.11.4

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.
@@ -63,6 +63,12 @@ export default class GridZones {
63
63
  edge.y2 >= height + 1) {
64
64
  continue;
65
65
  }
66
+ if ((edge.x1 < 0 && edge.x2 < 0) ||
67
+ (edge.y1 < 0 && edge.y2 < 0) ||
68
+ (edge.x1 >= width && edge.x2 >= width) ||
69
+ (edge.y1 >= height && edge.y2 >= height)) {
70
+ continue;
71
+ }
66
72
  if (Math.abs(edge.x1 - edge.x2) + Math.abs(edge.y1 - edge.y2) !== 1) {
67
73
  continue;
68
74
  }
@@ -64,13 +64,26 @@ class BanPatternRule extends Rule {
64
64
  }
65
65
  validateGrid(grid) {
66
66
  for (const pattern of this.cache) {
67
- for (let y = 0; y <= grid.height - 1; y++) {
68
- for (let x = 0; x <= grid.width - 1; x++) {
67
+ let startX, startY, endX, endY;
68
+ if (grid.wrapAround.value) {
69
+ startX = -pattern.width;
70
+ startY = -pattern.height;
71
+ endX = grid.width - 1;
72
+ endY = grid.height - 1;
73
+ }
74
+ else {
75
+ startX = 0;
76
+ startY = 0;
77
+ endX = grid.width - pattern.width;
78
+ endY = grid.height - pattern.height;
79
+ }
80
+ for (let y = startY; y <= endY; y++) {
81
+ for (let x = startX; x <= endX; x++) {
69
82
  let match = true;
70
83
  const visited = [];
71
84
  for (const tile of pattern.elements) {
72
85
  const pos = grid.toArrayCoordinates(x + tile.x, y + tile.y);
73
- if (grid.wrapAround.value && // optimization: not need to check visited if wrapAround is disabled
86
+ if (grid.wrapAround.value && // optimization: no need to check visited if wrapAround is disabled
74
87
  visited.some(p => p.x === pos.x && p.y === pos.y)) {
75
88
  match = false;
76
89
  break;
@@ -200,7 +200,12 @@ Object.defineProperty(MusicGridRule, "CONFIGS", {
200
200
  {
201
201
  type: ConfigType.NullableGrid,
202
202
  default: null,
203
- nonNullDefault: GridData.create(5, 4).addRule(new MusicGridRule([new ControlLine(0, 120, false, false, DEFAULT_SCALLE)], null)),
203
+ nonNullDefault: GridData.create([
204
+ 'wwwww',
205
+ 'wwwww',
206
+ 'wwwww',
207
+ 'wwwww',
208
+ ]).addRule(new MusicGridRule([new ControlLine(0, 120, false, false, DEFAULT_SCALLE)], null)),
204
209
  field: 'track',
205
210
  description: 'Track',
206
211
  configurable: true,
@@ -3,6 +3,7 @@ import { instance as lyingSymbolInstance } from '../../rules/lyingSymbolRule.js'
3
3
  import { instance as offByXInstance } from '../../rules/offByXRule.js';
4
4
  import { instance as lotusInstance } from '../../symbols/lotusSymbol.js';
5
5
  import { instance as galaxyInstance } from '../../symbols/galaxySymbol.js';
6
+ import { instance as wrapAroundInstance } from '../../rules/wrapAroundRule.js';
6
7
  import { allSolvers } from '../allSolvers.js';
7
8
  import Solver from '../solver.js';
8
9
  import UndercluedRule from '../../rules/undercluedRule.js';
@@ -176,6 +177,7 @@ Object.defineProperty(AutoSolver, "nonAdditiveInstructions", {
176
177
  value: new Set([
177
178
  offByXInstance.id,
178
179
  lyingSymbolInstance.id,
180
+ wrapAroundInstance.id,
179
181
  ])
180
182
  });
181
183
  export default AutoSolver;
@@ -126,6 +126,14 @@ class DirectionLinkerSymbol extends Symbol {
126
126
  color1: baseColor1,
127
127
  color2: baseColor2,
128
128
  };
129
+ const newColor1 = getColor(newArrTurtle.pos1, grid);
130
+ const newColor2 = getColor(newArrTurtle.pos2, grid);
131
+ if (newColor1 !== baseColor1 &&
132
+ newColor2 !== baseColor2 &&
133
+ newColor1 !== Color.Gray &&
134
+ newColor2 !== Color.Gray) {
135
+ continue;
136
+ }
129
137
  if (checkedCouples.some(({ pos1, pos2 }) => pos1.x === newArrTurtle.pos1.x &&
130
138
  pos1.y === newArrTurtle.pos1.y &&
131
139
  pos2.x === newArrTurtle.pos2.x &&
@@ -1,4 +1,5 @@
1
1
  import { ConfigType } from '../config.js';
2
+ import { move } from '../dataHelper.js';
2
3
  import GridData from '../grid.js';
3
4
  import { Color, ORIENTATIONS, Orientation, State, orientationToggle, } from '../primitives.js';
4
5
  import MultiEntrySymbol from './multiEntrySymbol.js';
@@ -71,11 +72,21 @@ class MyopiaSymbol extends MultiEntrySymbol {
71
72
  };
72
73
  const pos = { x: this.x, y: this.y };
73
74
  allDirections.forEach(direction => {
74
- grid.iterateDirectionAll(pos, direction, t => !t.exists || t.color === tile.color, () => {
75
+ let stopped = false;
76
+ grid.iterateDirectionAll(move(pos, direction), direction, t => {
77
+ if (!t.exists)
78
+ return true;
79
+ if (t.color === tile.color)
80
+ return true;
81
+ stopped = true;
82
+ return false;
83
+ }, () => {
75
84
  map[direction].min++;
76
85
  });
77
- let stopped = false;
78
- grid.iterateDirectionAll(pos, direction, t => {
86
+ if (!stopped && map[direction].min === 0)
87
+ map[direction].min = Number.MAX_SAFE_INTEGER;
88
+ stopped = false;
89
+ grid.iterateDirectionAll(move(pos, direction), direction, t => {
79
90
  if (!t.exists)
80
91
  return true;
81
92
  if (t.color === tile.color || t.color === Color.Gray)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.11.0",
3
+ "version": "0.11.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -58,6 +58,7 @@
58
58
  "events": "^3.3.0",
59
59
  "grilops": "^0.1.2",
60
60
  "lodash": "^4.17.21",
61
+ "logic-pad-solver-core": "^0.1.2",
61
62
  "z3-solver": "^4.13.0",
62
63
  "zod": "^3.24.1"
63
64
  },