Skip to content

Commit

Permalink
DEBUG-free map & robot
Browse files Browse the repository at this point in the history
  • Loading branch information
JayTeeSF committed Nov 26, 2010
1 parent 5348488 commit 49e90f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lib/map.rb
Expand Up @@ -78,13 +78,16 @@ def draw_matrix(_matrix=nil, row=nil,col=nil, path_ary=[])
# puts "coord_path: #{coord_path.inspect} vs. path_ary: #{path_ary.inspect}" unless coord_path.empty?
# return unless @debug
if _matrix.nil?
puts "nil matrix"
# puts "nil matrix"
clear_matrix
_matrix = fill_matrix
elsif _matrix.empty? # someone else's matrix ?!
puts "empty matrix"
# puts "empty matrix"
_matrix = construct_matrix( _matrix ) # no fill-in, here
end
puts "no drawing today..."
return true

# puts "drawing: _matrix: #{_matrix.inspect}"

# deep-copy the array, before any (potential) modifications
Expand Down Expand Up @@ -607,7 +610,7 @@ def verify(path_ary=[], row=0, col=0)

# # if we made it through the folded matrix --then we're good!
# puts "recursive-verify!"
puts "!: #{start_row}/#{start_col}"
# puts "!: #{start_row}/#{start_col}"
#: #{path_ary.inspect}"
return recursive_verify(path_ary, start_row, start_col)
end
Expand Down
10 changes: 5 additions & 5 deletions lib/robot.rb
Expand Up @@ -462,7 +462,7 @@ def new_soln(time_of, result, all_size_configs)
# (3) verify path or continue our search
result = map.verify(current_path, row, col)
if result
puts "got result: #{current_path.inspect}"
# puts "got result: #{current_path.inspect}"
return current_path
end
end # unless BM
Expand Down Expand Up @@ -756,18 +756,18 @@ def single(time_of, result, all_size_configs)
end

def config(a_min=@pre_min,a_max=@max)
puts "ideal_range: #{ideal_range} ( a_max(#{a_max}), a_min * 2(#{2 * a_min}) and a_max * 2(#{2 * a_max})) (out of #{map.width})"
#puts "ideal_range: #{ideal_range} ( a_max(#{a_max}), a_min * 2(#{2 * a_min}) and a_max * 2(#{2 * a_max})) (out of #{map.width})"

total_range = diff(a_min,a_max)
puts "min: #{a_min} - max: #{a_max}; total_range: #{total_range}"
#puts "min: #{a_min} - max: #{a_max}; total_range: #{total_range}"
return [[a_min, a_max]] if total_range < 2 || total_range <= ideal_range
# || ideal_range < 2

ranges = []
r_min = a_min
r_max = r_min + ideal_range
while ((r_max <= a_max) && (r_min < a_max))
puts "adding: #{r_min}:#{r_max}"
# puts "adding: #{r_min}:#{r_max}"
ranges << [r_min,r_max]
r_min += ideal_range # + 1

Expand Down Expand Up @@ -1063,4 +1063,4 @@ def multi_p(time_of, result, all_size_configs)
result
end

end
end

0 comments on commit 49e90f4

Please sign in to comment.