Ejemplo n.º 1
0
def scan():
  i = 0
  while look()=='wall' and i<4:
    turn(1)
    i=i+1
  if look()=='wall':
    return 0
  else:
    return 1
Ejemplo n.º 2
0
def find_fruit():
  for i in range(1,4):
    if (look() == "fruit"):
      move()
      return True
    else:
      turn(1)
  return False
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def Movement():

 FruitPresence = touch()
  
 while (FruitPresence == 'fruit'):
  move()
  FruitPresence = touch()
  NewSource = look()
 if NewSource == 'fruit':
  Movement()  
 if FruitPresence != 'fruit':
  turn(-1)
  Movement()
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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()
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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()
Ejemplo n.º 12
0
                            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)
Ejemplo n.º 13
0
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()
  
Ejemplo n.º 14
0
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()
Ejemplo n.º 15
0
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)
Ejemplo n.º 16
0
                            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)
Ejemplo n.º 17
0
   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':
Ejemplo n.º 18
0
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)
Ejemplo n.º 19
0
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)
Ejemplo n.º 20
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)

# Add your code here
print look()
Ejemplo n.º 21
0
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()
Ejemplo n.º 22
0
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
Ejemplo n.º 23
0
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()
Ejemplo n.º 24
0
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()
Ejemplo n.º 25
0
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
Ejemplo n.º 26
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)

# Add your code here
print look()
Ejemplo n.º 27
0
def fruit():
  while look() == 'fruit':
    _move(1)
  _turn()
  fruit()
Ejemplo n.º 28
0
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
    
    
    
Ejemplo n.º 29
0
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()
Ejemplo n.º 30
0
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)
  
Ejemplo n.º 31
0
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