10 !**** NICHE--AN ECOLOGICAL GAME
20 !**** JAMES D. LEHMAN, DEPT OF BIOLOGICAL SCIENCES
30 !**** PURDUE NIVERSITY, W. LAFAYETTE, INDIANA 48906
40 RANDOMIZE
50 T=0:K=0:P=100
60 ?:?:? ">>>>>>>>>>>>>>>>  NICHE  <<<<<<<<<<<<<<<<<":?
70 ?TAB(5);"AN ECOLOGICAL GAME":?:?:?
80 ?"WELCOME TO THE GAME OF NICHE!"
90 ?"DO YOU NEED INSTRUCTIONS (YES OR NO) ";
100 INPUT I$
110 ON ERROR GOTO 90
120 IF I$="NO" OR I$="N" THEN 520
130 ?TAB(-1,0):?:?:?"  INSTRUCTIONS FOR NICHE---":?
140 ?"NICHE REFERS TO ALL OF THE ECOLOGICAL VARIABLES WHICH"
150 ?"RELATE TO A GIVEN ORGANISM--ITS HABITAT, LIVING SPACE,"
160 ?"AND ROLE IN THE ECOSYSTEM.  IN THE GAME OF NICHE YOUR JOB"
170 ?"IS TO FIT A SELECTED ORGANISM INTO ITS NICHE.  YOU SELECT"
180 ?"ONE OF 5 ORGANISMS AND RECEIVE A SMALL POPULATION (100"
190 ?"INDIVIDUALS) OF THE ORGANISMS.  YOR GOAL IN NICHE IS TO"
200 ?"MAXIMIZE THE SIZE OF YOUR POPULATION BY PROVIDING IDEAL"
210 ?"CONDITIONS FOR GROWTH.  AT THE BEGINNING OF THE GAME (TURN 1)"
220 ?"AND AT EACH SUBSEQUENT TURN YOU WILL INPUT THE"
230 ?"ENVIRONMENT, RANGE, AND COMPETITOR FOR YOUR POPULATION."
240 ?"ONCE DURING THE GAME, YOU MAY INPUT THE PREDATOR KILL OPTION"
250 ?"THIS WILL REDUCE BUT NOT ELIMINATE THE EFFECTS OF PREDATION"
260 ?"ON YOUR POPULATION FOR THAT TURN ONLY.  AT THE END OF EACH TURN,"
270 ?"THE FOLLOWING INFORMATION WILL BE OUTPUT:  THE AMOUNT OF"
280 ?"FOOD PRESENT IN THE RANGE, THE AMOUNT OF FOOD TAKEN BY"
290 ?"COMPETITIORS, THE AMOUNT OF FOOD AVAILABLE TO YOUR POPULATION,"
300 ?"DEATHS DUE TO PREDAION, DEATHS DUE TO STARVATION AND OTHER"
310 ?"CAUSES, BIRTHS, AND THE NEW TOTAL POPULATION.  OF COUSE,"
320 ?"WHAT YOU INPUT WILL AFFECT THE RESULTS WHICH ARE OUTPUT."
330 ?:?"TO CONTINUE INSTRUCTIONS, HIT RETURN"
340 INPUT G$
350 ON ERROR GOTO 330
360 ?TAB(-1,0)
370 ?:?:?"FOR INSTANCE, IF THE INPUT RANGE IS TOO SMALL FOR YOUR"
380 ?"POPULATION, THERE WILL BE INSUFFICIENT FOOD (100 UNITS PER"
390 ?"ORGANISM IS OPTIMUM) AND SOME STARVATION WILL RESULT."
400 ?"IF THE INPUT RANGE IS TOO LARGE, THERE WILL BE MANY PREDATORS"
410 ?"AND DEATHS DUE TO PREDATION WILL BE HIGH.  THE GAME LASTS"
420 ?"FOR 5 TURNS, EACH OF WHICH CORRESPONDS TO ABOUT 1 TO 2"
430 ?"GENERATIONS OF YOUR ORGANISM.  YOU SHOULD RESPOND TO INPUT"
440 ?"PROMPTS BY TYPING WHAT IS IN THE PARENTHESES FOLLOWING YOUR"
450 ?"CHOICE.  YOU MAY INITIATE EACH NEW TURN BY TYPING GO."
460 ?"GOOD LUCK!! AND, MAY THE BEST ECOLOGIST WIN!!"
470 ?:?:?"TO BEGIN THE GAME, HIT RETURN"
490 INPUT G$
500 ON ERROR GOTO 470
510 ?TAB(-1,0)
520 ?:?:?"HERE WE GO!":?:?
530 !**** SELECTION OF THE ORGANISM
540 ?"WHAT ORGANISM---"
550 ?TAB(5);"PARAMECIUM CAUDATUM (1)"
560 ?TAB(5);"RAINBOW TROUT (2)"
570 ?TAB(5);"ANTEATER (3)"
580 ?TAB(5);"GRAY SQUIRREL (4)"
590 ?TAB(5);"KANGAROO RAT (5)"
600 INPUT O
610 ON ERROR GOTO 640
620 IF O<1 OR O>5 THEN 640
630 GOTO 650
640 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 540
650 !*** SET UP TURN COUNTER AND PRINT TURN
660 T=T+1:?:?:?"TURN  ";T:?:?
670 !***** SELECTION OF ENVIRONMENT
680 ?"WHAT ENVIRONMENT---"
690 ?TAB(5);"FRESH WATER POND (P)"
700 ?TAB(5);"FRESH WATER LAKE (L)"
710 ?TAB(5);"TROPICAL RAIN FOREST (R)"
720 ?TAB(5);"BOREAL CONIFEROUS FOREST (C)"
730 ?TAB(5);"TEMPERATE DECIDUOUS FOREST (T)"
740 ?TAB(5);"NORTH AMERICAN DESERT (D)"
750 ?TAB(5);"TEMPERATE GRASSLAND (G)"
760 INPUT E$
770 ON ERROR GOTO 800
775 IF E$="P" OR E$="L" OR E$="R" OR E$="C" OR E$="T" THEN 810
776 IF E$="D" OR E$="G" THEN 810
800 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 680
810 !***** GOSUB TO SET VALUES OF E, E1, AND U$
820 GOSUB 3000
830 !***** SELECTION OF RANGE SIZE
840 ?:?:?"WHAT RANGE FOR THE WHOLE POPULATION IN ";U$;" ---"
844 IF U$="HECTARS" THEN ?"(1 HECTARE = 10000 SQUARE METERS)"
846 IF U$="DEKASTERES" THEN ?"(1 DEKASTERE = 10 CUBIC METERS)"
850 INPUT R
860 ON ERROR GOTO 890
870 IF R<=0 THEN 890
880 GOTO 900
890 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 840
900 !***** SELECTION OF COMPETITOR (ORGANISM DEPENDENT)
910 !***** AND SETTING OF TRUE OPTIMUM RANGE
920 ?:?:?"WHAT COMPETITOR---"
930 IF O=1 THEN 4000
940 IF O=2 THEN 4100
950 IF O=3 THEN 4190
960 IF O=4 THEN 4300
970 IF O=5 THEN 4400
980 !****  GOSUB TO SET VALUES OF R1 AND R2
990 GOSUB 5000
1000 ! **** SET C1 VALUE
1010 IF C$="C" OR C$="E" OR C$="G" OR C$="I" OR C$="K" OR C$="M" THEN C1=0
1020 IF C$="B" OR C$="D" OR C$="L" OR C$="N" THEN C1=.2
1030 IF C$="F" OR C$="J" THEN C1=.4
1040 IF C$="A" OR C$="H" OR C$="O" THEN C1=.6
1050 !***** CHECK FOR PREVIOUS USE OF PREDATOR KILL
1060 IF K=1 THEN 1140
1070 ?:?:?"PREDATOR KILL (YES OR NO)---"
1080 INPUT K$
1090 IF K$="YES" OR K$="Y" THEN 1120
1100 IF K$="NO" OR K$="N" THEN 1140
1110 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 1070
1120 !***** SET COUNTER K AND SET D1 AT A LOW LEVEL
1130 K=1:D1=INT(.02*P):GOTO 1160
1140 !***** SET D1 AT THE NORMAL LEVEL
1150 D1=INT((.25*RND(1)+.1)*P)+INT(R2*P)
1160 !***** SET VARIABLE VALUES
1170 R1=R/R3:F1=INT(100*R1*P):F2=INT(C1*F1)
1180 F3=F1-F2:F4=F3/(100*P)
1184 IF F4>1 THEN F4=1
1186 D2=INT((1-F4+E1)*P)
1190 !***** GOSUB TO SET F5 VALUE
1200 GOSUB 6000
1210 !***** SET BIRTHS
1220 B=INT(F5*P)
1230 IF E1=1 THEN 1250
1240 GOTO 1260
1250 D=0:D1=0:D2=P
1260 !***** SET POPULATION
1270 P1=P:P=P+B-D1-D2
1280 IF P<0 THEN 1300
1290 GOTO 1340
1300 X=RND(1):Y=RND(1)
1310 IF P1+B=INT(D1*X)+INT(D2*Y) THEN 1330
1320 GOTO 1300
1330 D1=INT(D1*X):D2=INT(D2*Y):P=P1+B-D1-D2
1340 !***** PRINT RESULTS OF TURN
1350 ?TAB(-1,0):?:?:?"RESULTS OF TURN ";T;" ---":?
1360 ?TAB(5);"AMOUNT OF FOOD PRESENT IN RANGE--- ";F1;" UNITS"
1370 ?TAB(5);"AMOUNT OF FOOD TAKEN BY COMPETITORS--- ";F2;" UNITS"
1380 ?TAB(5);"AMOUNT OF FOOD FOR THE POPULATION--- ";F3;" UNITS"
1390 ?TAB(5);"DEATHS DUE TO PREDATION--- ";D1
1400 ?TAB(5);"DEATHS DUE TO STARVATION OR OTHER CAUSES--- ";D2
1410 ?TAB(5);"BIRTHS--- ";B
1420 ?:?TAB(10);"CURRENT POPULATION--- ";P:?:?
1430 !***** CHECK FOR END OF GAME
1440 IF T=5 THEN 1660
1450 !***** CHECK FOR LOSS OR GREAT REDUCTION OF THE POPULATION
1460 IF P=0 THEN 1500
1470 IF P>0 AND P<=10 THEN 1530
1480 IF P>10 AND P<=50 THEN 1560
1490 GOTO 1580
1500 ?"HEY TURKEY, YOU MANAGED TO LET YOUR POPULATION GO TO ZERO!!"
1510 ?"AND, YOU DID IT AFTER ONLY TURN ";T;" !!!!"
1520 GOTO 1670
1530 ?"LOOK OUT TURKEY!  YOUR POPULATION IS DOWN TO A MERE ";P
1540 ?"INDIVIDUALS!  THAT IS EXTREMELY RISKY!!!"
1550 GOTO 1580
1560 ?" YOU HAD BETTER WATCH OUT!  YOUR POPULATION IS DOWN TO ";P
1570 ?"INDIVIDUALS!  TROUBLE IS JUST AROUND THE CORNER."
1580 ?"TO BEGIN TURN ";T+1;" HIT RETURN"
1590 INPUT G$
1600 ON ERROR GOTO 1620
1610 GOTO 660
1620 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 1580
1660 !****** FINAL PERFORMANCE EVALUATION
1670 ?:?"END OF GAME":?:?
1680 IF P=0 THEN 1770
1690 IF P>0 AND P<=25 THEN 1800
1700 IF P>25 AND P<=100 THEN 1820
1710 IF P>100 AND P<=250 THEN 1830
1720 IF P>250 AND P<=500 THEN 1840
1730 IF P>500 AND P<=1000 THEN 1850
1740 IF P>1000 AND P<=5000 THEN 1870
1750 IF P>5000 AND P<=10000 THEN 1880
1760 IF P>10000 THEN 1900
1770 ?"YOU ARE A DISGRACE!  YOU ARE HEREBY DRUMMED OUT OF THE"
1780 ?"AMERICAN COLLEGE OF ECOLOGISTS (ACE) AND MADE A MEMBER"
1790 ?"OF THE AMERICAN SOCIETY OF STUPIDOS (YOU KNOW)!!!":GOTO 1920
1800 ?"THAT'S AWFUL!  THE WILDLIFE MANAGERS OF THE WORLD HAVE"
1810 ?"NOTHING BUT SPITE FOR YOU! ":GOTO 1920
1820 ?"THAT'S VERY POOR!  I HOPE YOU DON'T OWN ANY PETS!":GOTO 1920
1830 ?"THAT'S BARELY PASSABLE! AT LEAST YOU DIDN'T LOSE ANY!":GOTO 1920
1840 ?"NOT BAD!  YOU ARE APPOINTED A JUNIOR ECOLOGIST!":GOTO 1920
1850 ?"PRETTY GOOD JOB FELLA (OR GAL)!  I GUESS WE'LL HAVE TO LET"
1860 ?"YOU JOIN THE ECOLOGIST'S CLUB! ":GOTO 1920
1870 ?"GOOD JOB!!  YOU'RE A TRUE BLUE ECOLOGIST!":GOTO 1920
1880 ?"WOW!!!  TREMENDOUS JOB!  YOU CAN TAKE MARLIN PERKINS' PLACE"
1890 ?"ON WILD KINGDOM WHEN HE RETIRES!!": GOTO 1920
1900 ?"SUPER!!!  SUPERB!!!  FANTASTIC!!!!  MOTHER NATURE HERSELF"
1910 ?"MUST BE ENVIOUS!!"
1920 ?:?:?"DO YOU WANT TO PLAY ANOTHER GAME OF NICHE (YES OR NO)";
1930 INPUT G$
1940 ON ERROR GOTO 1920
1950 IF G$="YES" OR G$="Y" THEN 10
1960 GOTO 9999
3000 IF E$="P" THEN E=1
3010 IF E$="L" THEN E=2
3020 IF E$="R" THEN E=3
3030 IF E$="C" OR E$="T" THEN E=4
3040 IF E$="D" OR E$="G" THEN E=5
3050 IF O=1 AND O+E<4 THEN E1=0
3060 IF O=1 AND O+E>=4 THEN E1=1
3070 IF O=2 AND O+E=4 THEN E1=0  
3080 IF O=2 AND O+E=3 THEN E1=.33
3090 IF O=2 AND O+E>4 THEN E1=1
3100 IF O=3 AND O+E=6 THEN E1=0
3110 IF O=3 AND O+E<>6 THEN E1=1
3120 IF O=4 AND O+E=8 THEN E1=0
3130 IF O=4 AND O+E=7 THEN E1=.33
3140 IF O=4 AND O+E>8 THEN E1=1
3150 IF O=4 AND O+E<7 THEN E1=1
3160 IF O=5 AND O+E=10 THEN E1=0
3170 IF O=5 AND O+E=9 THEN E1=.5
3180 IF O=5 AND O+E=8 THEN E1=.5
3190 IF O=5 AND O+E<8 THEN E1=1
3200 IF O=3 OR O=4 OR O=5 THEN U$="HECTARES"
3210 IF O=2 THEN U$="DEKASTERES"
3220 IF O=1 THEN U$="CUBIC CENTIMETERS"
3230 RETURN
4000 ?TAB(5);"PARAMECIUM AURELIA (A)"
4010 ?TAB(5);"AMOEBA (B)"
4020 ?TAB(5);"PARAMECIUM BURSARIA (C)"
4030 INPUT C$
4040 ON ERROR GOTO 4070
4045 IF C$="A" OR C$="B" OR C$="C" THEN 4080
4070 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 920
4080 R3=P:GOTO 980
4100 ?TAB(5);"SNAPPING TURTLE (D)"
4110 ?TAB(5);"CATFISH (E)"
4120 ?TAB(5);"SOCKEYE SALMON (F)"
4130 INPUT C$
4140 ON ERROR GOTO 4170
4150 IF C$="D" OR C$="E" OR C$="F" THEN 4180
4170 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 920
4180 R3=2000*P:GOTO 980
4190 ?TAB(5);"PACA (G)"
4200 ?TAB(5);"ARMADILLO (H)"
4210 ?TAB(5);"TAPIR (I)"
4230 INPUT C$
4240 ON ERROR GOTO 4270
4250 IF C$="G" OR C$="H" OR C$="I" THEN 4280
4270 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 920
4280 R3=.6*P:GOTO 980
4300 ?TAB(5);"CHIPMUNK (J)"
4310 ?TAB(5);"TURKEY (K)"
4320 ?TAB(5);"MOUSE (L)"
4330 INPUT C$
4340 ON ERROR GOTO 4370
4360 IF C$="J" OR C$="K" OR C$="L" THEN 4380
4370 ?"IMPORPER RESPONSE--TRY AGAIN.":GOTO 920
4380 R3=.05*P:GOTO 980
4400 ?TAB(5);"PECCARY (M)"
4410 ?TAB(5);"JACKRABBIT (N)"
4420 ?TAB(5);"POCKET MOUSE (O)"
4430 INPUT C$
4440 ON ERROR GOTO 4470
4460 IF C$="M" OR C$="N" OR C$="O" THEN 4480
4470 ?"IMPROPER RESPONSE--TRY AGAIN.":GOTO 920
4480 R3=.1*P:GOTO 980
5000 R1=R/R3
5010 IF R1>0 AND R1<=1.33 THEN R2=0
5020 IF R1>1.33 AND R1<=1.67 THEN R2=.05
5030 IF R1>1.67 AND R1<=2 THEN R2=.075
5040 IF R1>2 AND R1<=5 THEN R2=.1
5050 IF R1>5 AND R1<=10 THEN R2=.2
5060 IF R1>10 AND R1<=25 THEN R2=.3
5070 IF R1>25 THEN R2=.4
5080 RETURN
6000 IF F4>1 THEN F4=1
6010 IF F4=0 THEN F5=0
6020 IF F4>0 AND F4<=.25 THEN F5=.1
6030 IF F4>.25 AND F4<=.5 THEN F5=.33
6040 IF F4>.5 AND F4<=.7 THEN F5=.67
6050 IF F4>.7 AND F4<=.9 THEN F5=1
6060 IF F4>.9 AND F4<=1 THEN F5=2
6070 RETURN
9999 END