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)
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) thing = touch() #Initialise count = smell() path = 0 #def TurnRobot(IsFruit, path): #if left_side() == "fruit": # turn(3) # elif right_side() == "fruit": # turn(1) # if IsFruit == False: # turn(-2) def MoveRobot(path): if smell() > 0: if left_side() == "fruit": turn(3) elif right_side() == "fruit": turn(1) move() path += 1
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) thing = touch() #Initialise count = smell() path = 0 #def TurnRobot(IsFruit, path): #if left_side() == "fruit": # turn(3) # elif right_side() == "fruit": # turn(1) # if IsFruit == False: # turn(-2) def MoveRobot(path): if smell() > 0: if left_side() == "fruit":
from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) print smell() #for i in range (0,100): #move() # Add your code here
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 move() turn() look() touch() smell() left_side() right_side()
import random from tealight.robot import (move, turn, look, touch, smell, left_side, right_side) n=0 while n<2000: n = n+1 if look() == 'fruit': move() elif right_side() == 'fruit': turn(1) while look() == 'fruit': move() elif left_side() == 'fruit': turn(1) while look() == 'fruit': move() elif smell() >= 1: i = random.randint (-1, 2) turn(i) move() else: i = random.randint (-1, 2) turn(i) move()
move () moved=moved +1 turn (1) if touch ()== "fruit": go() turn (1) if touch () == "fruit": for n in range (4): move() turn (1) if touch ()== "fruit": for n in range (8): move () turn (-1) while smell ()== "fruit": move () if touch ()== "wall": turn (1) if touch ()=="wall": go ()