Selaa lähdekoodia

zig zag flood

Dorian Snowball 2 vuotta sitten
vanhempi
sitoutus
6aca9c803b
2 muutettua tiedostoa jossa 31 lisäystä ja 20 poistoa
  1. 1 1
      config.store
  2. 30 19
      lib/tron.rb

+ 1 - 1
config.store

@@ -3,4 +3,4 @@ name: tron.rb
 password: ForKarl!
 host: gpn-tron.duckdns.org
 port: 4000
-lookahead: 10
+lookahead: 25

+ 30 - 19
lib/tron.rb

@@ -178,32 +178,43 @@ end
 def decide()
 
   lastdirection = $direction
+  # check area front
+  front = check_area("front")
   # check area left
   left = check_area("left")
   # 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
-
-    puts "#{left} > #{right}: turned #{$direction}"
   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()
   #   if $tries > 4
   #     break