0% found this document useful (0 votes)
50 views

Week 2: Programming With Robots (: Conditional Expressions, While-Loops)

This document provides an overview of week 2 programming concepts for robots, including conditional expressions (if/else/elif) and while loops. It introduces new robot functions like on_beeper() and front_is_clear() that check sensor states. Programming practices are outlined for tasks involving harvesting, planting, hurdles, and zigzag navigation using conditionals and while loops. The document explains modifying existing programs to work with different worlds and sensor conditions.

Uploaded by

Seungho Yang
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Week 2: Programming With Robots (: Conditional Expressions, While-Loops)

This document provides an overview of week 2 programming concepts for robots, including conditional expressions (if/else/elif) and while loops. It introduces new robot functions like on_beeper() and front_is_clear() that check sensor states. Programming practices are outlined for tasks involving harvesting, planting, hurdles, and zigzag navigation using conditionals and while loops. The document explains modifying existing programs to work with different worlds and sensor conditions.

Uploaded by

Seungho Yang
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Week 2 : Programming with Robots

(Conditional Expressions, While-loops)


Today’s Topic
 New program constructs
 Conditional expression : if, else, elif
 While-loops
Wing IDE Tip (Indent Guides)
 For easy programming
 Indent Guides
 Edit-> Preferences->Editer->Indentation->Show Indent Guides
New functions in robotnote
 Can check if there is a beeper
hubo.on_beeper()

hubo.on_beeper() = true hubo.on_beeper() = false

 Can check a wall on each side, front, left and right


hubo.front_is_clear()
hubo.left_is_clear()
hubo.right_is_clear()

hubo.left_is_clear()= true
hubo.front_is_clear()= false

hubo.right_is_clear()= true
Practices
 Read sections 10~20 doing following tasks.
 Harvest4 (page 6)
 Plant1 (page 7)
 Hurdles3(page 8)
 Hurdles4(page 9)
 Harvest5(page 10)
 ZigZag2(page 10)

 When you have done Task ZigZag2, let a TA mark you


off
Task | Conditionals – Harvest4
 Modify your program for the Harvest2 task so that is
works for the world harvest3.wld
 Load the “harvest3.wld” file
 load_world(“worlds/harvest3.wld”)

Before After
Task | Conditionals – Plant1

Write a program that plant potatoes

The world should be looked like harvest1.wld at the end

load_world(“worlds/harvest3.wld”)

Before After
Task | Conditionals – Hurdles3, 4
 Finish to write jump_one_hurdle() in section 11
 Will check below all maps
 Use a while loop to rewrite it
 You don’t have to use a for-loop of fixed length

Hurdles1.wld

Hurdles2.wld

Hurdles3.wld
Task | While loop – Harvest5
 Modify Harvest4 task program
 It also work when there is more than one carrot on one place
 It should also work for the previous worlds harvest1.wld and
harvest3.wld

Have to harvest all carrot


on one place
Task | While loop – ZigZag2
 Rewrite Zigzag1 program so that the robot can visit an
empty world of any size in zigzag fashion
 It should works for even and odd numbers of streets and
avenues

N is all even and odd numbers


n

n
Any Questions?

You might also like