0% found this document useful (0 votes)
569 views1 page

Harvest 1

This document defines functions to control a robot named hubo to harvest beepers in a diamond pattern on a grid, then perform a happy dance. It loads a world, defines functions for turning, moving to start, climbing stairs in a diamond pattern, harvesting all beepers, and dancing, then calls the functions to complete the tasks with hubo.

Uploaded by

walaba06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
569 views1 page

Harvest 1

This document defines functions to control a robot named hubo to harvest beepers in a diamond pattern on a grid, then perform a happy dance. It loads a world, defines functions for turning, moving to start, climbing stairs in a diamond pattern, harvesting all beepers, and dancing, then calls the functions to complete the tasks with hubo.

Uploaded by

walaba06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

from cs1robots import *

load_world("../worlds/harvest2.wld")

def turn_right(robot):
for i in range(3):
robot.turn_left()

def goto_start(robot):
for i in range(5):
robot.move()
robot.turn_left()
robot.move()

def stairs(robot, n):


for i in range(n):
robot.pick_beeper()
robot.move()
turn_right(robot)
robot.move()
robot.turn_left()

def diamond(robot, n):


for i in range(4):
stairs(robot, n)
robot.turn_left()

def harvest_all(robot):
for i in range(3):
n = 5 - 2 * i
diamond(robot, n)
hubo.move()
hubo.move()

def happy_dance(robot):
for i in range(102):
robot.turn_left()

hubo = Robot()
hubo.set_trace("blue")

goto_start(hubo)
harvest_all(hubo)
happy_dance(hubo)

You might also like