home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1995 January
/
1995-01b.d64
/
life
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
5KB
|
151 lines
30 rem life guide 10/86 p. 60
35 poke53280,6:poke53281,0:poke53272,29:poke53270,199:poke52,47
40 l$="life "
45 print"[147][154]"l$
50 poke56334,peek(56334)and254:poke1,peek(1)and251
55 x=41971:poke782,0:poke88,0:poke90,0
60 poke781,17:poke91,224:poke89,64:sysx
65 poke1,peek(1)or4:poke56334,peek(56334)or1
70 gosub460
75 l=14*1024:forx=ltol+242:readr:pokex,r:next
80 d$="[154]":n$=chr$(0)
85 forx=1to6:a$=a$+"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@":next
90 c=5:de=60:j=56320:l(1)=42
95 rem intro
100 printd$" instructions y/n "
105 gosub390:gosub350
110 sysl+72
115 forx=1to232:t=ti+300/x
120 getg$:gosub440:ifg$="y"org$="n"orpeek(j)=111then140
125 ift>tithen120
130 sysl
135 nextx:goto105
140 ifg$="y"thengosub 485
145 rem draw mode
150 gosub390
155 print""l$," draw mode"d$"f keys: 1=new 3=color 5=help 7=run
160 [129]d[178]1[164]1e3:[130]
165 [153]d$"f keys: 1=new 3=color 5=help q=quit":[129]d[178]1[164]1e3:[130]
170 [153]d$"f keys: 1=new 3=color 5=help 7=run
175 x=11:y=19
180 sc=1064+x*40+y:pokesc,l(f)+128
185 gosub425:pokesc,l(f)
190 ifa=17orp=125thenifx<22thenx=x+1:goto180
195 ifa=145orp=126thenifxthenx=x-1:goto180
200 ifa=29orp=119thenify<37theny=y+1:goto180
205 ifa=157orp=123thenifytheny=y-1:goto180
210 ifa=19then175
215 ifa=13orp=111thenf=1-f
220 ifa=133thengosub390:goto175
225 ifa=134thenc=1-c*(c<15):gosub390:goto175
230 ifa=135thengosub 485:gosub390:goto150
235 ifa=136then280
240 ifg$="t"thengosub390:gosub350
245 ifg$="l"thengosub460
250 ifg$<>"g"thenifg$<>"s"then180
255 ifx<2orx>21ory<3ory>36then180
260 f=0:forz=39to41:pokesc+z,42:next:pokesc+1,42
265 ifg$="g"thenpokesc-40,42:goto180
270 pokesc-3,42:pokesc+38,42:pokesc-39,42:pokesc-80,42:goto180
275 rem life loop
280 print"[154]"l$"generation population":f=0
285 printd$"f keys: 1=draw 3=slow 5=fast 7=stop":sysl+72:t=ti
290 print""tab(18)" "tab(34)" "
295 print"[154]"tab(17)g tab(33)peek(249)+peek(250)*256"[157]":g=g+1
300 getg$:ifg$=""andpeek(j)=127then335
305 a=asc(g$+n$)
310 ifa=133then155
315 ifa=134thende=60
320 ifa=135thende=0:t=ti
325 ifa=136orpeek(j)=111thengosub400
330 ifa=3then445
335 ift>tithen300
340 sysl:t=ti+de:goto290
345 rem print life
350 print"":poke646,c
355 print"*@@@@@*@@****@@****
360 [153]"*@@@@@*@@*@@@@@*
365 print"*@@@@@*@@***@@@***
370 [153]"*@@@@@*@@*@@@@@*
375 print"****@@*@@*@@@@@****
380 [142]
385 [143] print screen
390 f[178]1:g[178]0:[151]646,c:[153]""a$a$a$[201](a$,200);:[142]
395 [143] stop
400 [153]d$,,," 7=run
405 ifpeek(j)=111then405
410 gosub425:printd$,,," 7=stop":ford=1to1e3:next
415 printd$,,," q=quit":ford=1to1e3:next:printd$,,," 7=stop":return
420 rem get
425 k=0
430 getg$:p=peek(j):ifg$=""andp=127thenk=1:goto430
435 ifkthenifp<127thenford=1to222:next
440 a=asc(g$+n$):ifa<>81thenreturn
445 poke53272,21:poke53270,200
450 print"[147]"tab(14)"that's life":ford=1to4e3:next:end
455 rem poke chrs
460 restore:lf=1-lf
465 forz=1to4:readch:fork=0to7:readd:poke12288+8*ch+k,dand(127+128*lf):next
470 iflf=0thenpoke12288+ch*8+7,0
475 next
480 return
485 gosub390:printl$"[154][146]life@is@asimulationof@thelifeofa
490 [153]"colonyofcellsfollowingtheserules:"
495 [153]"list1.survival:acellcellwith2or3
500 print,"neighborssurvives",,"tothenextgeneration."
505 printspc(9)"**[145][157][154]*_thiscellhas2neighbors.
510 [153]"list2.birth:acellisbornineach
515 print,"areawith3neighbors.
520 [153][166]8)"**cmdcmd*cont wait_thisareahas3neighbors."
525 [153]"printputaninitialcolonyonthescreenin
530 print"thedrawmode,usingthecrsrkeysor
535 [153]"joystick2.turndrawon/offwiththe
540 print"joystickbuttonorreturnkey.
545 [153]"contthecomputerwilldisplaytheliving
550 print"cellsofeachgeneration.
555 [153]d$"cont press <space> "
560 [151]198,0:[141]425:[141]390
565 [141]390
570 [153]"listcommonstableforms:
575 poke646,c:print,,,"**",
580 print"********
585 [153]"**********
590 print"******
595 [153]"contbeehiveboxblockboatloaf"
600 [153]"listoscillators:",:[151]646,c
605 [151]646,c
610 [153]"***
615 print,"*******
620 [153]"**********
625 print,,"@@**@@@@@@@@@*
630 [153]"contblinkertoadbeaconclock
635 print"[155]other forms:",,:poke646,c
640 print"*
645 [153],"*****",
650 [153]"**********
655 print"************",
660 print"[154]cp485672pi[176][155]g[154]lider[155]s[154]paceship
665 [153]"listdraw@commands:conttantantantan<
670 printspc(19)"[157][173][155]l[154]ineson/off[155]t[154]itle
675 [141]425:[142]
680 [131] 0,128,128,128,128,128,128,128,170
685 [131] 42,128,156,190,190,190,156,128,170
690 [131] 128,255,255,255,255,255,255,255,255
695 [131] 170,255,227,193,193,193,227,255,255
700 [143] ml data
705 [131] 169,4,133,252,169,40,133,251,169,64,133,254,169,40,133,253,160
710 [131] ,177,253,170,224,2,240,10,169,42,224,3,240,2,169,,145,251
715 [131] 24,165,253,105,1,133,253,165,254,105,,133,254,24,165,251,105,1
720 [131] 133,251,165,252,105,,133,252,201,7,208,207,165,251,201,192,208
725 [131] 201,234,169,,133,250,133,249,169,63,133,254,169,255,133,253,169
730 [131] 0,160,,145,253,24,165,253,105,1,133,253,165,254,105,,133,254
735 [131] 201,68,208,233,169,4,133,252,169,40,133,251,169,63,133,254,169
740 [131] 255,133,253,160,,177,251,201,42,208,30,24,165,249,105,1,133
745 [131] 249,165,250,105,,133,250,24,162,0,188,235,56,177,253,105,1,145
750 [131] 253,232,224,8,208,242,24,165,253,105,1,133,253,165,254,105,
755 [131] 133,254,24,165,251,105,1,133,251,165,252,105,,133,252,201,7,208
760 [131] 188,165,251,201,192,208,182,234
765 [131] 169,64,133,254,169,78,133,253,169,,160,,145,253,200,145,253,24
770 [131] 165,253,105,40,133,253,165,254,105,,133,254,201,68,208,230,96
775 [131] ,1,2,40,42,80,81,82