Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Robot lives in the world on the next slide. We want Sam to double the number of beepers on a corner in the world. Provide

Robot lives in the world on the next slide. We want Sam to double the number of beepers on a corner in the world. Provide the algorithm needed to double the pile of beepers. You can assume the following:

There is a finite number of beepers on the corner directly in front of Sam

has an infinite number of beepers in his bag

robot understands the following commands

move() takes one step forward

turn() turns left 90 degrees

pickUpBeeper() picks up 1 beeper from the floor and puts it in the bag

putBeeper() puts one beeper on the floor from the bag

repeat X times / End statements between the X and the End will be repeated X times

while ? / End (statements between the ? Condition and the End will repeat as long as the ? Condition returns true.

robot knows how to do the following tests

beepersPresent() returns true if there is at least 1 beeper on the spot Sam is standing

Lab problem 2 requirements

On each of the avenues, there is a tower of beepers of an unknown height, although some avenues (such as 7th in the example photo) may be empty.

Sams job is to collect all beepers in each of these towers and put them back down on the easternmost corner of 1st street (bottom right of his world), then return to his starting position.

Sam does not have any beepers in his pouch when he starts.

See next slide for an after photo

What sam knows

Test

Opposite

What it Tests

frontIsClear

frontIsBlocked

Is there a wall in front of Sam?

leftIsClear

leftIsBlocked

Is there a wall to Sams left?

rightIsClear

rightIsBlocked

Is there a wall to Sams right?

beepersPresent

noBeepersPresent

Are there beepers on this spot?

beepersInBag

noBeepersInBag

Are there beepers left in Sams bag?image text in transcribed

2345678 7 6 5 4 3 2 2345678 7 6 5 4 3 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

1. Diagnose and solve a transfer of training problem.

Answered: 1 week ago