;;; PROJECT2-DATA.LISP - some test data for Project 2 ;;; created by Dana Nau, April 5, 2010 ;;; This file contains definitions of several racetracks that you can use as some of your ;;; test data for Project 2. The global variable *RACETRACKS* is a list of all of them. ;;; Each racetrack in *RACETRACKS* is as an instance of a defstruct called TRACK, ;;; which has the following fields: ;;; NAME - an arbitrary name that you can use to identify the track; ;;; BOUNDARY - the boundary of the track, in the format given in the project description; ;;; START - the starting stae, in the format given in the project description; ;;; FINISH - the finish line, in the format given in the project description; ;;; PATH - initially NIL. If you wish, you store your solution path here. ;;; As an example of how to use this file, the following four LISP expressions will return ;;; the name, boundary, starting point, and finish line of the second racetrack in the list: ;;; (track-name (second *racetracks*)) ;;; (track-boundary (second *racetracks*)) ;;; (track-start (second *racetracks*)) ;;; (track-finish (second *racetracks*)) ;;; Create the TRACK defstruct. This automatically defines the access functions ;;; (TRACK-NAME, TRACK-BOUNDARY, etc.) in the above example. (defstruct (track) name boundary start finish path) ;;; Create and initialize the *RACETRACKS* global variable. I could have initialized it with ;;; "(defvar *racetracks* nil) rather than using SETQ, but that would cause problems if you ;;; loaded this file several times during the same Lisp session. ;;; SETQ will re-initialize the variable every time you load this file. (defvar *racetracks*) (setq *racetracks* nil) ;;; Put the racetrack definitions into the *RACETRACKS* list. ;;; Each racetrack definition is an instance of the TRACK defstruct. ;;; example from the project description (push (make-track :name "track0" :boundary '(((4.1 0) (14 0)) ((18 14) (14 18)) ((0 14) (0 4)) ((0 10) (4 10)) ((11 5) (11 10)) ((14 14) (4.1 14)) ((14 0) (18 3.9)) ((18 3.9) (18 14)) ((14 18)(4.2 18)) ((4.2 18) (0 14)) ((0 4) (4.1 0)) ((4 10) (4 5)) ((4 5) (14 5)) ((11 10) (9 11)) ((14 5) (14 14)) ((4.1 14) (8 7))) :start '((1 8) (0 0)) :finish '((11 9) (14 9))) *racetracks*) ;;; track that's open at both ends, so the car can go outside (push (make-track :name "open-track" :boundary '(((4.5 4) (4.5 9.5)) ((4.5 9.5) (11.5 9.5)) ((11.5 9.5) (11.5 13)) ((5 13) (11.5 13)) ((5 13) (5 23)) ((8.5 23) (8.5 16)) ((8.5 16) (15 16)) ((15 16) (15 6.5)) ((7.5 6.5) (15 6.5))) :start '((6 5) (0 0)) :finish '((5.5 22.5) (8 22.5))) *racetracks*) ;;; example based loosely on the watkins glen racetrack (push (make-track :name "watkins-glen" :boundary '( ;; outer circuit ((0.5 7) (13 23)) ((13 23) (19.5 18)) ((19.5 18) (26 22.5)) ((26 22.5) (16 26)) ((16 26) (28.5 39)) ((28.5 39) (33.5 39)) ((33.5 39) (34 34.5)) ((28.5 29) (34 34.5)) ((28.5 29) (29.5 28)) ((29.5 28) (36.5 29)) ((36.5 29) (39.5 27)) ((39.5 27) (40.5 25)) ((39.5 22) (40.5 25)) ((22.5 4) (39.5 22)) ((14.5 4) (22.5 4)) ((10 0.5) (14.5 4)) ((0.5 7) (10 0.5)) ;; bump ((36.5 18.5) (36.5 20)) ((36.5 20) (37.5 21)) ((37.5 21) (38.5 21)) ;; inner circuit ((4 7) (9 3.5)) ((9 3.5) (10.5 3.5)) ((10.5 3.5) (14 6.5)) ((14 6.5) (21.5 6.5)) ((21.5 6.5) (34 20)) ((34 20) (34 21)) ((34 21) (36.5 23.5)) ((36.5 23.5) (37.5 23.5)) ((37.5 23.5) (38 24.5)) ((38 24.5) (37 26)) ((37 26) (36 26.5)) ((28.5 25) (36 26.5)) ((28.5 25) (25.5 27.5)) ((25.5 27.5) (25.5 29.5)) ((25.5 29.5) (31.5 36)) ((31.5 36) (30.5 37)) ((30.5 37) (20.5 27)) ((20.5 27) (29 24)) ((29 24) (29 21.5)) ((29 21.5) (20 15)) ((20 15) (13.5 19.5)) ((13.5 19.5) (4 7)) ((5.5 13.5) (8 11.5))) :start '((6 12) (0 0)) :finish '((6 14.5) (8 13))) *racetracks*) ;;; a maze (push (make-track :name "maze-track" :boundary '(((0 0) (32 0)) ((0 2) (30 2)) ((0 4) (10 4)) ((12 4) (30 4)) ((2 6) (6 6)) ((8 6) (18 6)) ((20 6) (30 6)) ((2 8) (12 8)) ((14 8) (30 8)) ((0 10) (6 10)) ((8 10) (30 10)) ((2 12) (32 12)) ((2 14) (10 14)) ((12 14) (30 14)) ((0 16) (26 16)) ((28 16) (30 16)) ((0 18) (4 18)) ((6 18) (28 18)) ((0 20) (10 20)) ((12 20) (30 20)) ((0 22) (8 22)) ((10 22) (16 22)) ((18 22) (32 22)) ((2 24) (12 24)) ((14 24) (24 24)) ((26 24) (32 24)) ((2 26) (10 26)) ((12 26) (32 26)) ((2 28) (10 28)) ((12 28) (20 28)) ((22 28) (30 28)) ((2 30) (10 30)) ((12 30) (26 30)) ((28 30) (32 30)) ((0 32) (32 32)) ((0 0) (0 32)) ((2 24) (2 26)) ((2 28) (2 30)) ((6 6) (6 8)) ((6 12) (6 14)) ((10 18) (10 20)) ((10 26) (10 28)) ((12 4) (12 6)) ((12 12) (12 14)) ((12 22) (12 24)) ((12 26) (12 28)) ((14 22) (14 24)) ((16 0) (16 2)) ((16 6) (16 8)) ((26 26) (26 30)) ((30 2) (30 4)) ((30 6) (30 8)) ((30 14) (30 20)) ((32 0) (32 32))) :start '((3 31) (0 0)) :finish '((18 0) (18 2))) *racetracks*) ;;; put the racetracks into the same order in which they were given (setq *racetracks* (reverse *racetracks*))