Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement