Skip to content

Commit

Permalink
Use cellid for comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
pusewicz committed May 7, 2024
1 parent 5d47977 commit 1c6b6f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/wave_function_collapse/cell.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
module WaveFunctionCollapse
class Cell
attr_reader :tiles
@@cellid = 0
attr_reader :tiles, :cellid
attr_accessor :collapsed, :entropy, :x, :y
alias_method :collapsed?, :collapsed

def initialize(x, y, tiles)
@cellid = @@cellid
@collapsed = tiles.size == 1
@entropy = tiles.size
@tiles = tiles
@neighbors = {}
@x = x
@y = y
@@cellid += 1
end

def ==(other)
@x == other.x && @y == other.y
@cellid == other.cellid
end

def tiles=(new_tiles)
Expand Down

0 comments on commit 1c6b6f7

Please sign in to comment.