Home » Archimedes archive » Archimedes World » AW-1991-03.adf » !AWMar91/Goodies/5Alive/TRAFFIC

!AWMar91/Goodies/5Alive/TRAFFIC

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Archimedes World » AW-1991-03.adf
Filename: !AWMar91/Goodies/5Alive/TRAFFIC
Read OK:
File size: 0F05 bytes
Load address: FFFFFB42
Exec address: 843C5548
File contents
   10REM > TRAFFIC
   20REM Production system demonstration
   30REM Jonathan Evans, July 1990
   40
   50MODE 12
   60PROCinit
   70PROCsimulate
   80END
   90
  100DEFPROCinit
  110@%=&90A
  120greenflow=30: nsflow=16: ewflow=8
  130REM Traffic flow rates in cars per minute
  140nstime=60: ewtime=30: ew=FALSE
  150REM Times that lights remain green in seconds
  160ecars = 3: wcars = 3: ncars = 3: scars = 3
  170oldecars = ecars: oldwcars = wcars: oldncars=ncars: oldscars = scars
  180xlow=600:ylow=472:side=80: offset=8: carwidth=8: carlength = 24
  190red=1:green=2: yellow=3: black=0
  200maxn=ncars:maxe=ecars:maxw=wcars:maxs=scars:count=1
  210ntot=0:stot=0:etot=0:wtot=0
  220PROCdraw_world
  230ENDPROC
  240
  250DEFPROCsimulate
  260finished=FALSE: time=0
  270REPEAT
  280oldecars = ecars: oldwcars = wcars: oldncars=ncars: oldscars = scars
  290PROCproduce
  300PROCshow
  310time += 1
  320count+=1
  330REM Each loop simulates one second of activity
  340UNTIL finished
  350ENDPROC
  360
  370DEFPROCproduce
  380
  390REM Rules for changing the traffic lights
  400IF ew AND time = ewtime THEN ew=FALSE: time=0:PROCdraw_lights
  410IF NOT ew AND time = nstime THEN ew=TRUE:time=0:PROCdraw_lights
  420
  430REM cars arriving at junction
  440IF FNrand(nsflow) THEN ncars +=1
  450IF FNrand(nsflow) THEN scars +=1
  460IF FNrand(ewflow) THEN ecars +=1
  470IF FNrand(ewflow) THEN wcars +=1
  480
  490REM cars leaving junction
  500IF NOT ew AND FNrand(greenflow) AND ncars >0 THEN ncars -=1
  510IF NOT ew AND FNrand(greenflow) AND scars >0 THEN scars -=1
  520IF ew AND FNrand(greenflow) AND ecars >0 THEN ecars -=1
  530IF ew AND FNrand(greenflow) AND wcars >0 THEN wcars -=1
  540
  550ENDPROC
  560
  570DEFFNrand(flow)
  580IF RND(1) < flow/60 THEN =TRUE ELSE =FALSE
  590
  600DEFPROCshow
  610PROCdraw_cars
  620PROCstatistics
  630REM PROCpause(10)
  640REM REPEAT UNTIL GET
  650ENDPROC
  660
  670DEFPROCpause(t)
  680LOCAL t1
  690t1=TIME
  700REPEAT UNTIL TIME-t1>t
  710ENDPROC
  720
  730DEFPROCstatistics
  740IF ncars > maxn THEN maxn = ncars
  750IF scars > maxs THEN maxs = scars
  760IF ecars> maxe THEN maxe = ecars
  770IF wcars >maxw THEN maxw = wcars
  780ntot += ncars: nave = ntot/count
  790stot += scars: save = stot/count
  800etot += ecars: eave = etot/count
  810wtot += wcars: wave = wtot/count
  820PRINT TAB(0,0);"NORTH CARS"'"Cur = ";ncars;TAB(8);" Max = ";maxn;TAB(18);" Ave = ";FNave(nave);" "
  830PRINT TAB(0,2);"SOUTH CARS"'"Cur = ";scars;TAB(8);" Max = ";maxs;TAB(18);" Ave = ";FNave(save);" "
  840PRINT TAB(0,5);"EAST CARS"'"Cur = ";ecars;TAB(8);" Max = ";maxe;TAB(18);" Ave = ";FNave(eave);" "
  850PRINT TAB(0,7);"WEST CARS"'"Cur = ";wcars;TAB(8);" Max = ";maxw;TAB(18);" Ave = ";FNave(wave);" "
  860PRINT '"Samples = ";count
  870REM REPEAT UNTIL GET
  880ENDPROC
  890
  900DEFFNave(ave)
  910LOCAL n,n%
  920n%=100*ave
  930n=n%/100
  940=n
  950
  960REM Graphical display procedures
  970
  980DEFPROCdraw_world
  990REM Draws current state of world
 1000RECTANGLE xlow,ylow,side,side
 1010PROCdraw_lights
 1020PROCdraw_cars
 1030OFF
 1040ENDPROC
 1050
 1060DEFPROCdraw_cars
 1070PROCewcars(ecars,oldecars,xlow+side+carwidth+offset)
 1080PROCewcars(wcars,oldwcars,xlow-carwidth -wcars*(carlength+offset))
 1090PROCnscars(ncars,oldncars,ylow+side+carwidth+offset)
 1100PROCnscars(scars,oldscars,ylow-carwidth-scars*(carlength+offset))
 1110ENDPROC
 1120
 1130DEFPROCewcars(n,oldn,xl)
 1140LOCAL x,xh
 1150IF n<oldn THEN
 1160GCOL black:
 1170IF xl < xlow THEN RECTANGLE FILL 0,ylow,xlow-offset,side
 1180IF xl >xlow THEN RECTANGLE FILL xlow+side+offset,ylow,640,side
 1190ENDIF
 1200GCOL yellow
 1210IF n=0 ENDPROC
 1220xh = xl+(n-1)*(carlength+offset)
 1230FOR x = xl TO xh STEP (carlength+offset)
 1240RECTANGLE FILL x,ylow+side/2-carwidth,carlength,carwidth
 1250NEXT x
 1260ENDPROC
 1270
 1280DEFPROCnscars(n,oldn,yl)
 1290LOCAL y,yh
 1300IF n<oldn THEN
 1310GCOL black:
 1320IF yl < ylow THEN RECTANGLE FILL xlow,0,side,ylow-offset
 1330IF yl >ylow THEN RECTANGLE FILL xlow,ylow+side+offset,side,512
 1340ENDIF
 1350GCOL yellow
 1360IF n=0 ENDPROC
 1370yh = yl+(n-1)*(carlength+offset)
 1380FOR y = yl TO yh STEP (carlength+offset)
 1390RECTANGLE FILL xlow+side/2-carwidth,y,carwidth,carlength
 1400NEXT y
 1410ENDPROC
 1420
 1430DEFPROCdraw_lights
 1440LOCAL ewcol,nscol
 1450CASE ew OF
 1460WHEN TRUE: ewcol=green: nscol=red
 1470WHEN FALSE: ewcol=red: nscol=green
 1480ENDCASE
 1490GCOL nscol
 1500RECTANGLE FILL xlow+2*offset,ylow+offset,side-4*offset,offset
 1510RECTANGLE FILL xlow+2*offset,ylow+side-2*offset,side-4*offset,offset
 1520GCOL ewcol
 1530RECTANGLE FILL xlow+offset,ylow+2*offset,offset,side-4*offset
 1540RECTANGLE FILL xlow+side-2*offset,ylow+2*offset,offset,side-4*offset
 1550ENDPROC
 1560

