Skip to content

Commit

Permalink
Linter updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pusewicz committed May 6, 2024
1 parent 0c41a58 commit eea1096
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/wave_function_collapse/cell.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module WaveFunctionCollapse
class Cell
attr_accessor :collapsed, :entropy, :tiles, :x, :y
attr_reader :tiles
attr_accessor :collapsed, :entropy, :x, :y
alias_method :collapsed?, :collapsed

def initialize(x, y, tiles)
Expand Down
4 changes: 2 additions & 2 deletions lib/wave_function_collapse/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ def draw_map
entropy,
x * @tile_width + (@tile_width / 2),
y * @tile_height + (@tile_height / 2),
ZOrder::Map, 0.5, 0.5, 1, 1, color
ZOrder::MAP, 0.5, 0.5, 1, 1, color
)
end

next unless tile

image = @tiles[tile.tileid]
image.draw(x * @tile_width, y * @tile_height, ZOrder::Map)
image.draw(x * @tile_width, y * @tile_height, ZOrder::MAP)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/wave_function_collapse/z_order.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module WaveFunctionCollapse
module ZOrder
Map, UI = *0..1
MAP, UI = *0..1
end
end
6 changes: 2 additions & 4 deletions test/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
require "json"
require "wave_function_collapse"

include WaveFunctionCollapse

json = JSON.load_file!("assets/map.tsj")
tiles =
json["wangsets"].last["wangtiles"].map do |tile|
prob = json["tiles"]&.find { |t| t["id"] == tile["tileid"] }&.fetch("probability")
Tile.new(
WaveFunctionCollapse::Tile.new(
tileid: tile["tileid"],
wangid: tile["wangid"],
probability: prob
)
end

model = Model.new(tiles, 20, 20)
model = WaveFunctionCollapse::Model.new(tiles, 20, 20)

puts RUBY_DESCRIPTION
puts "Running benchmark for Model(grid=#{model.width}x#{model.height} entropy=#{model.max_entropy})..."
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "wave_function_collapse"
require "minitest/autorun"

Minitest::Test.send(:include, WaveFunctionCollapse)
2 changes: 0 additions & 2 deletions test/test_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
require "test_helper"

class TestModel < Minitest::Test
include WaveFunctionCollapse

def test_initialize
tiles = [
Tile.new(tileid: 0, wangid: [0, 0, 0, 0, 0, 0, 0, 0]),
Expand Down

0 comments on commit eea1096

Please sign in to comment.