cmput 101 lab 2
Download
Skip this Video
Download Presentation
CMPUT 101 Lab # 2

Loading in 2 Seconds...

play fullscreen
1 / 13

CMPUT 101 Lab # 2 - PowerPoint PPT Presentation


  • 60 Views
  • Uploaded on

CMPUT 101 Lab # 2. September 17, 2007 14:00 – 16:50. Recap Lab # 1: Guido. World (.wld) Robot [ave] [street] [direction] [# of beeper] Robot 3 2 E 1 Wall [ave] [street] [direction] [length] Wall 3 4 S 2 Beepers [ave] [street] [# of beeper] Beepers 1 4 6. Recap Lab # 1: Guido.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CMPUT 101 Lab # 2' - rinah-jones


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cmput 101 lab 2

CMPUT 101 Lab # 2

September 17, 2007

14:00 – 16:50

recap lab 1 guido
Recap Lab # 1: Guido
  • World (.wld)
    • Robot [ave] [street] [direction] [# of beeper]
      • Robot 3 2 E 1
    • Wall [ave] [street] [direction] [length]
      • Wall 3 4 S 2
    • Beepers [ave] [street] [# of beeper]
      • Beepers 1 4 6
recap lab 1 guido1
Recap Lab # 1: Guido
  • Program (.gvr)
    • move, turnleft, pickbeeper, putbeeper, turnoff
    • All “define” instructions have to be at the beginning of the file.
conditionals
Conditionals
  • conditional branching

if :  

if front_is_clear:    move

  • indicates a set of instructions within the same indent.
  • All conditions you can use are listed in Step08 guide
iteration
Iteration
  • while loop

while :

while front_is_clear:

move

  • While do until the test condition is false.
iteration1
Iteration
  • Do

do :

do 5:

move

move

move

move

move

move

part a
Part a
  • Step09:
    • use do, and if instructions
    • Guido will shut down if asked to pick up a beeper and there is not one there, which conditional to use?
    • check if wall reached. Which conditional will be used to check if wall reached?
  • Read Step08 first
step08
Step08

robot 1 2 E

Beepers 3 2 1

Beepers 4 2 1

Beepers 6 2 1

Beepers 8 2 1

Beepers 9 2 1

Beepers 10 2 1

Beepers 12 2 1

Wall 12 2 E

part b
Part b
  • use while instead of do,
  • street can be any length,
  • wall at the end
part c
Part c
  • check for multiple beepers,
  • do we know how many? which conditional? while more beepers, keep picking up
part d
Part d
  • traverse each row, pick up beepers, until North East corner reached.
  • Drop beepers, how would you check if any are in the bag?
  • See figures for example
part e
Part e
  • Consider the map --- see figure
  • Use the program in part d but run in the new world
  • No need to write a new program
  • Answer the questions verbally
keep in mind
Keep in mind
  • use block structures (routines) to simplify the code e.g. turnNorth, turnEast, sweepOneRow, etc.
  • students can work in teams of two, or three (if there is an odd number of students), or can also work individually
  • test with both sample worlds provided
ad