Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PERSPECTIVE: Several of you have expressed a desire for an extra credit assignment --- this is it. It is entirely optional. Here's how the extra

PERSPECTIVE: Several of you have expressed a desire for an extra credit assignment --- this is it. It is entirely optional. Here's how the extra credit will work: the grade on this optional assignment will be added to your set of open lab assignment grades; the (single) lowest grade in the set will be dropped when figuring your total.

BACKGROUND: Reeborg likes to take long meandering walks in his world and, even though he has a built-in compass, he sometimes cannot find his way back home. To alleviate this problem, Reeborg leaves a trail of beepers behind him (much like in the story of Hansel and Gretel). Unfortunately one day, while returning to his starting point by following the beeper path, he was struck by a lightning bolt that erased his "Follow the Path Home" program. Lost and confused, Reeborg turned himself off to await help.

TASK: Program Reeborg to follow his path back to his starting point, dump all the beepers he is carrying, face north, and turn himself off.

SITUATION DETAILS: In the initial situation, Reeborg is guaranteed to be on a beeperless street corner. Because Reeborg was interrupted while returning home, you are guaranteed that the path does not resume behind him. (Indeed, even if a beeper WAS behind Reeborg as he resumes his journey, you must NOT go in that direction. That beeper was no doubt left there, while Reeborg was turned off, by some evil villain wishing to lead Reeborg astray.) There are no obstacles on the path, i.e. Reeborg did not jump over any walls when originally laying down the path of beepers. (That is not to say that there are no walls in Reeborgs world. In fact, Reeborg enjoyed walking along walls every once in a while.) The end of the path (i.e., his home) is marked by two beepers on the same street corner. Each beeper will be reachable from a previous beeper by the execution of one move() instruction in some direction; there will be only one beeper reachable by amove(). The path will never cross over itself. The figure below depicts one possible initial situation.

HELPFUL HINT: Reeborg must probe each possible next street corner in his path, eventually finding the correct one. You should have Reeborg pick up the beepers as he follows the path; otherwise, he might get caught in an infinite loop going backward and forward.

IMPLEMENTATION NOTES: As usual, only one turn_off() may be used and that one must be located in the main routine. Don't forget to include the title line and global comments at the top of your program. This is a "classic" Reeborg assignment: do NOT use any variables. (Also, do NOT use any recursive procedure calls, that is, no functions call themselves.) Use comments in front of your functions to clarify the purpose of the function. Use as your source file name "path.py". Store your source file in your ~/OLA directory. Use the following code as your starting point:

 def main(): return_home() drop_all_beepers() face_north() turn_off() 

TEST SITUATIONS: There are three situations (worlds) available in $PUB that you should use in testing your program: path1.wld, path2.wld, and path3.wld. In addition, you should try your program against any relevant test worlds you may have created.

NOTE: Remember, this assignment is meant to exercise YOUR ability to think; neither offer nor accept any additional help, except on a one-to-one basis with the instructor.

GRADING: In addition to examining your source code and the execution results obtained by running your program against the three situations above, the grader may run your program against some additional (and unknown to you) situations. Your program must complete the task under ALL legal initial situations to be considered correct.

REQUIRED: You are to electronically submit the source program and screenshots of the outcomes obtained from running your program against the three test worlds. Once you are sure your program is working, run your program against path1.wld. When the program has successfully completed, enter the command

 $ import path1.pdf 

then move the cursor over the rur window and click. This will save a screenshot of that window in the file path1.pdf. (If you wish to check that your screenshot came out okay, you may view your screenshot with the command $ display path1.pdf or use your Firefox/Iceweasel browser as we did in closed lab.) Prepare screenshots of the other two worlds in the same manner. (Be sure you change the worlds AND let the program run to completion each time.) When you have the screenshots path1.pdf, path2.pdf, and path3.pdf ready, enter the command

 $ handin "olaX" path.py path1.pdf path2.pdf path3.pdf 

to submit your assignment.

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago