set text font "arial" : set text size 12 : set text transparent
 
#constant graphX 340
#constant graphY 300
#constant splitS 50
#constant dotSize 2.5
 
#constant white rgb(255,255,255)
#constant red1 rgb(175,55,55)
#constant blue1 rgb(55,175,55)
#constant green1 rgb(55,55,175)
 
#constant DRR 1.3
#constant WRR 1.0
#constant TRR 1.1
 
type constantV
 
   averageRain as integer
   strtHunters as integer
 
   startingDeer as integer
   startingWolf as integer
   startingTree as integer
 
   deerEat as float
   wolfEat as float
   huntEat as float
   `treeWat as integer
 
   `deerRepro as integer
   `wolfRepro as integer
   `treeRepro as integer
 
endtype
 
type dynamicV
 
   numDeer as float
   numWolf as float
   numTree as float
   numHunt as float
   numRain as float
 
endtype
 
type loc
 
   x as integer
   y as float
 
   dotS as float
 
endtype
 
type graph
 
   d as loc
   w as loc
   t as loc
 
endtype
 
global constant as constantV
 
 
global stop as boolean
global currYear as integer
 
`global blah1 as float
`global blah2 as float
`global blah3 as float
 
_start:
dim dynamic(10) as dynamicV
dim graphP(10) as graph
 
initGraph()
initStats()
currYear = 0
stop = 0
 
cls
 
input "Average Rainfall: ",temp$
 
constant.averageRain = int(val(temp$))
 
`input "Starting Hunters: ",temp$
 
`constant.strtHunters = int(val(temp$))
 
`input "Deer per Hunter (*100): ",temp$
 
`constant.huntEat = val(temp$)/100
 
````````````````````````````````````````````````
cls
 
input "#of Starting Deer: ",temp$
 
constant.startingDeer = int(val(temp$))
 
input "#of Starting Wolves: ",temp$
 
constant.startingWolf = int(val(temp$))
 
input "#of Starting Trees: ",temp$
 
constant.startingTree = int(val(temp$))
 
`````````````````````````````````````````````````
cls
 
input "Deer Food Consumption (trees/year for 1 deer)(*100): ",temp$
 
constant.deerEat = val(temp$)/100
 
input "Wolf Food Consumption (deer/year for 1 wolf)(*100): ",temp$
 
constant.wolfEat = val(temp$)/100
 
`input "Tree Water Consumption (water/year for 1 tree): ",temp$
 
`constant.treeWat = int(val(temp$))
 
`````````````````````````````````````````````
cls
 
`input "Deer Reproduction Rate (% of population): ",temp$
 
`constant.deerRepro = int(val(temp$))
 
`input "Wolf Reproduction Rate (% of population): ",temp$
 
`constant.wolfRepro = int(val(temp$))
 
`input "Tree Reproduction Rate (% of population): ",temp$
 
`constant.treeRepro = int(val(temp$))
 
``````````````````````````````````````````````
`cls
 
dynamic(0).numDeer = constant.startingDeer
dynamic(0).numWolf = constant.startingWolf
dynamic(0).numTree = constant.startingTree
dynamic(0).numHunt = constant.strtHunters
dynamic(0).numRain = constant.averageRain
 
graphP(0).d.x = (n*30)+30+50+50-(dotSize/2)
graphP(0).w.x = (n*30)+30+50+50-(dotSize/2)
graphP(0).t.x = (n*30)+30+50+50-(dotSize/2)
 
graphP(0).d.y = 0
graphP(0).w.y = 0
graphP(0).t.y = 0
 
``````````````````````````````````````````````
 
 
 
repeat
 
   if currYear < 10 : updateEquations(currYear) : endif
   if done = 0
      drawGraph(currYear)
      stats(currYear)
 
      repeat : if shiftkey() : stop = 1 : view = 1 : endif : if stop = 1 : exit : endif : until spacekey() > 0
      repeat : if shiftkey() : stop = 1 : view = 1 : endif : if stop = 1 : exit : endif : until spacekey() = 0
 
      if stop = 0 : inc currYear : cls : endif
 
      if currYear = 11 : stop = 1 : currYear = 10 : endif
   else
      stop = 1
   endif
 
