Compare commits
2 Commits
53e3bf7fa4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73b49dd403 | ||
|
|
70b762b2ce |
@@ -3,7 +3,7 @@ tile_size_w = 48
|
|||||||
tile_size_h = 48
|
tile_size_h = 48
|
||||||
|
|
||||||
[map]
|
[map]
|
||||||
map_size_w = 20
|
map_size_w = 80
|
||||||
map_size_h = 20
|
map_size_h = 50
|
||||||
floor_char = '.'
|
floor_char = '.'
|
||||||
wall_char = '#'
|
wall_char = '#'
|
||||||
@@ -46,7 +46,8 @@ function CellularAutomata:update()
|
|||||||
for mx = 0, self.map_w - 1 do
|
for mx = 0, self.map_w - 1 do
|
||||||
for my = 0, self.map_h - 1 do
|
for my = 0, self.map_h - 1 do
|
||||||
local neighbors = self.get_neighbors(old_map, mx, my)
|
local neighbors = self.get_neighbors(old_map, mx, my)
|
||||||
local walls = 0
|
local expected_neighbors = 9
|
||||||
|
local walls = expected_neighbors - #neighbors
|
||||||
local required_walls = 5
|
local required_walls = 5
|
||||||
--print(old_map:is_wall(mx, my))
|
--print(old_map:is_wall(mx, my))
|
||||||
--print(new_map:is_wall(mx, my))
|
--print(new_map:is_wall(mx, my))
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ DrunkenWalk = {
|
|||||||
curr_y = 0,
|
curr_y = 0,
|
||||||
map_w = 0,
|
map_w = 0,
|
||||||
map_h = 0,
|
map_h = 0,
|
||||||
iterations = 30
|
iterations = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function DrunkenWalk:initialize(w, h)
|
function DrunkenWalk:initialize(w, h)
|
||||||
math.randomseed()
|
math.randomseed()
|
||||||
self.map_w = w
|
self.map_w = w
|
||||||
self.map_h = h
|
self.map_h = h
|
||||||
self.iterations = 30
|
self.iterations = 200
|
||||||
visualizer.map:fill(true)
|
visualizer.map:fill(true)
|
||||||
self.curr_x = math.random(0, w-1)
|
self.curr_x = math.random(0, w-1)
|
||||||
self.curr_y = math.random(0, h-1);
|
self.curr_y = math.random(0, h-1);
|
||||||
@@ -33,4 +33,4 @@ function DrunkenWalk:update()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
visualizer.algorithm_manager:register_algorithm("Drunken Walk", function (w, h) DrunkenWalk:initialize(w, h) end, function () return DrunkenWalk:update() end, 5)
|
visualizer.algorithm_manager:register_algorithm("Drunken Walk", function (w, h) DrunkenWalk:initialize(w, h) end, function () return DrunkenWalk:update() end, 60)
|
||||||
Reference in New Issue
Block a user