Skip to content

Commit

Permalink
Case is a 1.05 times faster
Browse files Browse the repository at this point in the history
Still within the margin of error.
  • Loading branch information
pusewicz committed May 6, 2024
1 parent 102a64e commit 77c8c64
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/wave_function_collapse/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ def evaluate_neighbor(source_cell, evaluation_direction)
while sci < scil
source_tile = source_tiles[sci]
sci += 1
source_edge_hash = source_tile.send(evaluation_direction)
source_edge_hash = case source_tile
when :up then source_tile.up
when :right then source_tile.right
when :down then source_tile.down
when :left then source_tile.left
end
nci = 0
ncil = neighbor_tiles.length

Expand All @@ -139,7 +144,12 @@ def evaluate_neighbor(source_cell, evaluation_direction)
nci += 1
next if new_tile_ids.has_key?(tile.tileid)

tile_edge_hash = tile.send(opposite_direction)
tile_edge_hash = case opposite_direction
when :up then tile.up
when :right then tile.right
when :down then tile.down
when :left then tile.left
end
if tile_edge_hash == source_edge_hash
new_tile_ids[tile.tileid] = true
new_tiles << tile
Expand Down

0 comments on commit 77c8c64

Please sign in to comment.