12.07.2015 Views

BeeperBot Manual - Department of Computing Science

BeeperBot Manual - Department of Computing Science

BeeperBot Manual - Department of Computing Science

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>of</strong> this activity by observing the movements <strong>of</strong> the robot, and watching thechanging values in the Status pane.In order to understand programming, you must come to grips with thesetwo notions <strong>of</strong> process, and how they relate to one another, or more specifically,how the processing <strong>of</strong> your code controls the actions <strong>of</strong> the robot.When running the program, also note the iteration counter associated witheach do in the Program pane. Check carefully how the counters are testedon the completion <strong>of</strong> each iteration. In particular, follow this code until youclearly understand how the nesting works. Take the hint from the comments,and change the program to see how it changes the behavior <strong>of</strong> the robot whenthe turn right command is moved inside the inner loop.6.0.5 Example Two# Second Example in the notes# draws a spiral with length based on initial piledefine get_all {while (next_to_a_beeper) {pick_beeper}}define make_side {while (has_beeper(0)) {move_beeper(0,1)create_beepermove}}define restore_bag {while (has_beeper(1)) {move_beeper(1,0)}# reduce the number by oneput_beeperdestroy_beeper}define main {get_allwhile (has_beeper(0)){make_siderestore_bagturn_left}12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!