� > TRAFFIC
%� Production system demonstration
� Jonathan Evans, July 1990
(
2� 12
<	�init
F
�simulate
P�
Z
d
��init
n@%=&90A
x%greenflow=30: nsflow=16: ewflow=8
�+� Traffic flow rates in cars per minute
�nstime=60: ewtime=30: ew=�
�/� Times that lights remain green in seconds
�.ecars = 3: wcars = 3: ncars = 3: scars = 3
�Holdecars = ecars: oldwcars = wcars: oldncars=ncars: oldscars = scars
�Cxlow=600:ylow=472:side=80: offset=8: carwidth=8: carlength = 24
�$red=1:green=2: yellow=3: black=0
�7maxn=ncars:maxe=ecars:maxw=wcars:maxs=scars:count=1
�ntot=0:stot=0:etot=0:wtot=0
��draw_world
��
�
���simulate
finished=�: time=0
�
Holdecars = ecars: oldwcars = wcars: oldncars=ncars: oldscars = scars
"�produce
,	�show
6
time += 1
@count+=1
J0� Each loop simulates one second of activity
T� finished
^�
h
r
��produce
|
�+� Rules for changing the traffic lights
�4� ew � time = ewtime � ew=�: time=0:�draw_lights
�5� � ew � time = nstime � ew=�:time=0:�draw_lights
�
�� cars arriving at junction
�� �rand(nsflow) � ncars +=1
�� �rand(nsflow) � scars +=1
�� �rand(ewflow) � ecars +=1
�� �rand(ewflow) � wcars +=1
�
�� cars leaving junction
�4� � ew � �rand(greenflow) � ncars >0 � ncars -=1
�4� � ew � �rand(greenflow) � scars >0 � scars -=1
2� ew � �rand(greenflow) � ecars >0 � ecars -=1
2� ew � �rand(greenflow) � wcars >0 � wcars -=1

&�
0
:ݤrand(flow)
D� �(1) < flow/60 � =� � =�
N
X
��show
b�draw_cars
l�statistics
v� PROCpause(10)
�� REPEAT UNTIL GET
��
�
���pause(t)
�� t1
�t1=�
�� � �-t1>t
��
�
���statistics
�!� ncars > maxn � maxn = ncars
�!� scars > maxs � maxs = scars
� � ecars> maxe � maxe = ecars
 � wcars >maxw � maxw = wcars
$ntot += ncars: nave = ntot/count
$stot += scars: save = stot/count
 $etot += ecars: eave = etot/count
*$wtot += wcars: wave = wtot/count
4X� �0,0);"NORTH CARS"'"Cur = ";ncars;�8);" Max = ";maxn;�18);" Ave = ";�ave(nave);" "
>X� �0,2);"SOUTH CARS"'"Cur = ";scars;�8);" Max = ";maxs;�18);" Ave = ";�ave(save);" "
HW� �0,5);"EAST CARS"'"Cur = ";ecars;�8);" Max = ";maxe;�18);" Ave = ";�ave(eave);" "
RW� �0,7);"WEST CARS"'"Cur = ";wcars;�8);" Max = ";maxw;�18);" Ave = ";�ave(wave);" "
\� '"Samples = ";count
f� REPEAT UNTIL GET
p�
z
�ݤave(ave)
�
� n,n%
�n%=100*ave
�n=n%/100
�=n
�
�"� Graphical display procedures
�
���draw_world
�"� Draws current state of world
�ȓ xlow,ylow,side,side
��draw_lights
��draw_cars
�
�

