|
@@ -178,32 +178,43 @@ end
|
|
|
def decide()
|
|
def decide()
|
|
|
|
|
|
|
|
lastdirection = $direction
|
|
lastdirection = $direction
|
|
|
|
|
+ # check area front
|
|
|
|
|
+ front = check_area("front")
|
|
|
# check area left
|
|
# check area left
|
|
|
left = check_area("left")
|
|
left = check_area("left")
|
|
|
# check area right
|
|
# check area right
|
|
|
right = check_area("right")
|
|
right = check_area("right")
|
|
|
|
|
|
|
|
- if check_front > -1 && !$dead.include?(check_front) || check_area("front") < 10
|
|
|
|
|
-
|
|
|
|
|
- if left > right
|
|
|
|
|
- $direction = turn_direction("left")
|
|
|
|
|
- else
|
|
|
|
|
- if left == right
|
|
|
|
|
- case $lastturn
|
|
|
|
|
- when "left"
|
|
|
|
|
- $direction = turn_direction("right")
|
|
|
|
|
- $lastturn = "right"
|
|
|
|
|
- when "right"
|
|
|
|
|
- $direction = turn_direction("left")
|
|
|
|
|
- $lastturn = "left"
|
|
|
|
|
- end
|
|
|
|
|
- else
|
|
|
|
|
- $direction = turn_direction("right")
|
|
|
|
|
- end
|
|
|
|
|
|
|
+ if left > front && left > right
|
|
|
|
|
+ puts "#{left} > #{front} && #{left} > #{right} -> left"
|
|
|
|
|
+ $direction = turn_direction("left")
|
|
|
|
|
+ else
|
|
|
|
|
+ if right > front && right > left
|
|
|
|
|
+ puts "#{right} > #{front} && #{right} > #{left} -> right"
|
|
|
|
|
+ $direction = turn_direction("right")
|
|
|
end
|
|
end
|
|
|
-
|
|
|
|
|
- puts "#{left} > #{right}: turned #{$direction}"
|
|
|
|
|
end
|
|
end
|
|
|
|
|
+ # if check_front > -1 && !$dead.include?(check_front) || check_area("front") < 10
|
|
|
|
|
+ #
|
|
|
|
|
+ # if left > right
|
|
|
|
|
+ # $direction = turn_direction("left")
|
|
|
|
|
+ # else
|
|
|
|
|
+ # if left == right
|
|
|
|
|
+ # case $lastturn
|
|
|
|
|
+ # when "left"
|
|
|
|
|
+ # $direction = turn_direction("right")
|
|
|
|
|
+ # $lastturn = "right"
|
|
|
|
|
+ # when "right"
|
|
|
|
|
+ # $direction = turn_direction("left")
|
|
|
|
|
+ # $lastturn = "left"
|
|
|
|
|
+ # end
|
|
|
|
|
+ # else
|
|
|
|
|
+ # $direction = turn_direction("right")
|
|
|
|
|
+ # end
|
|
|
|
|
+ # end
|
|
|
|
|
+ #
|
|
|
|
|
+ # puts "#{left} > #{right}: turned #{$direction}"
|
|
|
|
|
+ # end
|
|
|
# $direction = new_direction()
|
|
# $direction = new_direction()
|
|
|
# if $tries > 4
|
|
# if $tries > 4
|
|
|
# break
|
|
# break
|