text-software ✓ verified on-chain
BASIC creature simulator code
10 REM The v ariables in life ' life the lifespan of a creature 30 ' mates the number of mates a creature ne eds to breed 40 'mo ve the type of land a creature can be on (1=earth 2=water 3= all) 50 'foodtype t he type of food a cr eature can eat 60 ' f2breed the amount o f food a creature ne eds to breed 70 'a2 breed the age a crea ture needs to breed 80 'cy(i) the y loc ation of a creature 90 'cx(i) the x loc ation of a creature 100 'cf(i) the amou nt of food a creatur e has 110 'ca(i) th e age of a creature 120 CLS 130 COLOR 14, 0, 0 140 CLS 50 LOCATE 2, 30 PRINT "Life" 170 C OLOR 7, 0, 0 180 LO CATE 20, 20 190 INP UT "Do you want to s tart (y/n) ? ", STAR 200 IF START$ = "n" THEN END 'it wil l be gosub 210 REM 220 REM Setting att ributes 230 LIFE = 240 MATES = 0 0 MOVE = 1 260 FOOD TYPE = 1 270 F2BREE D = 10 280 A2BREED 290 F# = 10 0 C# = 5 305 CMUTA 310 EPERYEAR = 320 REM 330 GOSU B 360 350 REM 360 REM placing creature 370 COLOR 5, 6, 0 380 CLS 390 COLOR 14, 0, 0 400 FOR I = 1 TO C# 410 RAND OMIZE TIMER 420 Y = INT(RND * 21) 430 IF Y < 15 THEN GOTO 440 X = INT(RND * 61) 450 IF X < 1 5 THEN GOTO 440 LOCATE Y, X 470 CY (I) = Y 'This saves the creatures y CX(I) = X 'This sav es the creatures x 490 CF(I) = 10 500 CA(I) = 0 510 PRINT CHR$(2) 520 NEXT I '530 RETURN 540 R 550 REM This pla ces the food 560 CO LOR 2, 0, 0 570 FOR I = 1 TO F# 580 RA NDOMIZE TIMER 590 Y = INT(RND * 21) 0 IF Y < 15 THEN GOT O 590 610 X = INT(R ND * 61) 620 IF X < 15 THEN GOTO 610 30 LOCATE Y, X 640 FY(I) = Y 'This save s the foods y 650 F X(I) = X 'This saves the foods x 660 PR INT CHR$(5) 670 NEX 680 REM 690 RE M Starts trapping 00 ON KEY(1) GOSUB 1 710 KEY(1) ON 720 REM prompts to s tart 730 LOCATE 1, 740 PRINT "Press F1 to pause. " 750 760 REM checks the creatures 770 R EM can it breed FOR I = 1 TO C# 0 IF CA(I) > A2BREED THEN GOTO 810 800 GOTO 960 810 IF CF( I) > F2BREED THEN GO TO 830 820 GOTO 960 830 FOOD# = FOOD# - F2BREED 840 RANDO MIZE 'TIMER 850 MUT A = INT(RND * CMUTA) 860 IF MUTA <> 1 T HEN GOTO 920 'Check s to see if it mutat 870 LIFE = INT(R ND * 101) 880 MATES = INT(RND * 3) MOVE = INT(RND * 4) 900 FOOD = INT(RND * 4) 910 A = C# 20 C# = 1 930 GOSUB 360 940 C# = A 0 NEXT I 960 REM 70 REM moves the cre atures 980 FOR I = 1 TO C# 990 RANDOMI ZE TIMER 1000 A = I NT(RND * 5) 1010 IF A = 1 THEN CY(I) = CY(I) + 1 1020 IF A = 2 THEN CY(I) = CY (I) - 1 1030 IF A = 3 THEN CX(I) = CX(I ) + 1 1040 IF A = 4 THEN CX(I) = CX(I) 1050 GOSUB 1380 1060 NEXT I 1070 REM ********** 1080 REM is the creature on food 1090 FOR I = 1 TO C# 1100 FOR A = 1 TO F# 1110 I F CY(I) = FY(A) THEN YES = 1 1120 IF CX (I) = FX(A) THEN YES = YES + 1 1130 IF YES = 2 THEN GOSUB 1 1140 NEXT A 50 NEXT I 1160 GOSU B 1170 1165 GOTO 12 1170 REM giving the creature food 180 CF(I) = CF(I) + 1190 COLOR 2, 0, 1200 LOCATE FY(A ), FX(A) 1210 PRINT " " 1220 FY(A) = 0 'DELETEs the foods 1230 FX(A) = 0 'DELETEs the foods x 1240 RETURN 1250 REM dos it die 1260 FOR I = 1 TO C# 70 IF CF(I) < 9 THEN GOSUB 1300 1280 NE XT I 1290 GOTO 1340 1300 COLOR 14, 0, 1310 LOCATE CY(I) , CX(I) 1320 PRINT 1330 RETURN 40 REM this takes aw ay x food from a cre ature 1350 FOR I = 1 TO C# 1360 IF CA( I) MOD EPERYEAR > 0 THEN CF(I) = CF(I) - 1370 NEXT I 0 REM this redraws t he SCREEN 1385 COLO R 14, 6, 0 1390 CLS 1400 FOR I = 1 TO 1410 COLOR 14, 6 1420 LOCATE CY( I), CX(I) 1430 PRIN T CHR$(2) 1460 NEXT 1464 LOCATE 1, 1 1465 INPUT "gsf", 1470 GOTO 760 80 COLOR 7, 0, 0 90 END
10 REM The variables in life ...
Non-functional/buggy BASIC.