Skip to content

[18India] Fix yellow tile lay blocked through red city (rule 8.4.1.1)#12711

Open
ddaybell wants to merge 1 commit into
tobymao:masterfrom
ddaybell:18india-fix-lay-through-red-city
Open

[18India] Fix yellow tile lay blocked through red city (rule 8.4.1.1)#12711
ddaybell wants to merge 1 commit into
tobymao:masterfrom
ddaybell:18india-fix-lay-through-red-city

Conversation

@ddaybell

@ddaybell ddaybell commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Disables the simple-case shortcut in calculate_railhead_hexes that returned early when the last laid tile had 1-2 direct white neighbors
  • The shortcut excluded red-hex neighbors from empty_neighbors, causing it to miss white hexes reachable through adjacent red cities (e.g. E22/triple-dit via Mumbai D23 - rule 8.4.1.1)
  • The full walk already handles the 1-2 neighbor case correctly; the shortcut's performance benefit was marginal (result is cached per track action)
  • The shortcut code is preserved as a commented block with instructions for restoring it if a red-hex guard is added

Fixes #11780

Test plan

  • 18India fixtures: 43/43 pass
  • Full suite: 7429 examples, 0 failures
  • Manual: WIP at E24 (Pune) can lay yellow tile at E24 and then continue to E22 (triple-dit) via Mumbai D23 red city

Disable the simple-case shortcut in calculate_railhead_hexes that was
returning early when the last laid tile had 1-2 direct white neighbors.
The shortcut excluded red hex neighbors from empty_neighbors, causing it
to miss white hexes reachable through adjacent red cities (e.g. E22/triple-dit
via Mumbai D23). The full walk already handles the common 1-2 neighbor case
correctly, so the shortcut's benefit was marginal.

Fixes tobymao#11780

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
# Performance shortcut: if the last tile has 1-2 direct white neighbors (and is not a
# triple-town/OO tile), return them immediately without a full walk. DISABLED because
# it misses white hexes reachable through adjacent red cities (rule 8.4.1.1 — e.g.
# E22/triple-dit via Mumbai). To restore, add a guard skipping when any exit is red:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot the commented away code be removed? Line 27-30 might be enough.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Replace commented code with SHA reference

Instead of keeping dead code in the file, reference the commit where it existed:

# OPTIMIZATION DISABLED: This performance shortcut was removed in <SHA> because it
# missed white hexes reachable through red cities (rule 8.4.1.1). The full walk
# handles all cases correctly. To restore: add guard for red-hex neighbors and see
# commit <SHA> for the original implementation.

Benefits:

  • ✅ No commented-out code smell
  • ✅ No git grep noise
  • ✅ Code still recoverable via git show <SHA>
  • ✅ Clearer intent

perwestling
perwestling previously approved these changes Jun 14, 2026

@perwestling perwestling left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review: #12711 - [18India] Fix yellow tile lay blocked through red city (rule 8.4.1.1)

Reviewed with AI assistance by Mistral Vibe


✅ Strengths

  • Fixes documented bug (#11780)
  • Minimal, surgical change
  • All tests pass (18India: 43/43, Full suite: 7429/7429)
  • Clear PR description

💡 Suggestions

  • Consider replacing the commented-out optimization with a SHA reference to the original implementation
  • Or remove entirely and document in a separate OPTIMIZATIONS.md if you want to keep it for future reference

❓ Questions

  • Have you considered removing the shortcut code entirely rather than commenting it out?

✅ Verdict: Approve

The bug fix is correct and ready. The commented-out code is the only concern, but it's not blocking.

@perwestling perwestling dismissed their stale review June 15, 2026 19:32

Remove AI assisted approval.

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.

18India - won't allow yellow lay through red city

2 participants