Example #1
0
def go():
    while touch() == "fruit":
        move()

    if touch() != "fruit":
        turn(3)
        go()
Example #2
0
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)
Example #3
0
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)
Example #4
0
def branch(dir):
  turn(dir)
  
  if touch() == 'fruit':
    while touch() == 'fruit':
      move()
  elif left_side() == 'fruit':
    branch(-1)
  elif right_side() == 'fruit':
    branch(1)
Example #5
0
def branch(dir):
    turn(dir)

    if touch() == 'fruit':
        while touch() == 'fruit':
            move()
    elif left_side() == 'fruit':
        branch(-1)
    elif right_side() == 'fruit':
        branch(1)
Example #6
0
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()
Example #7
0
def go():
  moved = 0
  if touch() == 'fruit':
    move()
    moved = moved + 1
  elif touch() == None:
    turn(1)
  else:
    turn(1)
    go()
    
  for i in range(0,moved):
    go()
Example #8
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)  
Example #9
0
def Movement():

 FruitPresence = touch()
  
 while (FruitPresence == 'fruit'):
  move()
  FruitPresence = touch()
  NewSource = look()
 if NewSource == 'fruit':
  Movement()  
 if FruitPresence != 'fruit':
  turn(-1)
  Movement()
Example #10
0
def go():
  move()
  if (touch()!='fruit'):
    turn(-1)
    go()
    return
  go()
Example #11
0
def super_move():
  if touch() != "wall":
    move()
  elif left_side() == "wall":
    turn(1)
  else:
    turn(3)
Example #12
0
def go():
    move()
    if (touch() != 'fruit'):
        turn(-1)
        go()
        return
    go()
Example #13
0
def super_move():
    if touch() != "wall":
        move()
    elif left_side() == "wall":
        turn(1)
    else:
        turn(3)
Example #14
0
def go():
  moved = 0
  while touch() == "fruit":
    move()
    moved = moved + 1
  
  turn(-1)
Example #15
0
def  go():
  moved=0
  while touch() == "fruit":
    move()
    moved = moved+1
    
    turn (-1)
    if touch() == "fruit":
      go()
      turn(2)
      if touch() == "fruit":
        go()
        
      turn(1)
      for i in range (0,moved):
        move()
        turn (2)
Example #16
0
def tree():
    count = 0
    while touch() == "fruit":
        move()
        count += 1

    turn(-1)
    if touch() == "fruit":
        tree()

    turn(2)
    if touch() == "fruit":
        tree()

    turn(1)
    for i in range(count):
        move()

    turn(2)
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()
Example #18
0
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()

    if touch() == "wall":
        turn(2)
        move()
        go()
Example #19
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()
Example #20
0
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()
Example #21
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)
Example #22
0
def walk():
  for i in range (0, 1250):
    if left_side() == None:
            turn(-1)
            move()
    if touch()=='wall':
       if left_side()=='wall':
         turn(1)
         move()
       else:
          turn(-1)
          move()
    
    else:
      move()
Example #23
0
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()
Example #24
0
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)
Example #25
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)

while touch() != 'fruit':
  if left_side() == 'wall':
    if touch() != 'wall':
      move(1)
    else:
      turn(1)
  else:
    turn(-1)
    move(1)
move(1)
Example #26
0
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)
Example #27
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)


for i in range (0,10):
 if touch() == 'fruit':
  move()

if touch() == 'wall':
  turn(1)
  for i in range (0,10):
    move()
    
if touch() == 'wall':
 turn(-1)
 for i in range (0,20):
   move()
Example #28
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)

direction = -1

turn(1)
for i in range(0, 4):
    while touch() == "fruit":
        move()
    turn(-1)

for i in range(0, 7):
    for i in range(0, 4):
        move()
    turn(direction)
    direction = -direction
    for i in range(0, 30):
        move()
    turn(direction)

for i in range(0, 2):
    for i in range(0, 3):
        move()
    turn(direction)

direction = -direction

for i in range(0, 7):
    for i in range(0, 31):
        move()
    turn(direction)
from tealight.robot import move, turn, look, touch, smell, left_side, right_side

# 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":
Example #30
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)

# Add your code here
i = 0
while i < 1111:
    if touch() == 'fruit':
        move()

    elif left_side() == 'fruit':
        turn(-1)

    elif right_side() == 'fruit':
        turn(1)

    elif touch() != 'fruit':
        for i in range(0, 4):
            turn(1)
            if touch() == 'fruit':
                break

    i += 1
Example #31
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()
Example #32
0
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)
    
  
 
Example #33
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)

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":
Example #34
0
      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
  elif touch() == "wall" and collision_2==True:
    turn(-1)
  else:
    collision_1=False
    collision_2=False
  
  
  
Example #35
0
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()
Example #36
0
def super_move():
    if touch() != "wall":
        move()
Example #37
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)

print touch()

# Add your code here
Example #38
0
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":
Example #39
0
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
    elif touch() == "wall" and collision_2 == True:
        turn(-1)
    else:
        collision_1 = False
        collision_2 = False
Example #40
0
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


    
Example #41
0
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()
Example #42
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)
for i in range(0, 500):
  move()
  touch()
  if touch() == None:
    turn(-1)
     
def super_move():
    if touch() != "wall":
        move()
Example #44
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)
if touch() == 
Example #45
0
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)

Example #46
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)
Example #47
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)
import random
#
def scan():
  i = 0
  while look()=='wall' and i<4:
    turn(1)
    i=i+1
  if look()=='wall':
    return 0
  else:
    return 1
  
for i in range (0,400):
  found = scan()
  while found == 0:
    turn(random.randint(-1,1))
    move()
    found = scan()
  while str(touch())=='None':
    move()
  if str(touch())=='fruit':
    move()
Example #48
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
Example #49
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
Example #50
0
from tealight.robot import (move, 
                            turn, 
                            look, 
                            touch, 
                            smell, 
                            left_side, 
                            right_side)

# Add your code here
i = 0
while i < 1250:
  if touch() == 'wall':
    turn(1)
    
  elif left_side() != 'wall' and touch() != 'wall':
    move()
  
  elif left_side() != 'wall':
    turn(1)
    move()
    
  elif left_side() == 'wall':
    move()
Example #51
0
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
  
      
      
  
    

Example #52
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)
while True:
    if touch() == "fruit":
        move()
    else:
        if left_side() == "fruit":
            turn(-1)
            move()
            turn(1)
Example #53
0
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
Example #54
0
from tealight.robot import (move, turn, look, touch, smell, left_side,
                            right_side)

# Add your code here
n = 0
while n < 1000:
    n = n + 1
    print touch()
    if touch() == 'fruit':
        move()
    elif touch() == None:
        if right_side() == 'fruit':
            turn(1)
        elif left_side() == 'fruit':
            turn(-1)
Example #55
0
                            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)
  

    
Example #56
0
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)