Last updated: Thu, 29 Jan 2015 12:52:15 -0500
DUE: Monday 1/26/2015, 9pm EST
You must use the Beginning Student language to complete this assignment. Select it via the Choose Language... menu located at the bottom-left of the DrRacket window.
Put all your solution files in a directory named set02 in your repository.
Download extras.rkt to this directory (right-click and choose "Save As"; don’t copy and paste) and commit it as well.
Use begin-for-test and rackunit to define your examples and tests.
- Don’t forget to tell us how many hours you spent working on the assignment. This should be a global variable called TIME-ON-TASK in each file. For example:
(define TIME-ON-TASK 10.5) ; hours
- So each solution file must have at least the following at the top:
(require "extras.rkt") (require rackunit) (define TIME-ON-TASK <number-of-hours-you-spent>)
- After you’ve submitted your solution, use a web browser to go to https://github.ccs.neu.edu/ and check that your repository contains the following files:
Alternate Data Definitions: For each problem, describe in prose two alternative data definitions. For each of these alternatives, list pros and cons of how the changes would affect your code. For example, some data definition changes may simplify parts of your program and make other parts more complex. You should also consider how the alternatives affect your program in terms of readability and maintainability. Sometimes a little additional complexity may be worthwhile if makes your code more understandable. These are the tradeoffs you should constantly be considering.
Put these alternative data definitions and writeups at the end of your solution file(s).
UPDATE 2015-01-21: There are no git commit requirements for this assignment.
UPDATE 2015-01-21: You must now explicitly provide the required functions. See each problem for details.
(check-location "02" "robot.rkt")
UPDATE 2015-01-22: This is not a big-bang program. Notice that you are not required to write any render or key-handler functions.
Represent the robot with a circle that has a radius of 15 pixels.
The room is 200 pixels wide and 400 pixels long.
Use a graphics-style (x,y) coordinate system (like the Universe library) where (0,0) is the top-left, (200,400) is the bottom-right, and a robot moving "up" would decrease it’s y position.
- A robot can start anywhere:
completely in the room,
completely outside the room,
or partially inside/outside the room.
Once the robot is completely inside the room, it cannot leave (not even partially).
A robot who’s edge is flush against the wall is considered completely inside the room.
If moving an inside-the-room robot would put the robot outside or partially outside the room, it should stop right at the wall.
You may assume a built-in Coordinate data definition.
; initial-robot : Coordinate Coordinate -> Robot ; Returns a Robot located at (x,y), facing up. (define (initial-robot x y) ...) ; robot-left : Robot -> Robot ; robot-right : Robot -> Robot ; Returns a Robot like r, but turned either 90 degrees left or right. (define (robot-left r) ...) (define (robot-right r) ...) ; robot-x : Robot -> Coordinate ; robot-y : Robot -> Coordinate ; Returns the x or y component of the Robot's location. (define (robot-x r) ...) (define (robot-y r) ...) ; robot-forward : Robot NonNegReal -> Robot ; Returns a Robot like r, but moved forward by d pixels. ; If the robot is inside the room and moving would put any part of the ; robot outside the room, the robot should stop at the wall that it's facing. (define (robot-forward r d) ...)
(check-location "02" "fsm.rkt")
UPDATE 2015-01-23: Added INITIAL-WORLD to provide list.
a data definition named World representing the states of the FSM (you may always define other data definitions if you want to);
a constant named INITIAL-WORLD;
the following run function and the functions it needs. The body of run (and only run) may be excluded from the 100% test coverage requirement.
Make sure no big-bang simulation starts when executing the program in DrRacket. However, calling (run INITIAL-WORLD) should start your simulation.;
- and the following additional functions:
; accept-state? : World -> Boolean ; Returns true if World w is an accepting state. (define (accept-state? w) ...) ; error-state? : World -> Boolean ; Returns true if World w is an error state. (define (error-state? w) ...)
(check-location "02" "editor.rkt")
; string->editor : String -> Editor ; Returns an Editor containing text str and cursor at position 0. (define (string->editor str) ...) ; editor-pre : Editor -> String ; Returns the text in editor e before the cursor. (define (editor-pre e) ...) ; editor-post : Editor -> String ; Returns the text in editor e after the cursor. (define (editor-post e) ...) ; editor-pos : Editor -> Natural ; Returns the position of the cursor in editor e. (define (editor-pos e) ...)