until stop = 1
 
repeat : until spacekey() = 0
 
view = 1
while view = 1 and spacekey() = 0
 
   drawGraph(currYear)
   stats(currYear)
   text 0,0,"Finished..."
   center text 320,50,"FINISHED"
 
endwhile
 
cls : delete bitmap 1 : delete bitmap 2 : delete bitmap 3 : set current bitmap 0
undim dynamic(0) : undim graphP(0) : goto _start
 
function initGraph()
 
   create bitmap 1,640,480
   create bitmap 2,640,480
 
   set current bitmap 2
   ink white,white
 
   line 10,0,10,graphY
   line 10,graphY,graphX+10,graphY
   for x = 1 to 6
      line 5,(x*splitS),15,(x*splitS)
      inc x
   next x
   for x = 0 to 5
      line 5,(x*splitS),graphX+10,(x*splitS)
      inc x
   next x
   for x = 1 to 11
      line x*30,graphY,x*30,graphY+10
   next x
 
 
   get image 1,0,0,640,480
   cls
 
   x = 1
   text 1,x*splitS+1,"Deer"
   inc x,2
   text 1,x*splitS+1,"Wolf"
   inc x,2
   text 1,x*splitS+1,"Tree"
 
   for x = 0 to 10
      text 45+30+x*30,graphY+10,str$(x)
   next x
 
   paste image 1,49,0,1
   get image 2,0,0,graphX+56,graphY+20
   cls
   paste image 2,50,100,1
 
 
   set current bitmap 0
 
endfunction
 
function initStats()
 
   create bitmap 3,175,440
 
   set current bitmap 0
 
endfunction
 
function drawGraph(n)
 
   cls
   copy bitmap 2,1
   set current bitmap 1
   ink white,white
 
   graphP(n).d.dotS = dotSize
   graphP(n).w.dotS = dotSize
   graphP(n).t.dotS = dotSize
 
   graphP(n).d.x = (n*30)+30+50+50-(dotSize/2)
   graphP(n).w.x = (n*30)+30+50+50-(dotSize/2)
   graphP(n).t.x = (n*30)+30+50+50-(dotSize/2)
 
   graphP(n).d.y = (dynamic(n).numDeer - dynamic(0).numDeer) / dynamic(0).numDeer : if graphP(n).d.y > 1 : graphP(n).d.y = 1 : inc graphP(n).d.dotS,dotSize : endif
   graphP(n).w.y = (dynamic(n).numWolf - dynamic(0).numWolf) / dynamic(0).numWolf : if graphP(n).w.y > 1 : graphP(n).w.y = 1 : inc graphP(n).w.dotS,dotSize : endif
   graphP(n).t.y = (dynamic(n).numTree - dynamic(0).numTree) / dynamic(0).numTree : if graphP(n).t.y > 1 : graphP(n).t.y = 1 : inc graphP(n).t.dotS,dotSize : endif
 
   `blah1 = (dynamic(n).numDeer - dynamic(0).numDeer) / dynamic(0).numDeer
   `blah2 = (dynamic(n).numWolf - dynamic(0).numWolf) / dynamic(0).numWolf
   `blah3 = (dynamic(n).numTree - dynamic(0).numTree) / dynamic(0).numTree
 
   `break
 
   ink blue1,0 : circle graphP(n).d.x,(1*splitS)+100+(graphP(n).d.dotS/2)-int(graphP(n).d.y*50.0),graphP(n).d.dotS
 
   ink red1,0 : circle graphP(n).w.x,(3*splitS)+100+(graphP(n).w.dotS/2)-int(graphP(n).w.y*50.0),graphP(n).w.dotS
 
   ink green1,0 : circle graphP(n).t.x,(5*splitS)+100+(graphP(n).t.dotS/2)-int(graphP(n).t.y*50.0),graphP(n).t.dotS
 
   if n > 0
      ink blue1,0 : line graphP(n-1).d.x,(1*splitS)+100+(graphP(n).d.dotS/2)-int(graphP(n-1).d.y*50),graphP(n).d.x,(1*splitS)+100+(graphP(n).d.dotS/2)-int(graphP(n).d.y*50)
      ink red1,0 : line graphP(n-1).w.x,(3*splitS)+100+(graphP(n).w.dotS/2)-int(graphP(n-1).w.y*50),graphP(n).w.x,(3*splitS)+100+(graphP(n).w.dotS/2)-int(graphP(n).w.y*50)
      ink green1,0 : line graphP(n-1).t.x,(5*splitS)+100+(graphP(n).t.dotS/2)-int(graphP(n-1).t.y*50),graphP(n).t.x,(5*splitS)+100+(graphP(n).t.dotS/2)-int(graphP(n).t.y*50)
   endif
 
   ink white,0
 
   copy bitmap 1,2
   copy bitmap 1,0
   set current bitmap 0
   center text 320,25,"Year: "+str$(n)
 
