Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Autor: Andrei Petrea
- def turn_right():
- repeat(turn_left,3)
- def pickBeepers():
- tempBeepers = 0
- while on_beeper():
- pick_beeper()
- tempBeepers = tempBeepers+1
- return tempBeepers
- def linea(gir, z, pos, enRaya, xBeep):
- acPos = 0
- while front_is_clear():
- move()
- if(on_beeper()):
- acPos = pickBeepers()
- if(xBeep > 0):
- if acPos == pos:
- xBeep = xBeep + 1
- if(acPos != pos):
- xBeep = 1
- if((xBeep) == 3):
- enRaya += 1
- xBeep = 0
- acPos = 0
- pos = acPos
- acPos = 0
- if (gir):
- if (z == 0):
- turn_left()
- z = 1
- elif (z == 1):
- turn_right()
- z = 0
- gir = False
- else:
- #0 = IZQ
- #1 = DERECHA
- if not front_is_clear():
- if (isFinal(z)):
- print "En Raya: "+str(enRaya)
- turn_off()
- if (z ==0):
- turn_left()
- gir = True
- elif (z==1):
- turn_right()
- gir = True
- def isFinal(n):
- #0 = IZQ
- #1 = DERECHA
- if (n == 0):
- turn_left()
- if not front_is_clear():
- return True
- turn_right()
- elif (n == 1):
- turn_right()
- if not front_is_clear():
- return True
- turn_left()
- return False
- #g = False
- #z1 = 0
- #pos = 0
- #xBeep = 0
- #yBeep = 0
- #zBeep = 0
- #enRaya = 0
- #while front_is_clear(): #Si quieres añadele esto pero no es necesario
- #linea(g, z1, pos, enRaya, xBeep, yBeep, zBeep)
- linea(False, 0, 0, 0, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement