zd : n  , : "The Longest Automobile Race, 1908" : x : ) "(c) David H. Ahl, 1986" : ,::Initialization3 LA$(),LB$(),TX(),C(),WX(),DX()c FA$(),FB$(),FC$(),FT(,),FL(,)Z : GF : :Starting cash and gas price  : :Initialize text variables  : :Initialize location data  : :Initialize mechanical breakdown dataX "Press any key when you're ready to go" : RNu () : RNRN :  RN : RNRN : : RN : ::Main programJJ : T : ~ : . : :New location, road data, etc.ODA : WWX(J) : DDX(J) : TETX(J) : :Set variables for new locationm  : :Print the date" "You are at " LA$(J) ", " LB$(J) ".", "You currently have"; : "$$####.##";Z : J  6 FX T : :Any unfixed mechanical parts?S@ "A sympathetic garage owner will fix the " FA$(FX) " here." : FXJTZ(()) : "It will take" TZ "day(s)." :  T J J  : :Ocean voyage?^ JV JV : TLTLTE :  : :End of ocean voyage?4h : "You have driven" (DC) "miles in" TD "days."]r J  : :Finished the race?| TDTL  : TDTL  "The race leader passed this point" TDTL "day(s) ago." :   "You are the race leader and are" TLTD "day(s) ahead." : O "You and the Italian Zust are running even with each other."}TLTLTE : :Elapsed time of race leader J J  : :Ocean voyage after land segment? JV JV :  : :End of ocean vovage?$ "Roads to the west of here are " C$(C(J)) "."O "The weather forecast is " W$(W) "." "You set a goal of making" D "miles in the next" TE "days."  : :Buy gas and oil  : :Get desired speed 4 : :Get desired driving hours per day :;:Go through this race segment day by dayvTZ :  : :Increment through each day of travel ` : :Weather subroutine& h : :Mechanical breakdown subroutine0  : :Accident subroutine4:DDSPHPPW : DADADD : DCDCDD : :Daily and cumulative distanceslDGM)\}DD(LL()) : :Gas used todayN GMGG GGGGGM : l : :Subtract gas used from supplyX:::  : "You ran out of gas on the road."bGF( :  : GGGGGM : :Buy gasKl DAD  :  : :Complete a travel segment?Sv:r:Fuel and oil subroutineGPGF(333()): "Gas costs" (dGP) "cents per gallon here." "How many gallons do you want for the segment ahead";GGAGF : ZNGGGP : "That will cost"; : "$$###.##";ZNj d : :Do you have enough money? A : :Enough money now? Z "Your car won't run on fumes. It's all over.": FGG(ZGP) : "Sorry, you could only get" GG "gallons." : :B:Input desired speed subroutineq "How fast (mph) do you want to drive";SP SP6 "Top speed of your car is only 54 mph." :  SP "At that rate, you'll never get there." :  W SP   : V  "That's too fast for these weather and road conditions." : PBSPSPX : :Probability of mechanical breakdown is related to speed *:4:Input desired driving hours subroutine >K : :Counter for pushing too hardB H "How many hours do you want to drive each day";HP R K  : :Did we ask about pushing too hard already? \ HP "That's too much for both you and your car." : H f HP "No one is that lazy!" : H#!pHCHCHP : J HCJq z : c!z "You've been pushing yourself and your crew pretty hard."! "You should probably back off a bit." : K : H!PFHP~ : PF #z PF #z : :Probability of fatigue problem!!:":Date subroutineD" TTTD : :Printed this date already?x" TD  : TD2  : TDP " TDo  : TD  : TD " TD  : . : ."MO$"February" : MDTD : $#MO$"March" : MDTD : $D#MO$"April" : MDTD1 : $k#MO$"May" : MDTDO : $#MO$"June" : MDTDn : $#MO$"July" : MDTD : $#MO$"August" : MDTD$$ : "Date: " MO$;MD ", 1908" : TTTD : H$. : "It's September 1 and the winning car crossed the finish"$8 "line in Paris over a month ago. Your factory refuses to give"$B "you any more money to continue. Better luck next time."$L 2$V:$`:Weather subroutine!%j W ~, ,  , F, F, )%t:S%~:Heavy snow and blizzard conditions%RN() : RN(  : RNzT  : %  : PWu{ #}() : :Speed factor in blizzard & "Blizzard conditions. Tough going today." : ~ : P&  : PWL|L}() : :Speed factor in very heavy snow& "You're stuck in a huge snow drift." :  : &PW)\~{.~() : : :Speed factor on heavy snow day&:&:Snow conditions(' ()L}  : :10% chance of getting stuck in snowk'PWL() : : :Speed factor on normal snowy day'PW~L}() :  : "You have skidded into a ditch."'  : : :Hire farmer to pull you out of ditch?':( :Rainy weatherB( ()L~  : ( : :Bogged down in mud?(PW333L() : : :Speed factor on normal rainy day((PW #{ #|() : "You are totally bogged down in the mud.")2  : : :Hire farmer to pull you out of mud? )<:+)F:Cloudy and mixed weatherl)PRN() : RN #}  :  : :Normal cloudy day?)Z RN #z "An unexpected downpour!" : ()d "River ahead with no bridge. Some locals tell you there is a bridge"8*n "'some distance' north. They also offer to take you across by boat"}*xZN(()) : "for $"ZN; : ". Want to go by boat";A$*  : A  : :Not willing to pay?* d : :Go to pay the bill routine+ A  : :Still not enough money?J+ "They got you across in" (()) "hours." : PW : +TZ(()) : "It took" TZ "day(s) for you to drive north ";+ "and find the bridge." :  : +PWLL() : : :Normal cloudy day+:,:Clear and sunnyJ, ()L{  : d : :River with no bridge},PWfff() : : :Normal sunny day,:,:Pull you out of ditch subroutine,ZN(()) : "A farmer offers to pull you out for $" ZN-- "Do you want to pay him to pull you out";A$ :  V- A J : :Not willing to pay?-" d : :If not enough money try to get some-, A J : :Still not enough money?.6RQ(@()): "It took" RQ "hours for him to pull you out."1.@ RQ : TZ :  : PWPW@ : }.JTZ(ff&()): "It took" TZ "day(s) for you and your mechanic".T "to pull the car out by yourselves." :  : PWPW@:.^:.h:Mechanical breakdowns subroutine//r ()PB : :If no mechanical breakdown then returnv/|F(()) : F F(()) : :What malfunction/:: :  : :Sound warning beeper and print date/ "Uh oh. You have a problem. It's a " FA$(F) "."0 "Here's what you can do about the problem:"E0 ) "(1) Try to keep going with it"p0 ) "(2) " FB$(F) ", cost $" FL(,F)0 FC$(F)""  : :Only one way to fix it?0 ) "(3) " FC$(F) ", cost $" FL(,F)0 "Which would you like to do";FQ!1 FQ 0 : :Decided to do nothing?_1 FQ FQ  : "Please enter a number." : 1FQFQ : FUFT(FQ,F) : FU FD$"hours" : 1 FU  : TZ :  : :Lose a day for repairs?2FUFT(FQ,F) : TZFU : FU FD$"day" : FD$"days"`2PWPW@ :  : :Allow for 1/2 day driven & increase day counters2ZNFL(FQ,F) : "Repairs will take" FU;FD$ " and will cost $" ZN2 d : :Pay the repair bill2& A : :Enough money?(30 "You try to nurse the car along to the next major city."W3: FX N : :Any unfixed malfunction?3D "But with the other problem you just can't make it and" : b3N ()L l : :60% chance that you can nurse it along4X ~ : : "Unfortunately, it just won't make it and"K4b "reluctantly you admit defeat." : 24l "It looks like you'll make but at a drastically reduced speed."4vPWPW : FXF : : :Cut speed factor in half, note unfixed item4:5:Accidents and special situations subroutine`5 ()PF 4 : :If driving long hours is not a problem, go on5:::: : "You dozed off and your car has run ";5 (()) , , , , 5 "into a tree." : TZ : ZN : "6 "off the road." : TZ : ZN : U6 "into a gaping hole." : TZ : ZN : 6 "into a farmer's wagon." : TZ : ZN6 "You can try to fix it or get a tow to the next village for $15." 7 "Want to try to bang out the damage on the spot";A$ :  O7 A  : "The tow costs $15 and the repairs cost $"ZNw7ZNZN : d : :Pay the bills7 A 4 : :Enough money now?7  "The locals impound your car for your unpaid debt." : 28 "You finally manage to do it but it takes" TZ "day(s)."l8 PWPW@ :  : :Allow for 1/2 day driven & increase day counterst8*:84:Drive on railraod ties routine8> J J J J  : :In area with railroads?'9H ()L  :  : :40% chance to drive on rwy tracksq9R "In this area of terrible roads, you can save some time by driving"9\ "on the railraod tracks. However, it is murder on your wheels,"9f "tires, and whole car. "; : "Want to drive on the tracks";A$:p  : A `:zPWPWY : PBPB : : :Increase speed and chance of troubleh::::No grease routine: J J : :In central Russia?: ()L~ : :20% chance of no grease!;:::  : "Your differential is dry and there is"c; "no grease available here. However, you can get Vaseline."; "Want to use it in place of grease";A$ :  ; A "Okay, you buy 20 jars for $4." : ZZ : < "The gears sound horrible. You'll have to cut your speed in half."0<PWPW : 8<:W<:Ocean voyage subroutine<JV : TZ(`()) : :Length of time in port< J  : J  < J t : J V = "You're stuck in port for"TZ"days before you can get a steamer"Z=$ "for Seattle. You use the time to get new countershaft"=. "housings, springs, wheels, drive chains, and tires."=8 Z, "The cost of these items is $164." : ZZ: L >B "These were all furnished by the local Thomas Flyer dealer."E>L TZTZ : TDTD :  : L : >V "It took 3 days on the steamer. The next steamer for Valdez">` "leaves in" TZ "days. Nothing to do but wait." :  >j L : TDTD : $?t "The steamer made many stops up the coast and it took 7 days."n?~ "It is apparent that the race organizers have never been in Alaska"? "and have no idea that it is impossible to drive on the snow and"@ "ice at all, much less across the Bering Strait to Russia. You'll"D@ "have to return to Seattle. Next steamer goes in" TZ "days."d@  : L : TDTD : @ "It took 7 days to get back to Seattle. Now you have a" TZ "day"@ "wait before you can get a freighter for Japan."A  : L : TDTD : NA "The freighter across the Pacific takes a leisurely 21 days making"A "stops at Hawaii, Guam, and the Philippines. Also the Chinese"A "crewmen made sandals out of your leather fenders and mud flaps.""B "You can't replace them in Japan, but you can at Vladivostock,"iB "Russia. There you'll have to spend several days arranging for"B "fuel also. But hurry now. A steamer to Russia leaves tonight."B L : TDTD : B :B :Time delay and hotel bills routine.C( TTTZ : TDTDTZ : :Increment time counters`C2 ZN TZ : d : :Pay for hotel and mealsC< A : :Did we have enough money?CF : "You don't even have enough money to pay for meals."DP "That's the end of the road for you." : : 2 DZ :(Dd :Pay the bills routinebDn ZZN  :  : :Enough money to pay bills?Dx ZZN A : : :Couldn't get money from homeD ZZZN : A : : :Subtract money from kittyD :D :Need more money subroutine=E ZBZB : ZB ZW : ZW : :Money request and amountE : "You don't have enough money to continue. Your only hope is"E "to send a telegram back to Mr. Thomas at the factory and ask"F "for more money. Remember, telegrams in 1908 used all capital"@F "letters, had no commas, and were short."~F "What is your message";A$ : "Sending telegram now..."F  : ZB | F AS : AP : L(A$) : L h G I L : AT$(A$,I,) : :Look at 3-letter groups in telegramFG AT$"PLE" AT$"BEG" AT$"SOR" AT$"IMP" APG AT$"SOO" AT$"QUI" AT$"EAR" AT$"FAS" AT$"HUR" ASG AT$"IMM" AT$"ONC" AT$"URG" ASG I : AP @ : AS , )H" "Mr. Thomas wired back $"ZW" and said 'GOOD LUCK!" : ZZZW : sH, "Mr. Thomas didn't know you needed the money right away and waited"H6 "3 days before wiring back $"ZW : ZZZW : TZ :  : H@ AS ^ IJ "Mr. Thomas wired back, 'YOU COULD AT LEAST BE POLITE,' but did"EIT ZWZW : "include a draft for $" ZW : ZZZW : I^ "Mr. Thomas was offended by your telegram and refused to": r Ih "Your message was short all right. Too short. Mr. Thomas didn't"Ir "send any money. Sorry." : =J| "Mr. Thomas wires back: I AM FED UP WITH THIS ADVENTURE STOP"rJ "YOU WILL GET NO MORE MONEY FROM ME STOP" : zJ :J :Subroutine to put verbal data into constantsJ I  : C$(I) : IJ I  : W$(I) : I3K "hard packed gravel","muddy ruts","slightly improved wagon tracks"xK "built for narrow carts","practically non-existent","horrible"K "blizzard conditions","snow and sleet","rain"K "cloudy with a chance of rain","mixed","sunny and dry"K K :=L :Location, expected weather, road conditions, need to use rail,L : expected days to next location, distance to next locationL I : X,LA$(I),LB$(I),WX(I),C(I),TX(I),DX(I): IL L 1, "New York","New York", 2,1,8,897,M& 2, "Kendallville","Indiana", 1,1,6,166`M0 3, "Chicago","Illinois", 3,2,7,634M: 4, "Omaha","Nebraska", 6,3,4,482MD 5, "Laramie","Wyoming", 2,3,7,467MN 6, "Ogden","Utah", 6,1,8,1237/NX 7, "San Francisco","California", 5,7,8,0aNb 8, "Seattle","Washington", 5,7,8,0Nl 9, "Valdez","Alaska", 5,7,8,0Nv 10,"Seattle","Washington", 5,7,25,0N 11,"Kobe","Japan", 4,4,4,350,O 12,"Tsuruga","Japan", 4,7,7,0aO 13,"Vladivostock","Russia", 3,5,15,558O 14,"Tsitsihar","Manchuria", 5,6,10,659O 15,"Chita","Russia", 3,3,8,1116P 16,"Kansk","Russia", 4,3,6,10754P 17,"Omsk","Russia", 5,1,7,820jP 18,"Perm","Russia", 3,2,14,1090P 19,"St. Petersburg","Russia", 3,1,8,1575P 20,"Paris","France", 0,0,0,0P :Q :Mechanical breakdown descriptions, time to fix, cost$Q I gQ X,FA$(I),FB$(I),FC$(I),FT(,I),FL(,I),FT(,I),FL(,I): I:Q 1, "tire blowout","Patch the hole","Replace the tire", 2,1,2,7Q 2, "skipping cylinder","New spark plugs","Grind cylinder",1,2,8,2>R 3, "rough running engine","Do a tune up","", 4,5,0,0R* 4, "binding axle bearing","Regrind bearing","Get a new one",8,2,4,8R4 5, "cracked spring","New spring","Weld angle iron to it",8,26,8,4S> 6, "cracked wheel","New wheel","Weld brace on it", 2,42,8,4`SH 7, "slipping clutch","Adjust clutch","New clutch plate", 4,4,8,54SR 8, "stripped gear","Weld teeth back on","New gear", 16,6,8,24S\ 9, "radiator leak","Weld a patch on it","", 4,2,0,06Tf 10,"brakes failure","Replace the linings","", 8,7,0,0Tp 11,"crack in the countershaft housing","A new housing","",24,40,0,0Tz 12,"broken drive pinion","Weld teeth back on","New pinion",16,6,8,18U 13,"broken rear axle","Get a new axle","", 16,68,0,0`U 14,"cracked transmission housing","New one from factory","",24,60,0,0U 15,"broken motor support","Make a new one of scrap iron","",16,16,0,0U 16,"worn down clutch shaft","A new clutch shaft","", 8,28,0,0AV 17,"cracked frame","Weld on braces of angle iron","", 24,26,0,0V 18,"total transmission failure","A new one from factory","",40,225,0,0V :V :Check for yes or no answerV A$"" A$"Y" A$"y" A : W A$"N" A$"n" A : 0W "Don't understand your answer of ";A$;"."jW "Please enter Y for 'yes' or N for 'no.'";A$ :  rW :W:Telegraph routineW I  : X() : K X : : KW K  : K : I : W$:X.:Warning beeper routine5X8 : I ::: K  : K : I : =XB:YXL:Ready to go? routineXV : "Press any key when you're ready to go aboard."X` () : XjXt:X~:Pause routineX I  : I : X:Y:Finished the race in Paris!:Y K  : ::: : K : : XqY I  : K d : K :  , : X$ : Y X X$"CONGRATULATIONS !" : X : YX$" " : X : :X$=17 spaces to erase congratulationsY I : : !Z TDTL  : TDTL  _Z "You made it to Paris! The German Protos beat you by"Z TDTL "days but just to finish is a great honor!" : Z "You reached Paris first! The next car is" TLTD "days behind."Z 2[  "You reached Paris in a dead tie with the French Motobloc!"y[ : "You reached Paris in" TD "days. In 1908, the Thomas Flyer"[ "won the race reaching Paris on July 30 after 169 days." : [(:[2:End of race and summary statistics\< : . : <\F "Sorry you were unsuccessful. Only three of the"m\P "cars in the 1908 race ever finished." : \Z "In the" TD "days since the start of the race on February 12, 1908,"]d "you covered" (DC) "miles. You almost made it to " LA$(J) ", ";@]n LB$(J) "." : "Not bad, but you can do better." : H]x:] : "Would you like to try again (Y or N)";A$ :  ] A "Okay. Good luck!" :  : : ] "Okay. So long for now." :  : "M" : ]:^:Subroutine to print the instructionsU^ : ) "The Longest Automobile Race, 1908" : ^ " In this program, you are the captain of the Thomas Flyer team."^ "It is your job to get the car from New York to Paris--east to west--4_ "as quickly as possible. The race starts on Febraury 12, 1908."z_ " You must overcome many problems: bad weather, accidents,"_ "mechanical breakdowns, fatigue, and a lack of gas stations." ` " For each leg of the trip, buy as much gas as you need, but no"U` "more. Your car gets approximately 14 mph, although this will vary."` "You will carry what fuel you can and ship the rest ahead by rail to"` "locations along your route to be held for you (called 'spotting')."7a " Your car has a top speed of 54 mph. However, the probability"a" "of a breakdown increases substantially at speeds over 35 mph. Like-a, "wise, driving more than six hours per day increases your chance of" b6 "having an accident. But don't forget, this IS a race."Wb@ " If you get stuck, you can pay someone to pull you out (costs"bJ "money) or try to get out on your own (costs time)."bT " You can choose to repair a mechanical problem on the spot or"'c^ "wait until the next large town to get it fixed. Either choice has"Ach "associated risks."cr " If and when you run out of money, you can wire Mr. Thomas for"c| "more, but your request must be carefully and politely worded Also,"d "your telegram must be in all UPPER CASE letters.":d ) "Press any key to continue.";Ud () : : :