|
Post by bluatigro on Nov 2, 2018 13:17:09 GMT
there are bird's they are dove or hawk if to bird's try to eat - if 2 hawk's -- they fight and get damage and no food - if 1 hawk and 1 dove -- hawk eat's al food - if 2 dove's -- they share the food
error : the sim shoot show a smal number of hawk's and a great number of dove's but it keeps it +- 50 : 50
[/p][p]'' bluatigro 2 nov 2018 '' hawk and dove dim bird( 100 ) , e( 100 ) global hawk , dove hawk = 1 dove = 2 for i = 0 to 100 bird( i ) = irange( 1 , 2 ) e( i ) = 10 next i for j = 0 to 1000 hawktel = 0 dovetel = 0 for i = 0 to 100 dice = irange( 0 , 100 ) if i <> dice then e( i ) = e( i ) + eat( bird( i ) , bird( dice ) ) if e( i ) < 0 then bird( i ) = irange( 1 , 2 ) e( i ) = 10 end if if e( i ) > 20 then bird( dice ) = bird( i ) e( dice ) = 10 end if end if if bird( i ) = hawk then hawktel = hawktel + 1 if bird( i ) = dove then dovetel = dovetel + 1 next i print hawktel , dovetel next j end function irange( low , high ) irange = int( rnd(0) * ( high - low + 1 ) + low ) end function function eat( a , b ) if a = hawk then if b = hawk then eat = -6 else eat = 2 end if else if b = hawk then eat = 0 else eat = 1 end if end if eat = 0 end function [/p][p]
|
|
|
Post by tenochtitlanuk on Nov 2, 2018 14:05:33 GMT
Your function eat has a last line which makes eat always =0!
|
|
|
Post by B+ on Nov 2, 2018 16:56:41 GMT
Heck of a diet plan!
|
|
|
Post by bluatigro on Nov 4, 2018 8:02:42 GMT
update : i altered eat() now i get good results
this is proof that coperation is better than competision
'' bluatigro 2 nov 2018 '' hawk and dove global pop : pop = 1000 dim bird( pop ) , e( pop ) global hawk , dove hawk = 1 dove = 2 for i = 0 to pop bird( i ) = irange( 1 , 2 ) e( i ) = 10 next i for j = 1 to 512 hawktel = 0 dovetel = 0 for i = 0 to pop dice = irange( 0 , pop ) if i <> dice then e( i ) = e( i ) + eat( bird( i ) , bird( dice ) ) if e( i ) < 0 then bird( i ) = irange( 1 , 2 ) e( i ) = 10 end if if e( i ) > 20 then bird( dice ) = bird( i ) e( dice ) = 10 end if end if if bird( i ) = hawk then hawktel = hawktel + 1 if bird( i ) = dove then dovetel = dovetel + 1 next i q = log( j ) / log( 2 ) if q = int( q ) then print j , hawktel , dovetel end if next j print "[ end sim . ]" end function irange( low , high ) irange = int( rnd(0) * ( high - low + 1 ) + low ) end function function eat( a , b ) if a = hawk then if b = hawk then uit = -6 else uit = 2 end if else if b = hawk then uit = 0 else uit = 1 end if end if eat = uit end function
|
|
|
Post by tenochtitlanuk on Nov 4, 2018 10:58:51 GMT
I've always liked these predator/prey simulations. Here's my adapted version to give a graphic front end, making clear the way rises in one population cause drop in the other, but despite the random disturbances they self-level. ' bluatigro 2 nov 2018, modified '' hawk and dove
nomainwin
WindowWidth =1330 WindowHeight = 550
open "Predation" for graphics_nsb as #wg
#wg "trapclose quit" #wg "size 2"
#wg "goto 10 500 ; down ; backcolor 50 100 160 ; boxfilled 1012 10"
for axis =0 to 500 step 100 #wg "up ; goto 10 "; 500 -axis; " ; down ; goto 1010 "; 500 -axis next axis
#wg "size 1"
dim bird( 100), e( 100) global hawk, dove hawk = 1: hawktelO =1 dove = 2: dovetelO =1
for i = 0 to 100 bird( i ) = irange( 1 , 2 ) e( i ) = 10 next i
for j = 0 to 1000 hawktel = 0 dovetel = 0
for i = 0 to 100 dice = irange( 0, 100)
if i <> dice then e( i ) = e( i ) + eat( bird( i ) , bird( dice ) )
if e( i ) < 0 then bird( i ) = irange( 1 , 2 ) e( i ) = 10 end if
if e( i ) > 20 then bird( dice ) = bird( i ) e( dice ) = 10 end if
end if
if bird( i ) = hawk then hawktel = hawktel + 1 if bird( i ) = dove then dovetel = dovetel + 1 next i
#wg "color red ; line "; j +10; " "; 500 -4 *hawktelO; " "; j +10; " "; 500 -4 *hawktel #wg "color darkblue ; line "; j +10; " "; 500 -4 *dovetelO; " "; j +10; " "; 500 -4 *dovetel hawktelO =hawktel dovetelO =dovetel
#wg "size 3 ; color 0 160 0 ; set "; 1040 +hawktel *4; " "; 500 -dovetel *4
scan next j
wait
#wg "getbmp scr 1 1 1330 550" bmpsave "scr", "birds.bmp"
end
function irange( low , high ) irange = int( rnd( 0) * ( high - low + 1 ) + low ) end function
function eat( a , b ) if a = hawk then if b = hawk then eat = -6 else eat = 2 else if b = hawk then eat = 0 else eat = 1 end if end function
end
sub quit h$ close #wg end end sub
Incidentally, it can get stuck with one species all dead....
|
|
|
Post by tsh73 on Nov 5, 2018 18:14:35 GMT
>>making clear the way rises in one population cause drop in the other That's because in this model total population is fixed.
This is not have to be this way.
|
|
|
Post by tenochtitlanuk on Nov 5, 2018 21:21:58 GMT
It's easy to model these unrealistically simplified cases, and you learn a lot from them. Just remember that putting in rubbish rules will give rubbish output ( GIGO)! See my predator/prey stuff at population modelling and modelling human population pyramids
|
|
|
Post by B+ on Nov 6, 2018 13:18:39 GMT
So what is first step towards making the model more realistic and thus more useful to humanity and it's future on earth?
|
|
|
Post by bluatigro on Nov 7, 2018 9:46:55 GMT
update : try at grass , cow and lion world
error : there shoot be cow's and lion's in this grass world
'' bluatigro 7 nov 2018 '' grass cow lion sim global world world = 1000 dim q( world ) , e( world ) global cow , lion , grass , empty , energie cow = 1 lion = 2 grass = 3 energie = 24 for i = 0 to world q( i ) = grass if rnd(0) < .1 then q( i ) = cow e( i ) = energie end if if rnd(0) < .02 then q( i ) = lion e( i ) = energie end if next i
for tel = 0 to 1000 cowtel = 0 liontel = 0 grasstel = 0 for i = 0 to world dice = int( rnd(0) * world ) if i <> dice then select case q( i ) case cow q( i ) = empty if q( dice ) <> lion then if q( dice ) = grass then e( dice ) = e( i ) + 3 else e( dice ) = e( i ) - 1 end if q( dice ) = cow end if if e( dice ) > energie * 2 then q( i ) = cow e( i ) = energie e( dice ) = energie else e( i ) = 0 end if case lion q( i ) = empty if q( dice ) = cow then e( dice ) = e( i ) + 3 q( dice ) = lion else e( dice ) = e( i ) - 1 q( dice ) = lion end if if e( dice ) > energie * 2 then q( i ) = lion e( i ) = energie e( dice ) = energie else e( i ) = 0 end if e( i ) = 0 case grass if q( dice ) = empty then q( dice ) = grass end if case else ''empty end select if e( i ) < 0 then e( i ) = 0 q( i ) = empty end if end if if q( i ) = cow then cowtel = cowtel + 1 if q( i ) = lion then liontel = liontel + 1 if q( i ) = grass then grasstel = grasstel + 1 next i print tel , grasstel , cowtel , liontel next tel print "[ end sim ]"
|
|
|
Post by bluatigro on Nov 7, 2018 10:14:53 GMT
update : i got cow's in my world error : the lion's die quickly out
'' bluatigro 7 nov 2018 '' grass cow lion sim global world world = 1000 dim q( world ) , e( world ) global cow , lion , grass , empty , energie cow = 1 lion = 2 grass = 3 energie = 10 for i = 0 to world q( i ) = grass if rnd(0) < .7 then q( i ) = cow e( i ) = energie end if if rnd(0) < .4 then q( i ) = lion e( i ) = energie end if next i
for tel = 0 to 1000 cowtel = 0 liontel = 0 grasstel = 0 for i = 0 to world dice = int( rnd(0) * world ) if i <> dice then select case q( i ) case cow q( i ) = empty if q( dice ) <> lion then if q( dice ) = grass then e( dice ) = e( i ) + 3 else e( dice ) = e( i ) - 1 end if q( dice ) = cow end if if e( dice ) > energie * 2 then q( i ) = cow e( i ) = energie e( dice ) = energie else e( i ) = 0 end if case lion q( i ) = empty if q( dice ) = cow then e( dice ) = e( i ) + 10 q( dice ) = lion else e( dice ) = e( i ) - 1 q( dice ) = lion end if if e( dice ) > energie * 2 then q( i ) = lion e( i ) = energie e( dice ) = energie else e( i ) = 0 end if e( i ) = 0 case grass if q( dice ) = empty then q( dice ) = grass end if case else ''empty end select if e( i ) < 0 then e( i ) = 0 q( i ) = empty end if end if if q( i ) = cow then cowtel = cowtel + 1 if q( i ) = lion then liontel = liontel + 1 if q( i ) = grass then grasstel = grasstel + 1 next i if tel mod 100 = 0 then print tel , grasstel , cowtel , liontel end if next tel print "[ end sim ]"
|
|
|
Post by tenochtitlanuk on Nov 8, 2018 14:13:32 GMT
Replying to B+'s comment. All simulations about world ecology are almost by definition limited- we don't know all the variables, nor how they interact. At a simple level, the interactions MUST be more familiar in future if the Earth is to have a future. This is where these simulations can have a great educational value for young people. ( Of course at an international level the simulations will be at the limits of what we know and can compute. We do now know much more about the important interactions. Business 'games' help develop business talent- even tho' economics is not the precise science its practioners think it is...Think too how much weather forecasts have improved in our lifetimes...)
I found the population program on my website a great introduction for my students to the delayed impact of changes in disease, food supply or war- and on future taxation needs for aging retirees. Everyone should understand what a population pyramid is, and how it should influence decisions on how to develop our own countries and help the underdeveloped. Have small student groups implement changes, and see if they can generate a steady population- or a controlled reduction. Throw in random war or disease, an oil price hike, or a revolt of pensioners whose pensions are no longer affordable. . Lively debate ensued, as they say, on the need for say compulsory euthanasia at 60; or compulsory birth control limits; or 'culling' male children since women are generally more peaceful and able to cooperate.. Let's have a debate, as they say!!!
|
|
|
Post by bluatigro on Nov 14, 2018 12:24:58 GMT
update : this is also known as fox and rabbit
try to get a 'stable' population [ that is whit cycly ]
or did i make a error ?
'' bluatigro 14 nov 2018 '' fish and shark input "fish : " ; fish input "shark : " ; shark input "fish get child : " ; a input "shark eat fish : " ; b input "shark get child : " ; c input "shark die : " ; d tel = 0 while shark > 0 and tel < 1000 print shark , fish dfish = fish * a - shark * b dshark = fish * c - shark * d fish = fish + dfish shark = shark + dshark tel = tel + 1 wend print "[ end sim ]"
|
|
|
Post by B+ on Nov 14, 2018 14:59:49 GMT
I have been sitting here meditating on how to get a decent model going. It started with an IF THEN question:
IF all fish eat are smaller fish THEN what do the smallest fish eat?
There is no smallest fish? ;-)) (But there is something called land which includes elements mostly recycled and energy mostly from the sun.)
Then a couple of insights: 1) The whole chain is limited to the amount of the smallest fish. 2) The higher up the chain the significantly smaller the balance of that species population must be. Each higher up number has to exist between the feast or famine numbers of next lower level. 3) Omnivores complicate this whole thing. 4) Bacteria are an extremely important part of cycle for plants to carry on.
|
|
|
Post by tsh73 on Nov 15, 2018 13:12:02 GMT
|
|
|
Post by tsh73 on Nov 15, 2018 13:39:13 GMT
John, just tried your "population pyramid" program. It balks at loading "Malthus.txt" my guess that it's just help text in big right textbox - works fine if commented out (or "autoexec" imply one could program some events to mimic button presses?)
Reading program is a treat. So it is totally deterministic, no RND? Rather dark humor. Me likes. (this doesn't prevent me being afraid, but playing "dictator" I got used to starving electronic populace).
|
|