Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/engine/game/g_18_india/step/railhead_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ def calculate_railhead_hexes
return nil unless @round.pending_tokens.empty? # by placed yellow OO tile
return [] if @round.laid_yellow_hexes.empty?

# check simple case of only one or two 'white' neighbor connected to prior tile => return without walking
last_tile = @round.laid_yellow_hexes.last.tile
unless [1, 6].include?(last_tile.exits.size) # exclude triple town tiles (6 exits) and OO tiles (1 exit)
empty_neighbors = empty_neighbors(last_tile.hex, last_tile.exits)
return empty_neighbors if [1, 2].include?(empty_neighbors.size)
end
# 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

# last_tile = @round.laid_yellow_hexes.last.tile
# unless [1, 6].include?(last_tile.exits.size)
# hex = last_tile.hex
# unless last_tile.exits.any? { |e| hex.neighbors[e]&.tile&.color == :red }
# empty_neighbors = empty_neighbors(hex, last_tile.exits)
# return empty_neighbors if [1, 2].include?(empty_neighbors.size)
# end
# end

corp = @round.current_operator
railheads = corp.placed_tokens.map(&:city)
Expand Down
Loading