they are hawk or dove
2 bird's meet and try to eat
if 2 hawk's :
- they fight and get no food
if 2 dove's :
- they share the food
if 1 hawk :
- hawk eats al food
this is a sim that show's and proofs
that the dove's get it good
conclusion :
cooperation is better then competision
Code: Select all
'' bluatigro 7 nov 2018
'' hawk and dove
const as integer pop = 1000
dim shared as integer bird( pop ) , e( pop )
const as integer hawk = 1
const as integer dove = 2
function irange( low as integer , high as integer ) as integer
return int( rnd * ( high - low + 1 ) + low )
end function
function eat( a as integer , b as integer ) as integer
if a = hawk then
if b = hawk then
return -4
else
return 2
end if
else
if b = hawk then
return 0
else
return 1
end if
end if
end function
dim as integer i , j , dice , hawktel , dovetel
dim as double q
for i = 0 to pop
bird( i ) = irange( 1 , 2 )
e( i ) = 10
next i
for j = 1 to 2 ^ 15
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 , "hawk's : " + str( hawktel ) , "dove's : " + str( dovetel )
end if
next j
print "[ end sim . ]"
sleep