endfunction
 
function stats(n)
 
   set current bitmap 3 : cls
 
   if constant.startingDeer * 1.8 < dynamic(n).numDeer : DeerTrend$ = "Excellent" : endif
   if constant.startingDeer * 1.35 < dynamic(n).numDeer and dynamic(n).numDeer <= constant.startingDeer * 1.8 : DeerTrend$ = "Really Good" : endif
   if constant.startingDeer < dynamic(n).numDeer and dynamic(n).numDeer <= constant.startingDeer * 1.35 : DeerTrend$ = "Good" : endif
   if constant.startingDeer = dynamic(n).numDeer : DeerTrend$ = "Indifferent" : endif
   if constant.startingDeer > dynamic(n).numDeer and dynamic(n).numDeer >= constant.startingDeer * 0.65 : DeerTrend$ = "Poor" : endif
   if constant.startingDeer * 0.65 > dynamic(n).numDeer and dynamic(n).numDeer >= constant.startingDeer * 0.2 : DeerTrend$ = "Very Poor" : endif
   if constant.startingDeer * 0.2 > dynamic(n).numDeer : DeerTrend$ = "Horrible" : endif
 
   if constant.startingWolf * 1.8 < dynamic(n).numWolf : WolfTrend$ = "Excellent" : endif
   if constant.startingWolf * 1.35 < dynamic(n).numWolf and dynamic(n).numWolf <= constant.startingWolf * 1.8 : WolfTrend$ = "Really Good" : endif
   if constant.startingWolf < dynamic(n).numWolf and dynamic(n).numWolf <= constant.startingWolf * 1.35 : WolfTrend$ = "Good" : endif
   if constant.startingWolf = dynamic(n).numWolf : WolfTrend$ = "Indifferent" : endif
   if constant.startingWolf > dynamic(n).numWolf and dynamic(n).numWolf >= constant.startingWolf * 0.65 : WolfTrend$ = "Poor" : endif
   if constant.startingWolf * 0.65 > dynamic(n).numWolf and dynamic(n).numWolf >= constant.startingWolf * 0.2 : WolfTrend$ = "Very Poor" : endif
   if constant.startingWolf * 0.2 > dynamic(n).numWolf : WolfTrend$ = "Horrible" : endif
 
   if constant.startingTree * 1.8 < dynamic(n).numTree : TreeTrend$ = "Excellent" : endif
   if constant.startingTree * 1.35 < dynamic(n).numTree and dynamic(n).numTree <= constant.startingTree * 1.8 : TreeTrend$ = "Really Good" : endif
   if constant.startingTree < dynamic(n).numTree and dynamic(n).numTree <= constant.startingTree * 1.35 : TreeTrend$ = "Good" : endif
   if constant.startingTree = dynamic(n).numTree : TreeTrend$ = "Indifferent" : endif
   if constant.startingTree > dynamic(n).numTree and dynamic(n).numTree >= constant.startingTree * 0.65 : TreeTrend$ = "Poor" : endif
   if constant.startingTree * 0.65 > dynamic(n).numTree and dynamic(n).numTree >= constant.startingTree * 0.2 : TreeTrend$ = "Very Poor" : endif
   if constant.startingTree * 0.2 > dynamic(n).numTree : TreeTrend$ = "Horrible" : endif
 
   text 5,105,"Current # of Deer: " + str$(dynamic(n).numDeer)
   text 5,115,"Deer Population Trend: " + DeerTrend$
   text 5,125,"Starting Deer: " + str$(constant.startingDeer)
 
   text 5,165,"Current # of Wolf: " + str$(dynamic(n).numWolf)
   text 5,175,"Wolf Population Trend: " + WolfTrend$
   text 5,185,"Starting Wolves: " + str$(constant.startingWolf)
 
   text 5,225,"Current # of Tree: " + str$(dynamic(n).numTree)
   text 5,235,"Tree Population Trend: " + TreeTrend$
   text 5,245,"Starting Trees: " + str$(constant.startingTree)
 
   text 5,285,"Amount of Rain: " + str$(dynamic(n).numRain)
   text 5,295,"Average Rain: " + str$(constant.averageRain)
 
   text 5,335,"Number of Hunters: " + str$(dynamic(n).numHunt)
   text 5,345,"Starting Hunters: " + str$(constant.strtHunters)
 
   copy bitmap 3,0,0,bitmap width(3),bitmap height(3),0,450,20,625,460
   set current bitmap 0
 
