def super_move():
  if touch() != "wall":
    move()
  elif left_side() == "wall":
    turn(1)
  else:
    turn(3)
Exemple #2
0
def go():
  move()
  if (touch()!='fruit'):
    turn(-1)
    go()
    return
  go()
Exemple #3
0
def go():
  moved = 0
  while touch() == "fruit":
    move()
    moved = moved + 1
  
  turn(-1)
Exemple #4
0
def super_move():
    if touch() != "wall":
        move()
    elif left_side() == "wall":
        turn(1)
    else:
        turn(3)
Exemple #5
0
def go():
  while True:
    if left_side() == False:
      turn(1)
    if right_side() == False:
      turn(-1)
    move()
Exemple #6
0
def columnsd():
  turn(-1)
  for n in range(0,4):
    move()
  turn(-1)
  for k in range(0,30):
    move()
Exemple #7
0
def rowsr():
  turn(1)
  for n in range(0,4):
    move()
  turn(1)
  for j in range(0,32):
    move()
Exemple #8
0
def rowsl():
  turn(-1)
  for n in range(0,4):
    move()
  turn(-1)
  for j in range(0,32):
    move()
Exemple #9
0
def go():
    while touch() == "fruit":
        move()

    if touch() != "fruit":
        turn(3)
        go()
Exemple #10
0
def go():
    move()
    if (touch() != 'fruit'):
        turn(-1)
        go()
        return
    go()
Exemple #11
0
def find_fruit():
  for i in range(1,4):
    if (look() == "fruit"):
      move()
      return True
    else:
      turn(1)
  return False
Exemple #12
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)
Exemple #13
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)
Exemple #14
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)
Exemple #15
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)
Exemple #16
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()
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()
Exemple #18
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()
Exemple #19
0
def Movement():

 FruitPresence = touch()
  
 while (FruitPresence == 'fruit'):
  move()
  FruitPresence = touch()
  NewSource = look()
 if NewSource == 'fruit':
  Movement()  
 if FruitPresence != 'fruit':
  turn(-1)
  Movement()
Exemple #20
0
def u_turn(right):
  if right == True:
    turn(1)
  else:
    turn(-1)
  
  for i in range(4):
    move()
  
  if right:
    turn(1)
  else:
    turn(-1)
Exemple #21
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()
Exemple #22
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()
Exemple #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()
Exemple #24
0
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()
Exemple #25
0
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()
Exemple #26
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)
Exemple #27
0
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)
Exemple #28
0
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)
Exemple #29
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)
Exemple #30
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)  
Exemple #31
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)
Exemple #32
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()
Exemple #33
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)
Exemple #34
0
 def uturn():
   print 'u-turn'
   print flip
   if l=='fruit':
     if r=='fruit':
       turn(flip*2-1)
       move()
       turn(flip*2-1)
     else:
      turn(-1)
      move()
      turn(-1)
   else:
     turn(1)
     move()
     turn(1)
Exemple #35
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()
Exemple #36
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()
Exemple #37
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)
  
Exemple #38
0
def smalledge():
    for i in range(4):
        move()
Exemple #39
0
def edge():
    for i in range(32):
        move()
Exemple #40
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()
Exemple #41
0
def run(i):
    for i in range(0, 3):
        move()
Exemple #42
0
def turnrightand4():
    turn(1)
    distance = 4
    for n in range(0, distance):
        move()
Exemple #43
0
def turnleftand4():
    turn(-1)
    distance = 4
    for n in range(0, distance):
        move()
Exemple #44
0
def run1(i):
    for i in range(0, 20):
        move()
Exemple #45
0
def move32():
    distance = 32
    for n in range(0, distance):
        move()
Exemple #46
0
def m(num):
  for i in range(0, num):
    move()
Exemple #47
0
def go():
    moveBy(3)
    turn(-1)
    while True:
        if right_side() or left_side():
            move()
Exemple #48
0
def moveBy(spaces):
    for i in range(0, spaces):
        move()
Exemple #49
0
def super_move():
    if touch() != "wall":
        move()