Skip to content

Fix getHexagonRequiredNodeId2 formulas for even-k rings#589

Merged
chrxh merged 1 commit intofeatures/ConstructionSequencesfrom
copilot/fix-hexagon-required-node-id-algorithm
Apr 9, 2026
Merged

Fix getHexagonRequiredNodeId2 formulas for even-k rings#589
chrxh merged 1 commit intofeatures/ConstructionSequencesfrom
copilot/fix-hexagon-required-node-id-algorithm

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Two arithmetic bugs in ShapeGenerator::getHexagonRequiredNodeId2 produce wrong node IDs for rings with even k ≥ 4, breaking hexagon topology at larger sizes.

Changes

  • Side 3, even k: (pos - 2)((pos - 2) / 2) — missing halving caused values to decrease twice as fast as intended
  • Side 4, even k ≥ 4: 3*k*k - 6*k + 2 - pos3*k*k - 7*k + 6 - pos — wrong coefficients introduced an offset that grows with ring size
// Side 3, even k
-  return 3 * k * k - 6 * k + 3 - (pos - 2);
+  return 3 * k * k - 6 * k + 3 - ((pos - 2) / 2);

// Side 4, even k >= 4
-  return 3 * k * k - 6 * k + 2 - pos;
+  return 3 * k * k - 7 * k + 6 - pos;

Both bugs are latent for k=4 (only side 3 pos=2 is hit, where (pos-2)/2 == pos-2 == 0; side 4 formulas coincide when k=4) and first manifest at k=6. Verified against the full 169-value expected sequence and generateHexagon_61cells_withSeparation.

@chrxh chrxh marked this pull request as ready for review April 9, 2026 07:02
@chrxh chrxh merged commit 8676177 into features/ConstructionSequences Apr 9, 2026
@chrxh chrxh deleted the copilot/fix-hexagon-required-node-id-algorithm branch April 9, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants