Advertisement
joaquinzc

xDDDDDDDDDDD

Feb 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.84 KB | None | 0 0
  1. #Autor: Andrei Petrea
  2. def turn_right():
  3.     repeat(turn_left,3)
  4. def pickBeepers():
  5.     tempBeepers = 0
  6.     while on_beeper():
  7.         pick_beeper()
  8.         tempBeepers = tempBeepers+1
  9.     return tempBeepers
  10. def linea(gir, z, pos, enRaya, xBeep):
  11.     acPos = 0
  12.     while front_is_clear():
  13.         move()
  14.         if(on_beeper()):
  15.             acPos = pickBeepers()
  16.             if(xBeep > 0):
  17.                 if acPos == pos:
  18.                     xBeep = xBeep + 1
  19.            
  20.             if(acPos != pos):
  21.                 xBeep = 1
  22.            
  23.             if((xBeep) == 3):
  24.                 enRaya += 1
  25.                 xBeep = 0
  26.                 acPos = 0
  27.        
  28.         pos = acPos
  29.         acPos = 0
  30.        
  31.         if (gir):
  32.             if (z == 0):
  33.                 turn_left()
  34.                 z = 1
  35.             elif (z == 1):
  36.                 turn_right()
  37.                 z = 0
  38.             gir = False
  39.         else:
  40.             #0 = IZQ
  41.             #1 = DERECHA
  42.             if not front_is_clear():
  43.                 if (isFinal(z)):
  44.                     print "En Raya: "+str(enRaya)
  45.                     turn_off()
  46.                 if (z ==0):
  47.                     turn_left()
  48.                     gir = True
  49.                 elif (z==1):
  50.                     turn_right()
  51.                     gir = True
  52. def isFinal(n):
  53.     #0 = IZQ
  54.     #1 = DERECHA
  55.     if (n == 0):
  56.         turn_left()
  57.         if not front_is_clear():
  58.             return True
  59.         turn_right()
  60.     elif (n == 1):
  61.         turn_right()
  62.         if not front_is_clear():
  63.             return True
  64.         turn_left()
  65.     return False
  66. #g = False
  67. #z1 = 0
  68. #pos = 0
  69. #xBeep = 0
  70. #yBeep = 0
  71. #zBeep = 0
  72. #enRaya = 0
  73. #while front_is_clear(): #Si quieres añadele esto pero no es necesario
  74. #linea(g, z1, pos, enRaya, xBeep, yBeep, zBeep)
  75. linea(False, 0, 0, 0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement