View the step-by-step solution to:

CS 135 Fall 2012 Ali,Fraser,Goldberg,Hoey, Kaplan,Kogan,Petrick,Tompkins Assignment: 3 Due: Language level: Files to submit: Warmup exercises:...

Please solve Question 2 for me. I have no idea where to start. :(
CS 135 Fall 2012 Ali,Fraser,Goldberg,Hoey, Kaplan,Kogan,Petrick,Tompkins Assignment: 3 Due: Tuesday, October 2, 2012 9:00 pm Language level: Beginning Student Files to submit: robot.rkt Warmup exercises: HtDP 8.2.1, 8.2.2, 8.6.2, 8.6.3, 6.1.1 Practise exercises: HtDP 8.2.3, 8.2.4, 8.3.1, 8.3.2 Here are the assignment questions you need to submit. 1. In this question, you will perform step-by-step evaluations of Scheme programs, by applying substitution rules until you either arrive at a final value or cannot continue. You will use an online evaluation tool that we have created for this purpose. To begin, visit this web page: https://www.student.cs.uwaterloo.ca/ ˜ cs135/stepping (Note that the use of https is significant; the system won’t work if you omit the s . This link is also in the course web page’s table of contents.) You will need to authenticate using your Quest/WatIAM ID and password. Once you’re logged in, you should try the questions in the “Warm-up questions” category under “CS 135 Assignment 3”, in order to get used to the system. Note the “Show instructions” link at the bottom of each problem. Read the instructions before attempting a question! When you’re ready, complete the six stepping problems in the “Assignment questions” cat- egory, using the semantics given in class for Beginning Student Scheme. You can re-enter a step as many times as necessary until you get it right, so keep going until you completely fin- ish every question. All you have to do is complete the questions online—we’ll be recording your answers as you go, and there is no file to submit! The public tests for this assignment will tell you whether or not we have a record of your completion of the stepper problems. You are not done a question until you see the message Question complete! You should not use DrRacket’s Stepper to help you with this question, for a couple of rea- sons. First, as mentioned in class, DrRacket’s evaluation rules are slightly different from the ones presented in class; you are to use the ones presented in class. Second, in an exam situation, of course, you will not have the Stepper to help you. There will definitely be step-by-step evaluation questions on at least the first midterm. CS 135 — Fall 2012 Assignment 3 1
Background image of page 1
2. In this question you will write a robot navigator. A robot’s state is given by its ( x,y ) position. Submit your answer in the file robot.rkt . (a) Give a structure definition and accompanying data definition for a robot navigation command structure RobotCmd that should have two fields in the following order: dist (a distance the robot should travel from the current robot location) and dir (that is one of the four symbols ’ north , ’ east , ’ south , or ’ west ). Observe that a value of dist is natural (including zero). (b) Write a function to help a robot accept directional movement commands. Your function should follow the following contract: ;; robot-ctrl: Posn RobotCmd Posn The first parameter is a current robot position and the second is a navigation command. The function should produce a new robot location after moving the distance in the given direction from its current position that are specified in a navigation command. ( robot-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 north )) ( make-posn 0 5 ) ( robot-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 south )) ( make-posn 0 - 5 ) ( robot-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 west )) ( make-posn - 5 0 ) ( robot-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 east )) ( make-posn 5 0 ) (c) An obstacle is defined by its position. If during navigation a robot meets an obstacle then the obstacle’s position is the new position of the robot. Write a function that should follow the following contract: ;; robot-obstacle-ctrl: Posn RobotCmd Posn Posn The function consumes three parameters: a current robot position, a navigation com- mand and a position of the obstacle. The function should produce a new robot’s posi- tion. If the robot does not encounter the obstacle then it will proceed to its final location as in the previous question. If at the beginning the robot’s position coincides with the position of the obstacle then the robot does not move. ( robot-obstacle-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 north ) ( make-posn 0 3 )) ( make-posn 0 3 ) ( robot-obstacle-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 north ) ( make-posn 0 7 )) ( make-posn 0 5 ) ( robot-obstacle-ctrl ( make-posn 0 0 ) ( make-robotcmd 5 north ) ( make-posn 0 0 )) ( make-posn 0 0 ) (d) Assume that a robot can be controlled remotely by two controllers. Each controller is defined by its position. The robot executes the order given by the closest controller to its current position at the time the order is issued. If the distance from the original robot location to the both controllers is the same then the robot does not move. Observe that a robot will pass through controllers (controllers are not obstacles). Give a structure definition and accompanying data definition for a structure RobotCtrlCmd that should CS 135 — Fall 2012 Assignment 3 2
Background image of page 2
Show entire document
Sign up to view the entire interaction

Top Answer

Dear Student, We have reviewed your assignment thoroughly based on details of your assignment... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online