$��draw_cars
.5�ewcars(ecars,oldecars,xlow+side+carwidth+offset)
8C�ewcars(wcars,oldwcars,xlow-carwidth -wcars*(carlength+offset))
B5�nscars(ncars,oldncars,ylow+side+carwidth+offset)
LB�nscars(scars,oldscars,ylow-carwidth-scars*(carlength+offset))
V�
`
j��ewcars(n,oldn,xl)
t
� x,xh
~� n<oldn �
�� black:
�/� xl < xlow � ȓ Ȑ 0,ylow,xlow-offset,side
�5� xl >xlow � ȓ Ȑ xlow+side+offset,ylow,640,side
��
�� yellow
�� n=0 �
�$xh = xl+(n-1)*(carlength+offset)
�&� x = xl � xh � (carlength+offset)
�3ȓ Ȑ x,ylow+side/2-carwidth,carlength,carwidth
�� x
��
�
��nscars(n,oldn,yl)


� y,yh
� n<oldn �
� black:
(/� yl < ylow � ȓ Ȑ xlow,0,side,ylow-offset
25� yl >ylow � ȓ Ȑ xlow,ylow+side+offset,side,512
<�
F� yellow
P� n=0 �
Z$yh = yl+(n-1)*(carlength+offset)
d&� y = yl � yh � (carlength+offset)
n3ȓ Ȑ xlow+side/2-carwidth,y,carwidth,carlength
x� y
��
�
���draw_lights
�� ewcol,nscol
�Ȏ ew �
�� �: ewcol=green: nscol=red
�� �: ewcol=red: nscol=green
��
�� nscol
�8ȓ Ȑ xlow+2*offset,ylow+offset,side-4*offset,offset
�?ȓ Ȑ xlow+2*offset,ylow+side-2*offset,side-4*offset,offset
�� ewcol
�8ȓ Ȑ xlow+offset,ylow+2*offset,offset,side-4*offset
?ȓ Ȑ xlow+side-2*offset,ylow+2*offset,offset,side-4*offset
�

�
00000000  0d 00 0a 0f f4 20 3e 20  54 52 41 46 46 49 43 0d  |..... > TRAFFIC.|
00000010  00 14 25 f4 20 50 72 6f  64 75 63 74 69 6f 6e 20  |..%. Production |
00000020  73 79 73 74 65 6d 20 64  65 6d 6f 6e 73 74 72 61  |system demonstra|
00000030  74 69 6f 6e 0d 00 1e 1f  f4 20 4a 6f 6e 61 74 68  |tion..... Jonath|
00000040  61 6e 20 45 76 61 6e 73  2c 20 4a 75 6c 79 20 31  |an Evans, July 1|
00000050  39 39 30 0d 00 28 04 0d  00 32 08 eb 20 31 32 0d  |990..(...2.. 12.|
00000060  00 3c 09 f2 69 6e 69 74  0d 00 46 0d f2 73 69 6d  |.<..init..F..sim|
00000070  75 6c 61 74 65 0d 00 50  05 e0 0d 00 5a 04 0d 00  |ulate..P....Z...|
00000080  64 0a dd f2 69 6e 69 74  0d 00 6e 0b 40 25 3d 26  |d...init..n.@%=&|
00000090  39 30 41 0d 00 78 25 67  72 65 65 6e 66 6c 6f 77  |90A..x%greenflow|
000000a0  3d 33 30 3a 20 6e 73 66  6c 6f 77 3d 31 36 3a 20  |=30: nsflow=16: |
000000b0  65 77 66 6c 6f 77 3d 38  0d 00 82 2b f4 20 54 72  |ewflow=8...+. Tr|
000000c0  61 66 66 69 63 20 66 6c  6f 77 20 72 61 74 65 73  |affic flow rates|
000000d0  20 69 6e 20 63 61 72 73  20 70 65 72 20 6d 69 6e  | in cars per min|
000000e0  75 74 65 0d 00 8c 1e 6e  73 74 69 6d 65 3d 36 30  |ute....nstime=60|
000000f0  3a 20 65 77 74 69 6d 65  3d 33 30 3a 20 65 77 3d  |: ewtime=30: ew=|
00000100  a3 0d 00 96 2f f4 20 54  69 6d 65 73 20 74 68 61  |..../. Times tha|
00000110  74 20 6c 69 67 68 74 73  20 72 65 6d 61 69 6e 20  |t lights remain |
00000120  67 72 65 65 6e 20 69 6e  20 73 65 63 6f 6e 64 73  |green in seconds|
00000130  0d 00 a0 2e 65 63 61 72  73 20 3d 20 33 3a 20 77  |....ecars = 3: w|
00000140  63 61 72 73 20 3d 20 33  3a 20 6e 63 61 72 73 20  |cars = 3: ncars |
00000150  3d 20 33 3a 20 73 63 61  72 73 20 3d 20 33 0d 00  |= 3: scars = 3..|
00000160  aa 48 6f 6c 64 65 63 61  72 73 20 3d 20 65 63 61  |.Holdecars = eca|
00000170  72 73 3a 20 6f 6c 64 77  63 61 72 73 20 3d 20 77  |rs: oldwcars = w|
00000180  63 61 72 73 3a 20 6f 6c  64 6e 63 61 72 73 3d 6e  |cars: oldncars=n|
00000190  63 61 72 73 3a 20 6f 6c  64 73 63 61 72 73 20 3d  |cars: oldscars =|
000001a0  20 73 63 61 72 73 0d 00  b4 43 78 6c 6f 77 3d 36  | scars...Cxlow=6|
000001b0  30 30 3a 79 6c 6f 77 3d  34 37 32 3a 73 69 64 65  |00:ylow=472:side|
000001c0  3d 38 30 3a 20 6f 66 66  73 65 74 3d 38 3a 20 63  |=80: offset=8: c|
000001d0  61 72 77 69 64 74 68 3d  38 3a 20 63 61 72 6c 65  |arwidth=8: carle|
000001e0  6e 67 74 68 20 3d 20 32  34 0d 00 be 24 72 65 64  |ngth = 24...$red|
000001f0  3d 31 3a 67 72 65 65 6e  3d 32 3a 20 79 65 6c 6c  |=1:green=2: yell|
00000200  6f 77 3d 33 3a 20 62 6c  61 63 6b 3d 30 0d 00 c8  |ow=3: black=0...|
00000210  37 6d 61 78 6e 3d 6e 63  61 72 73 3a 6d 61 78 65  |7maxn=ncars:maxe|
00000220  3d 65 63 61 72 73 3a 6d  61 78 77 3d 77 63 61 72  |=ecars:maxw=wcar|
00000230  73 3a 6d 61 78 73 3d 73  63 61 72 73 3a 63 6f 75  |s:maxs=scars:cou|
00000240  6e 74 3d 31 0d 00 d2 1f  6e 74 6f 74 3d 30 3a 73  |nt=1....ntot=0:s|
00000250  74 6f 74 3d 30 3a 65 74  6f 74 3d 30 3a 77 74 6f  |tot=0:etot=0:wto|
00000260  74 3d 30 0d 00 dc 0f f2  64 72 61 77 5f 77 6f 72  |t=0.....draw_wor|
00000270  6c 64 0d 00 e6 05 e1 0d  00 f0 04 0d 00 fa 0e dd  |ld..............|
00000280  f2 73 69 6d 75 6c 61 74  65 0d 01 04 16 66 69 6e  |.simulate....fin|
00000290  69 73 68 65 64 3d a3 3a  20 74 69 6d 65 3d 30 0d  |ished=.: time=0.|
000002a0  01 0e 05 f5 0d 01 18 48  6f 6c 64 65 63 61 72 73  |.......Holdecars|
000002b0  20 3d 20 65 63 61 72 73  3a 20 6f 6c 64 77 63 61  | = ecars: oldwca|
000002c0  72 73 20 3d 20 77 63 61  72 73 3a 20 6f 6c 64 6e  |rs = wcars: oldn|
000002d0  63 61 72 73 3d 6e 63 61  72 73 3a 20 6f 6c 64 73  |cars=ncars: olds|
000002e0  63 61 72 73 20 3d 20 73  63 61 72 73 0d 01 22 0c  |cars = scars..".|
000002f0  f2 70 72 6f 64 75 63 65  0d 01 2c 09 f2 73 68 6f  |.produce..,..sho|
00000300  77 0d 01 36 0d 74 69 6d  65 20 2b 3d 20 31 0d 01  |w..6.time += 1..|
00000310  40 0c 63 6f 75 6e 74 2b  3d 31 0d 01 4a 30 f4 20  |@.count+=1..J0. |
00000320  45 61 63 68 20 6c 6f 6f  70 20 73 69 6d 75 6c 61  |Each loop simula|
00000330  74 65 73 20 6f 6e 65 20  73 65 63 6f 6e 64 20 6f  |tes one second o|
00000340  66 20 61 63 74 69 76 69  74 79 0d 01 54 0e fd 20  |f activity..T.. |
00000350  66 69 6e 69 73 68 65 64  0d 01 5e 05 e1 0d 01 68  |finished..^....h|
00000360  04 0d 01 72 0d dd f2 70  72 6f 64 75 63 65 0d 01  |...r...produce..|
00000370  7c 04 0d 01 86 2b f4 20  52 75 6c 65 73 20 66 6f  ||....+. Rules fo|
00000380  72 20 63 68 61 6e 67 69  6e 67 20 74 68 65 20 74  |r changing the t|
00000390  72 61 66 66 69 63 20 6c  69 67 68 74 73 0d 01 90  |raffic lights...|
000003a0  34 e7 20 65 77 20 80 20  74 69 6d 65 20 3d 20 65  |4. ew . time = e|
000003b0  77 74 69 6d 65 20 8c 20  65 77 3d a3 3a 20 74 69  |wtime . ew=.: ti|
000003c0  6d 65 3d 30 3a f2 64 72  61 77 5f 6c 69 67 68 74  |me=0:.draw_light|
000003d0  73 0d 01 9a 35 e7 20 ac  20 65 77 20 80 20 74 69  |s...5. . ew . ti|
000003e0  6d 65 20 3d 20 6e 73 74  69 6d 65 20 8c 20 65 77  |me = nstime . ew|
000003f0  3d b9 3a 74 69 6d 65 3d  30 3a f2 64 72 61 77 5f  |=.:time=0:.draw_|
00000400  6c 69 67 68 74 73 0d 01  a4 04 0d 01 ae 1f f4 20  |lights......... |
00000410  63 61 72 73 20 61 72 72  69 76 69 6e 67 20 61 74  |cars arriving at|
00000420  20 6a 75 6e 63 74 69 6f  6e 0d 01 b8 1f e7 20 a4  | junction..... .|
00000430  72 61 6e 64 28 6e 73 66  6c 6f 77 29 20 8c 20 6e  |rand(nsflow) . n|
00000440  63 61 72 73 20 2b 3d 31  0d 01 c2 1f e7 20 a4 72  |cars +=1..... .r|
00000450  61 6e 64 28 6e 73 66 6c  6f 77 29 20 8c 20 73 63  |and(nsflow) . sc|
00000460  61 72 73 20 2b 3d 31 0d  01 cc 1f e7 20 a4 72 61  |ars +=1..... .ra|
00000470  6e 64 28 65 77 66 6c 6f  77 29 20 8c 20 65 63 61  |nd(ewflow) . eca|
00000480  72 73 20 2b 3d 31 0d 01  d6 1f e7 20 a4 72 61 6e  |rs +=1..... .ran|
00000490  64 28 65 77 66 6c 6f 77  29 20 8c 20 77 63 61 72  |d(ewflow) . wcar|
000004a0  73 20 2b 3d 31 0d 01 e0  04 0d 01 ea 1b f4 20 63  |s +=1......... c|
000004b0  61 72 73 20 6c 65 61 76  69 6e 67 20 6a 75 6e 63  |ars leaving junc|
000004c0  74 69 6f 6e 0d 01 f4 34  e7 20 ac 20 65 77 20 80  |tion...4. . ew .|
000004d0  20 a4 72 61 6e 64 28 67  72 65 65 6e 66 6c 6f 77  | .rand(greenflow|
000004e0  29 20 80 20 6e 63 61 72  73 20 3e 30 20 8c 20 6e  |) . ncars >0 . n|
000004f0  63 61 72 73 20 2d 3d 31  0d 01 fe 34 e7 20 ac 20  |cars -=1...4. . |
00000500  65 77 20 80 20 a4 72 61  6e 64 28 67 72 65 65 6e  |ew . .rand(green|
00000510  66 6c 6f 77 29 20 80 20  73 63 61 72 73 20 3e 30  |flow) . scars >0|
00000520  20 8c 20 73 63 61 72 73  20 2d 3d 31 0d 02 08 32  | . scars -=1...2|
00000530  e7 20 65 77 20 80 20 a4  72 61 6e 64 28 67 72 65  |. ew . .rand(gre|
00000540  65 6e 66 6c 6f 77 29 20  80 20 65 63 61 72 73 20  |enflow) . ecars |
00000550  3e 30 20 8c 20 65 63 61  72 73 20 2d 3d 31 0d 02  |>0 . ecars -=1..|
00000560  12 32 e7 20 65 77 20 80  20 a4 72 61 6e 64 28 67  |.2. ew . .rand(g|
00000570  72 65 65 6e 66 6c 6f 77  29 20 80 20 77 63 61 72  |reenflow) . wcar|
00000580  73 20 3e 30 20 8c 20 77  63 61 72 73 20 2d 3d 31  |s >0 . wcars -=1|
00000590  0d 02 1c 04 0d 02 26 05  e1 0d 02 30 04 0d 02 3a  |......&....0...:|
000005a0  10 dd a4 72 61 6e 64 28  66 6c 6f 77 29 0d 02 44  |...rand(flow)..D|
000005b0  1e e7 20 b3 28 31 29 20  3c 20 66 6c 6f 77 2f 36  |.. .(1) < flow/6|
000005c0  30 20 8c 20 3d b9 20 8b  20 3d a3 0d 02 4e 04 0d  |0 . =. . =...N..|
000005d0  02 58 0a dd f2 73 68 6f  77 0d 02 62 0e f2 64 72  |.X...show..b..dr|
000005e0  61 77 5f 63 61 72 73 0d  02 6c 0f f2 73 74 61 74  |aw_cars..l..stat|
000005f0  69 73 74 69 63 73 0d 02  76 13 f4 20 50 52 4f 43  |istics..v.. PROC|
00000600  70 61 75 73 65 28 31 30  29 0d 02 80 16 f4 20 52  |pause(10)..... R|
00000610  45 50 45 41 54 20 55 4e  54 49 4c 20 47 45 54 0d  |EPEAT UNTIL GET.|
00000620  02 8a 05 e1 0d 02 94 04  0d 02 9e 0e dd f2 70 61  |..............pa|
00000630  75 73 65 28 74 29 0d 02  a8 08 ea 20 74 31 0d 02  |use(t)..... t1..|
00000640  b2 08 74 31 3d 91 0d 02  bc 0e f5 20 fd 20 91 2d  |..t1=...... . .-|
00000650  74 31 3e 74 0d 02 c6 05  e1 0d 02 d0 04 0d 02 da  |t1>t............|
00000660  10 dd f2 73 74 61 74 69  73 74 69 63 73 0d 02 e4  |...statistics...|
00000670  21 e7 20 6e 63 61 72 73  20 3e 20 6d 61 78 6e 20  |!. ncars > maxn |
00000680  8c 20 6d 61 78 6e 20 3d  20 6e 63 61 72 73 0d 02  |. maxn = ncars..|
00000690  ee 21 e7 20 73 63 61 72  73 20 3e 20 6d 61 78 73  |.!. scars > maxs|
000006a0  20 8c 20 6d 61 78 73 20  3d 20 73 63 61 72 73 0d  | . maxs = scars.|
000006b0  02 f8 20 e7 20 65 63 61  72 73 3e 20 6d 61 78 65  |.. . ecars> maxe|
000006c0  20 8c 20 6d 61 78 65 20  3d 20 65 63 61 72 73 0d  | . maxe = ecars.|
000006d0  03 02 20 e7 20 77 63 61  72 73 20 3e 6d 61 78 77  |.. . wcars >maxw|
000006e0  20 8c 20 6d 61 78 77 20  3d 20 77 63 61 72 73 0d  | . maxw = wcars.|
000006f0  03 0c 24 6e 74 6f 74 20  2b 3d 20 6e 63 61 72 73  |..$ntot += ncars|
00000700  3a 20 6e 61 76 65 20 3d  20 6e 74 6f 74 2f 63 6f  |: nave = ntot/co|
00000710  75 6e 74 0d 03 16 24 73  74 6f 74 20 2b 3d 20 73  |unt...$stot += s|
00000720  63 61 72 73 3a 20 73 61  76 65 20 3d 20 73 74 6f  |cars: save = sto|
00000730  74 2f 63 6f 75 6e 74 0d  03 20 24 65 74 6f 74 20  |t/count.. $etot |
00000740  2b 3d 20 65 63 61 72 73  3a 20 65 61 76 65 20 3d  |+= ecars: eave =|
00000750  20 65 74 6f 74 2f 63 6f  75 6e 74 0d 03 2a 24 77  | etot/count..*$w|
00000760  74 6f 74 20 2b 3d 20 77  63 61 72 73 3a 20 77 61  |tot += wcars: wa|
00000770  76 65 20 3d 20 77 74 6f  74 2f 63 6f 75 6e 74 0d  |ve = wtot/count.|
00000780  03 34 58 f1 20 8a 30 2c  30 29 3b 22 4e 4f 52 54  |.4X. .0,0);"NORT|
00000790  48 20 43 41 52 53 22 27  22 43 75 72 20 3d 20 22  |H CARS"'"Cur = "|
000007a0  3b 6e 63 61 72 73 3b 8a  38 29 3b 22 20 4d 61 78  |;ncars;.8);" Max|
000007b0  20 3d 20 22 3b 6d 61 78  6e 3b 8a 31 38 29 3b 22  | = ";maxn;.18);"|
000007c0  20 41 76 65 20 3d 20 22  3b a4 61 76 65 28 6e 61  | Ave = ";.ave(na|
000007d0  76 65 29 3b 22 20 22 0d  03 3e 58 f1 20 8a 30 2c  |ve);" "..>X. .0,|
000007e0  32 29 3b 22 53 4f 55 54  48 20 43 41 52 53 22 27  |2);"SOUTH CARS"'|
000007f0  22 43 75 72 20 3d 20 22  3b 73 63 61 72 73 3b 8a  |"Cur = ";scars;.|
00000800  38 29 3b 22 20 4d 61 78  20 3d 20 22 3b 6d 61 78  |8);" Max = ";max|
00000810  73 3b 8a 31 38 29 3b 22  20 41 76 65 20 3d 20 22  |s;.18);" Ave = "|
00000820  3b a4 61 76 65 28 73 61  76 65 29 3b 22 20 22 0d  |;.ave(save);" ".|
00000830  03 48 57 f1 20 8a 30 2c  35 29 3b 22 45 41 53 54  |.HW. .0,5);"EAST|
00000840  20 43 41 52 53 22 27 22  43 75 72 20 3d 20 22 3b  | CARS"'"Cur = ";|
00000850  65 63 61 72 73 3b 8a 38  29 3b 22 20 4d 61 78 20  |ecars;.8);" Max |
00000860  3d 20 22 3b 6d 61 78 65  3b 8a 31 38 29 3b 22 20  |= ";maxe;.18);" |
00000870  41 76 65 20 3d 20 22 3b  a4 61 76 65 28 65 61 76  |Ave = ";.ave(eav|
00000880  65 29 3b 22 20 22 0d 03  52 57 f1 20 8a 30 2c 37  |e);" "..RW. .0,7|
00000890  29 3b 22 57 45 53 54 20  43 41 52 53 22 27 22 43  |);"WEST CARS"'"C|
000008a0  75 72 20 3d 20 22 3b 77  63 61 72 73 3b 8a 38 29  |ur = ";wcars;.8)|
000008b0  3b 22 20 4d 61 78 20 3d  20 22 3b 6d 61 78 77 3b  |;" Max = ";maxw;|
000008c0  8a 31 38 29 3b 22 20 41  76 65 20 3d 20 22 3b a4  |.18);" Ave = ";.|
000008d0  61 76 65 28 77 61 76 65  29 3b 22 20 22 0d 03 5c  |ave(wave);" "..\|
000008e0  19 f1 20 27 22 53 61 6d  70 6c 65 73 20 3d 20 22  |.. '"Samples = "|
000008f0  3b 63 6f 75 6e 74 0d 03  66 16 f4 20 52 45 50 45  |;count..f.. REPE|
00000900  41 54 20 55 4e 54 49 4c  20 47 45 54 0d 03 70 05  |AT UNTIL GET..p.|
00000910  e1 0d 03 7a 04 0d 03 84  0e dd a4 61 76 65 28 61  |...z.......ave(a|
00000920  76 65 29 0d 03 8e 0a ea  20 6e 2c 6e 25 0d 03 98  |ve)..... n,n%...|
00000930  0e 6e 25 3d 31 30 30 2a  61 76 65 0d 03 a2 0c 6e  |.n%=100*ave....n|
00000940  3d 6e 25 2f 31 30 30 0d  03 ac 06 3d 6e 0d 03 b6  |=n%/100....=n...|
00000950  04 0d 03 c0 22 f4 20 47  72 61 70 68 69 63 61 6c  |....". Graphical|
00000960  20 64 69 73 70 6c 61 79  20 70 72 6f 63 65 64 75  | display procedu|
00000970  72 65 73 0d 03 ca 04 0d  03 d4 10 dd f2 64 72 61  |res..........dra|
00000980  77 5f 77 6f 72 6c 64 0d  03 de 22 f4 20 44 72 61  |w_world...". Dra|
00000990  77 73 20 63 75 72 72 65  6e 74 20 73 74 61 74 65  |ws current state|
000009a0  20 6f 66 20 77 6f 72 6c  64 0d 03 e8 1a c8 93 20  | of world...... |
000009b0  78 6c 6f 77 2c 79 6c 6f  77 2c 73 69 64 65 2c 73  |xlow,ylow,side,s|
000009c0  69 64 65 0d 03 f2 10 f2  64 72 61 77 5f 6c 69 67  |ide.....draw_lig|
000009d0  68 74 73 0d 03 fc 0e f2  64 72 61 77 5f 63 61 72  |hts.....draw_car|
000009e0  73 0d 04 06 05 87 0d 04  10 05 e1 0d 04 1a 04 0d  |s...............|
000009f0  04 24 0f dd f2 64 72 61  77 5f 63 61 72 73 0d 04  |.$...draw_cars..|
00000a00  2e 35 f2 65 77 63 61 72  73 28 65 63 61 72 73 2c  |.5.ewcars(ecars,|
00000a10  6f 6c 64 65 63 61 72 73  2c 78 6c 6f 77 2b 73 69  |oldecars,xlow+si|
00000a20  64 65 2b 63 61 72 77 69  64 74 68 2b 6f 66 66 73  |de+carwidth+offs|
00000a30  65 74 29 0d 04 38 43 f2  65 77 63 61 72 73 28 77  |et)..8C.ewcars(w|
00000a40  63 61 72 73 2c 6f 6c 64  77 63 61 72 73 2c 78 6c  |cars,oldwcars,xl|
00000a50  6f 77 2d 63 61 72 77 69  64 74 68 20 2d 77 63 61  |ow-carwidth -wca|
00000a60  72 73 2a 28 63 61 72 6c  65 6e 67 74 68 2b 6f 66  |rs*(carlength+of|
00000a70  66 73 65 74 29 29 0d 04  42 35 f2 6e 73 63 61 72  |fset))..B5.nscar|
00000a80  73 28 6e 63 61 72 73 2c  6f 6c 64 6e 63 61 72 73  |s(ncars,oldncars|
00000a90  2c 79 6c 6f 77 2b 73 69  64 65 2b 63 61 72 77 69  |,ylow+side+carwi|
00000aa0  64 74 68 2b 6f 66 66 73  65 74 29 0d 04 4c 42 f2  |dth+offset)..LB.|
00000ab0  6e 73 63 61 72 73 28 73  63 61 72 73 2c 6f 6c 64  |nscars(scars,old|
00000ac0  73 63 61 72 73 2c 79 6c  6f 77 2d 63 61 72 77 69  |scars,ylow-carwi|
00000ad0  64 74 68 2d 73 63 61 72  73 2a 28 63 61 72 6c 65  |dth-scars*(carle|
00000ae0  6e 67 74 68 2b 6f 66 66  73 65 74 29 29 0d 04 56  |ngth+offset))..V|
00000af0  05 e1 0d 04 60 04 0d 04  6a 17 dd f2 65 77 63 61  |....`...j...ewca|
00000b00  72 73 28 6e 2c 6f 6c 64  6e 2c 78 6c 29 0d 04 74  |rs(n,oldn,xl)..t|
00000b10  0a ea 20 78 2c 78 68 0d  04 7e 0e e7 20 6e 3c 6f  |.. x,xh..~.. n<o|
00000b20  6c 64 6e 20 8c 0d 04 88  0c e6 20 62 6c 61 63 6b  |ldn ...... black|
00000b30  3a 0d 04 92 2f e7 20 78  6c 20 3c 20 78 6c 6f 77  |:.../. xl < xlow|
00000b40  20 8c 20 c8 93 20 c8 90  20 30 2c 79 6c 6f 77 2c  | . .. .. 0,ylow,|
00000b50  78 6c 6f 77 2d 6f 66 66  73 65 74 2c 73 69 64 65  |xlow-offset,side|
00000b60  0d 04 9c 35 e7 20 78 6c  20 3e 78 6c 6f 77 20 8c  |...5. xl >xlow .|
00000b70  20 c8 93 20 c8 90 20 78  6c 6f 77 2b 73 69 64 65  | .. .. xlow+side|
00000b80  2b 6f 66 66 73 65 74 2c  79 6c 6f 77 2c 36 34 30  |+offset,ylow,640|
00000b90  2c 73 69 64 65 0d 04 a6  05 cd 0d 04 b0 0c e6 20  |,side.......... |
00000ba0  79 65 6c 6c 6f 77 0d 04  ba 0b e7 20 6e 3d 30 20  |yellow..... n=0 |
00000bb0  e1 0d 04 c4 24 78 68 20  3d 20 78 6c 2b 28 6e 2d  |....$xh = xl+(n-|
00000bc0  31 29 2a 28 63 61 72 6c  65 6e 67 74 68 2b 6f 66  |1)*(carlength+of|
00000bd0  66 73 65 74 29 0d 04 ce  26 e3 20 78 20 3d 20 78  |fset)...&. x = x|
00000be0  6c 20 b8 20 78 68 20 88  20 28 63 61 72 6c 65 6e  |l . xh . (carlen|
00000bf0  67 74 68 2b 6f 66 66 73  65 74 29 0d 04 d8 33 c8  |gth+offset)...3.|
00000c00  93 20 c8 90 20 78 2c 79  6c 6f 77 2b 73 69 64 65  |. .. x,ylow+side|
00000c10  2f 32 2d 63 61 72 77 69  64 74 68 2c 63 61 72 6c  |/2-carwidth,carl|
00000c20  65 6e 67 74 68 2c 63 61  72 77 69 64 74 68 0d 04  |ength,carwidth..|
00000c30  e2 07 ed 20 78 0d 04 ec  05 e1 0d 04 f6 04 0d 05  |... x...........|
00000c40  00 17 dd f2 6e 73 63 61  72 73 28 6e 2c 6f 6c 64  |....nscars(n,old|
00000c50  6e 2c 79 6c 29 0d 05 0a  0a ea 20 79 2c 79 68 0d  |n,yl)..... y,yh.|
00000c60  05 14 0e e7 20 6e 3c 6f  6c 64 6e 20 8c 0d 05 1e  |.... n<oldn ....|
00000c70  0c e6 20 62 6c 61 63 6b  3a 0d 05 28 2f e7 20 79  |.. black:..(/. y|
00000c80  6c 20 3c 20 79 6c 6f 77  20 8c 20 c8 93 20 c8 90  |l < ylow . .. ..|
00000c90  20 78 6c 6f 77 2c 30 2c  73 69 64 65 2c 79 6c 6f  | xlow,0,side,ylo|
00000ca0  77 2d 6f 66 66 73 65 74  0d 05 32 35 e7 20 79 6c  |w-offset..25. yl|
00000cb0  20 3e 79 6c 6f 77 20 8c  20 c8 93 20 c8 90 20 78  | >ylow . .. .. x|
00000cc0  6c 6f 77 2c 79 6c 6f 77  2b 73 69 64 65 2b 6f 66  |low,ylow+side+of|
00000cd0  66 73 65 74 2c 73 69 64  65 2c 35 31 32 0d 05 3c  |fset,side,512..<|
00000ce0  05 cd 0d 05 46 0c e6 20  79 65 6c 6c 6f 77 0d 05  |....F.. yellow..|
00000cf0  50 0b e7 20 6e 3d 30 20  e1 0d 05 5a 24 79 68 20  |P.. n=0 ...Z$yh |
00000d00  3d 20 79 6c 2b 28 6e 2d  31 29 2a 28 63 61 72 6c  |= yl+(n-1)*(carl|
00000d10  65 6e 67 74 68 2b 6f 66  66 73 65 74 29 0d 05 64  |ength+offset)..d|
00000d20  26 e3 20 79 20 3d 20 79  6c 20 b8 20 79 68 20 88  |&. y = yl . yh .|
00000d30  20 28 63 61 72 6c 65 6e  67 74 68 2b 6f 66 66 73  | (carlength+offs|
00000d40  65 74 29 0d 05 6e 33 c8  93 20 c8 90 20 78 6c 6f  |et)..n3.. .. xlo|
00000d50  77 2b 73 69 64 65 2f 32  2d 63 61 72 77 69 64 74  |w+side/2-carwidt|
00000d60  68 2c 79 2c 63 61 72 77  69 64 74 68 2c 63 61 72  |h,y,carwidth,car|
00000d70  6c 65 6e 67 74 68 0d 05  78 07 ed 20 79 0d 05 82  |length..x.. y...|
00000d80  05 e1 0d 05 8c 04 0d 05  96 11 dd f2 64 72 61 77  |............draw|
00000d90  5f 6c 69 67 68 74 73 0d  05 a0 11 ea 20 65 77 63  |_lights..... ewc|
00000da0  6f 6c 2c 6e 73 63 6f 6c  0d 05 aa 0b c8 8e 20 65  |ol,nscol...... e|
00000db0  77 20 ca 0d 05 b4 1f c9  20 b9 3a 20 65 77 63 6f  |w ...... .: ewco|
00000dc0  6c 3d 67 72 65 65 6e 3a  20 6e 73 63 6f 6c 3d 72  |l=green: nscol=r|
00000dd0  65 64 0d 05 be 1f c9 20  a3 3a 20 65 77 63 6f 6c  |ed..... .: ewcol|
00000de0  3d 72 65 64 3a 20 6e 73  63 6f 6c 3d 67 72 65 65  |=red: nscol=gree|
00000df0  6e 0d 05 c8 05 cb 0d 05  d2 0b e6 20 6e 73 63 6f  |n.......... nsco|
00000e00  6c 0d 05 dc 38 c8 93 20  c8 90 20 78 6c 6f 77 2b  |l...8.. .. xlow+|
00000e10  32 2a 6f 66 66 73 65 74  2c 79 6c 6f 77 2b 6f 66  |2*offset,ylow+of|
00000e20  66 73 65 74 2c 73 69 64  65 2d 34 2a 6f 66 66 73  |fset,side-4*offs|
00000e30  65 74 2c 6f 66 66 73 65  74 0d 05 e6 3f c8 93 20  |et,offset...?.. |
00000e40  c8 90 20 78 6c 6f 77 2b  32 2a 6f 66 66 73 65 74  |.. xlow+2*offset|
00000e50  2c 79 6c 6f 77 2b 73 69  64 65 2d 32 2a 6f 66 66  |,ylow+side-2*off|
00000e60  73 65 74 2c 73 69 64 65  2d 34 2a 6f 66 66 73 65  |set,side-4*offse|
00000e70  74 2c 6f 66 66 73 65 74  0d 05 f0 0b e6 20 65 77  |t,offset..... ew|
00000e80  63 6f 6c 0d 05 fa 38 c8  93 20 c8 90 20 78 6c 6f  |col...8.. .. xlo|
00000e90  77 2b 6f 66 66 73 65 74  2c 79 6c 6f 77 2b 32 2a  |w+offset,ylow+2*|
00000ea0  6f 66 66 73 65 74 2c 6f  66 66 73 65 74 2c 73 69  |offset,offset,si|
00000eb0  64 65 2d 34 2a 6f 66 66  73 65 74 0d 06 04 3f c8  |de-4*offset...?.|
00000ec0  93 20 c8 90 20 78 6c 6f  77 2b 73 69 64 65 2d 32  |. .. xlow+side-2|
00000ed0  2a 6f 66 66 73 65 74 2c  79 6c 6f 77 2b 32 2a 6f  |*offset,ylow+2*o|
00000ee0  66 66 73 65 74 2c 6f 66  66 73 65 74 2c 73 69 64  |ffset,offset,sid|
00000ef0  65 2d 34 2a 6f 66 66 73  65 74 0d 06 0e 05 e1 0d  |e-4*offset......|
00000f00  06 18 04 0d ff                                    |.....|
00000f05