From 1c6b6f7d87cf792136a1d9513e78f82d5dead584 Mon Sep 17 00:00:00 2001 From: Piotr Usewicz Date: Tue, 7 May 2024 07:55:03 +0200 Subject: [PATCH] Use cellid for comparison --- lib/wave_function_collapse/cell.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/wave_function_collapse/cell.rb b/lib/wave_function_collapse/cell.rb index 1e39b4d..99df4a3 100644 --- a/lib/wave_function_collapse/cell.rb +++ b/lib/wave_function_collapse/cell.rb @@ -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)