def scan(): i = 0 while look()=='wall' and i<4: turn(1) i=i+1 if look()=='wall': return 0 else: return 1
def find_fruit(): for i in range(1,4): if (look() == "fruit"): move() return True else: turn(1) return False
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 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 Movement(): FruitPresence = touch() while (FruitPresence == 'fruit'): move() FruitPresence = touch() NewSource = look() if NewSource == 'fruit': Movement() if FruitPresence != 'fruit': turn(-1) Movement()
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 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()
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) turncounter = 0 while True: print "breaking" if look() =='wall': print "wall" turn(1) turncounter += 1 if turncounter == 4: turncounter = 0 while touch() == 'wall': turn(1) move() if look() =='fruit': turncounter = 0 while look() =="fruit": move() break
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)
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) else: x = 0 super_move() turn(1) super_move()
left_side, right_side) wallcount = 0 def MoveSearch(thing): global wallcount wallcount = 0 distance = 1 i = 0 while i < distance: if touch() == thing: distance += 1 i += 1 if i < distance: move() z = 0 while z < 512: z+=1 if touch() == 'fruit': MoveSearch('fruit') elif left_side() == 'fruit': turn(-1) elif right_side() == 'fruit': turn(1) elif look() == 'wall' and wallcount < 4: turn(1) wallcount += 1 elif look() == 'fruit': MoveSearch(None)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here i = 400 for i in range(400): if look() == "flower": move()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) while True: if look() == 'fruit': move() elif right_side() == 'fruit': turn(1) while look() == 'fruit': move() elif left_side() == 'fruit': turn(1) while look() == 'fruit': move() else: turn(1) move()
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() 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)
uturn() flip=(flip + 1)%2 a=str(touch()) if a=='fruit': lasta='fruit' elif l=='fruit': if r=='fruit': turn(flip*2-1) flip=(flip + 1)%2 else: turn(-1) elif r=='fruit': turn(1) else: turn(1) if str(look())=='fruit': move() else: turn(2) if str(look())=='fruit': move() else: turn(1) for i in range(0,5): move() move() def uturn(): print 'u-turn' print flip if l=='fruit':
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here while touch() != 'wall': look() left_side() move(1) if touch() == 'wall': turn(-1) if touch () == 'wall': turn(-2) if touch () == 'wall': turn(1)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) # Add your code here 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) # Add your code here print look()
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) turncounter = 0 while True: print "breaking" if look() == 'wall': print "wall" turn(1) turncounter += 1 if turncounter == 4: turncounter = 0 while touch() == 'wall': turn(1) move() if look() == 'fruit': turncounter = 0 while look() == "fruit": move() break
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) for i in range (0,700): if look()=='fruit': while touch()!= 'fruit': move() move() else: turn(1) # Add your code here
def fruit(): while look() == 'fruit': _move(1) _turn() fruit()
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) while True: i=0 if look()=='fruit': move() elif right_side()=='fruit': turn(1) while look()=='fruit': move() elif left_side()=='fruit': turn(2) while look()=='fruit': move() else: while i==0: turn(1) move() if look()=='fruit': i=1
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) from random import random # This is a fairly useless algorithm! dir = 1 while True: move() i=0 while (smell() and look() != 'fruit' and i<4): turn(1) i=i+1 if smell()==0 and look() != 'fruit': steps = int(3*random()) turn(steps) for i in range(1,5): move()
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)
from tealight.robot import move, turn, look, touch, smell, left_side, right_side # Add your code here turncounter = 0 while True: print "breaking" if look() == "wall": print "wall" turn(1) turncounter += 1 if turncounter == 4: turncounter = 0 while touch() == "wall": turn(1) move() if look() == "fruit": turncounter = 0 while look() == "fruit": move() break