-
-
Save anonymous/df9725dee053c5dbc6d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def open (file) | |
line = file.gets; | |
opencells = 0; | |
puts "this is reached" | |
puts "#{opencells}"; | |
if line == nil then return end | |
# read additional lines | |
while line = file.gets do | |
# begins with "path", must be path specification | |
if line[0...4] == "path" | |
p, name, x, y, ds = line.split(/\s/) | |
# otherwise must be cell specification (since maze spec must be valid) | |
else | |
x, y, ds, w = line.split(/\s/,4) | |
#puts "cell spec: coordinates (#{x},#{y}) with dirs #{ds}" | |
#check if all four walls are open | |
check = true; | |
if ds.length == 4 | |
4.times do |i| | |
case ds[i] | |
when "u", "d", "l", "r" | |
check = true; | |
else | |
check = false; | |
end | |
if check == false | |
break; | |
end | |
end | |
end | |
if check == true | |
opencells = opencells + 1; | |
end | |
end | |
end | |
puts "#{opencells}"; | |
end | |
open(maze_file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment