def go(): while True: if left_side() == False: turn(1) if right_side() == False: turn(-1) move()
def main(): while True: while True: move() if right_side()=='wall' and touch()=='wall': turn(-1) elif left_side()=='wall' and touch()=='wall': turn(1)
def left_way(): while True: move() if (left_side() != "wall"): turn(-1) elif (touch() == "wall" and right_side() != "wall"): turn(1) elif (touch() == "wall"): turn(2)
def branch(dir): turn(dir) if touch() == 'fruit': while touch() == 'fruit': move() elif left_side() == 'fruit': branch(-1) elif right_side() == 'fruit': branch(1)
def find(): i=0 while touch()!='fruit' and left_side()!='fruit' and right_side()!='fruit': if look()=='fruit': i=i+1 print i move() else: turn(-1) move()
def test_way(): while True: if (find_fruit() == False): if (touch() != "wall"): a=1 elif (left_side() != "wall"): turn(-1) elif (right_side() != "wall"): turn(1) elif (touch() == "wall"): turn(2) move()
def trythisway(): move() if left_side()=='fruit': return -1 elif right_side()=='fruit': return 1 elif str(look())=='fruit': move() return(2) else: turn(2) move() return(0)
def go(dir): while touch() != 'fruit': move() while touch() == 'fruit': move() if dir == 1: while left_side() == 'fruit': move() if dir == -1: while right_side() == 'fruit': move() dir =dir*-1 turner(dir)
def search(): while True: if touch() =="fruit": move() elif right_side() == "fruit": turn(1) move() elif left_side() == "fruit": turn(-1) move() elif look() == "fruit": move() else: turn(1)
def go(): while touch() == "fruit": move() if right_side() == "fruit": turn(1) go() if left_side() == "fruit": turn(3) go() if left_side() != "fruit" and right_side != "fruit": move() go()
def go(): steps = 0 while touch() == "fruit": move() steps += 1 if left_side() == "fruit": turn(-1) go() turn(-1) if right_side() == "fruit": turn(1) go() turn(1) turn(2) for i in range(steps): move()
def MoveRobot(): count = smell() while count > 0: if left_side() == "fruit": turn(-1) elif right_side() == "fruit": turn(1) move() count = smell() print(count) else: turn(2) move() MoveRobot()
def MoveRobot(path): if smell() > 0: if left_side() == "fruit": turn(3) elif right_side() == "fruit": turn(1) move() path += 1 else: turn(-2) for i in range(0, path): move() path = 0 MoveRobot(path)
def lookAndMove(): if touch() == 'fruit': return 'yes' if right_side() == 'fruit': turn(1) move() return 'yes' if left_side() == 'fruit': turn(-1) move() return 'yes' t = 0 while t<4: turn(1) if touch() == 'fruit': return 'yes' t = t+1 move() start()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here move() move() move() n = 1 while n < 2000: n = n + 1 print left_side() if touch() == 'fruit': move() elif right_side() == 'fruit': turn(1) move() elif left_side() == 'fruit': turn(-1) move() elif look() == 'fruit': move() print right_side() else: turn(1) move() move()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here while touch() == 'fruit': move() for x in range(1, 9): if (x % 2 != 0) and (right_side() == 'fruit'): turn(1) while right_side() != 'fruit': move() else: turn(1) while touch() == 'fruit': move() elif (x % 2 == 0) and (left_side() == 'fruit'): turn(-1) while left_side() != 'fruit': move() else: turn(-1) while touch() == 'fruit': move() turn(-1) for y in range(0, 4): for x in range(0, 31): move() turn(-1) for x in range(0, 4): move()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) while 1: if left_side() != 'wall': turn(-1) move() elif right_side() != 'wall': turn(1) move() else: turn(2) move()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here n = 1 while n < 2000: n = n + 1 if touch() == None: move() print left_side() elif left_side() == 'wall': turn(1) move() elif right_side() == 'wall': turn(-1) move() print left_side() elif touch() == 'wall': turn(-1)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here if touch() == 'water': move() if right_side() == 'water': move()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) while True: for n in range(-1, 2, 2): print n while look() == 'fruit' or left_side() == 'fruit' or right_side( ) == 'fruit': move() turn(n) move() turn(n)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) while touch() != 'wall': move() if touch() == 'wall': if left_side() == 'wall': turn(1) if left_side() != 'wall': turn(-1) print left_side() print right_side()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) collision_1 = False collision_2=False tryright=False tryleft=False while True: move() if left_side() != "wall" and right_side()=="wall": turn(-1) elif right_side() != "wall" and left_side()=="wall": turn(1) elif right_side() != "wall" and left_side() != "wall": if tryright==False: turn(1) tryright=True elif tryleft==False: turn(-1) tryleft=True else: turn(2) tryright=False tryleft=False
from tealight.robot import move, turn, look, touch, smell, left_side, right_side move() turn() look() touch() smell() left_side() right_side()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here while touch() == 'fruit': move() for x in range(1,9): if (x%2 != 0) and (right_side() == 'fruit'): turn(1) while right_side() != 'fruit': move() else: turn(1) while touch() == 'fruit': move() elif (x%2 == 0) and (left_side() == 'fruit'): turn(-1) while left_side() != 'fruit': move() else: turn(-1) while touch() == 'fruit': move() turn(-1) for y in range(0,4):
def go(): moveBy(3) turn(-1) while True: if right_side() or left_side(): move()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # This is a fairly useless algorithm! while True: move() if touch() == "wall": turn(2) elif left_side() == "fruit": turn(-1) elif right_side() == "fruit": turn(1)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) collision_1 = False collision_2 = False tryright = False tryleft = False while True: move() if left_side() != "wall" and right_side() == "wall": turn(-1) elif right_side() != "wall" and left_side() == "wall": turn(1) elif right_side() != "wall" and left_side() != "wall": if tryright == False: turn(1) tryright = True elif tryleft == False: turn(-1) tryleft = True else: turn(2) tryright = False tryleft = False if touch() == "wall" and collision_1 == False: turn(1) collision_1 = True elif touch() == "wall" and collision_1 == True: turn(2) collision_1 = False collision_2 = True
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here while True: move() if touch()=='wall': if left_side()==None: turn(-1) elif right_side()==None: turn(1) else: turn(2) elif left_side()==None: turn(-1)
# This is a fairly useless algorithm! x = 0 dir = 1 def super_move(): if touch() != "wall": move() while True: if touch() == "fruit": x = 0 super_move() elif right_side() == "fruit": x = 0 turn(1) super_move() elif left_side() == "fruit": x = 0 turn(3) super_move() elif look() == "fruit": x = 0 super_move() elif x < 3: x = x + 1 turn(1) elif touch() == "wall": turn(1)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) thing = look() #Initialise count = smell() while count > 0: if touch() == "fruit" and (right_side() != "fruit" and left_side() != "fruit"): move() elif left_side() == "fruit": turn(3) elif right_side() == "fruit": turn(1) move() thing = look() count = smell() #thing = look() #print(thing)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) distance = 10 longest_d = 0 #for n in range(0, distance): while touch() == 'fruit': move() if touch() != 'fruit': if longest_d == 0: longest_d = moves if left_side() == 'fruit' and longest_d: turn(-1) elif right_side() == 'fruit': turn(1) if right_side() == 'fruit': turn(1) elif left_side() == 'fruit': turn(-1)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here i = 0 while i < 400: if touch() == 'fruit': move() elif right_side() == 'fruit': turn(1) elif left_side() == 'fruit': turn(-1) elif touch() != 'fruit' and left_side() != 'fruit' and right_side() != 'fruit': move() for i in range(0, 4): turn(-1) if touch() == 'fruit' or left_side() == 'fruit' or right_side() == 'fruit': break i += 1
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) while touch() == 'fruit': move() if left_side() == 'fruit': dir = 1 turn(dir) dir = -dir if right_side() == 'fruit': dir = 1 turn(dir) dir = -dir else: dir = 1 turn(dir) dir = -dir
left_side, right_side) # Add your code here move() move() move() n=1 while n < 2000: n = n + 1 print left_side() if touch() == 'fruit': move() elif right_side() == 'fruit': turn(1) move() elif left_side() == 'fruit': turn(-1) move() elif look() == 'fruit': move() print right_side() else: turn(1) move() move()
move() def traverse(): d = trythisway() if d<>0: turn(d) move() turn(d*-1) else: e = trythatway() if e<>0: turn(e) move() ''' turn(e*-1) ''' else: if str(look())=='fruit': move() find() for i in range(0,400): a=str(touch()) l=str(left_side()) r=str(right_side()) print look() print touch() traverse()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here while True: move() if(left_side() == "fruit"): turn(-1) elif(right_side() == "fruit"): turn(1) elif (look() == "fruit"): while (look() == "fruit"): move() if(left_side() == None): turn(-1) move() if(touch() == "wall"): if(left_side() != "wall"): turn(-1) move() elif(right_side() != "wall"): turn(1) else: turn(2)
right_side) # Add your code here while True: move() # if(left_side() == "fruit"): # turn(-1) # elif(right_side() == "fruit"): # turn(1) # elif (look() == "fruit"): # while (look() == "fruit"): # move() for i in range(0,4): while(look() == "fruit"): move() turn(1) #if(left_side() == None): # turn(-1) # move() if(touch() == "wall"): if(left_side() != "wall"): turn(-1) move() elif(right_side() != "wall"): turn(1) move() else: turn(2) move()