endfunction
 
function updateEquations(n)
 
   if n > 0
      deer(n)
      wolf(n)
      tree(n)
      rain(n)
      `hunters(n)
   else
      specialD(n)
      specialW(n)
      specialT(n)
      specialR(n)
      `specialH(n)
   endif
 
   if dynamic(n+1).numDeer < 0 then dynamic(n+1).numDeer = 0
   if dynamic(n+1).numWolf < 0 then dynamic(n+1).numWolf = 0
   if dynamic(n+1).numTree < 0 then dynamic(n+1).numTree = 0
 
endfunction
 
function deer(n)
 
   deerRepro# = DRR * (dynamic(n).numTree/dynamic(n-1).numTree)
 
   dynamic(n+1).numDeer = (dynamic(n).numDeer - (dynamic(n).numWolf*constant.wolfEat)) * deerRepro#
 
endfunction
 
function wolf(n)
 
   wolfRepro# = WRR * (dynamic(n).numDeer/dynamic(n-1).numDeer)
 
   dynamic(n+1).numWolf = dynamic(n).numWolf * wolfRepro#
 
endfunction
 
function tree(n)
 
   treeRepro# = TRR * (dynamic(n).numRain/constant.averageRain)
 
   dynamic(n+1).numTree = ((dynamic(n).numTree) - (dynamic(n).numDeer * constant.deerEat))*treeRepro#
 
endfunction
 
function rain(n)
 
   dynamic(n+1).numRain = constant.averageRain `* (.7 + (rnd(6)/10))
 
endfunction
 
function hunters(n)
 
   dynamic(n+1).numHunt = dynamic(n).numHunt * (dynamic(n).numDeer / dynamic(n-1).numDeer)
 
endfunction
`````````````````````````````
function specialD(n)
 
   deerRepro# = DRR * (dynamic(n).numTree/dynamic(0).numTree)
 
   dynamic(n+1).numDeer = (dynamic(n).numDeer - (dynamic(n).numWolf*constant.wolfEat))* deerRepro#
 
endfunction
 
function specialW(n)
 
   wolfRepro# = WRR * (dynamic(n).numDeer/dynamic(0).numDeer)
 
   dynamic(n+1).numWolf = dynamic(n).numWolf * wolfRepro#
 
endfunction
 
function specialT(n)
 
   treeRepro# = TRR * (dynamic(n).numRain/constant.averageRain)
 
   dynamic(n+1).numTree = ((dynamic(n).numTree) - (dynamic(n).numDeer * constant.deerEat))*treeRepro#
 
endfunction
 
function specialR(n)
 
   dynamic(n+1).numRain = constant.averageRain` * (.7 + (rnd(6)/10))
 
endfunction
 
function specialH(n)
 
   dynamic(n+1).numHunt = dynamic(n).numHunt * (dynamic(n).numDeer / dynamic(0).numDeer)
 
endfunction