Postby bluatigro » Mar 30, 2020 6:38
update :
now whit travelers
{code]
'' bluatigro 30 mrt 2020
'' virus outbreak sim
screen 18 , 32
const as long healty = rgb( 0 , 255 , 0 )
const as long notilljet = rgb( 255 , 255 , 0 )
const as long ill = rgb( 255 , 0 , 0 )
const as long been_ill = rgb( 0 , 0 , 255 )
const as long dead = rgb( 255 , 255 , 255 )
const as integer humans = 1000
type thuman
dim as double x , y , dx , dy'' spot of thuman
dim as long kl '' color state of thuman
dim as integer tijd1 , tijd2 , isTraveling ''counter for keeping time
end type
dim shared as thuman h(humans)
function dist( i as integer , j as integer ) as integer
return cint(sqr((h(i).x-h(j).x)^2+(h(i).y-h(j).y)^2))
end function
dim as string in
input "type incubation time [ in day's ] : " ; in
dim as integer incu = val( in )
if incu = 0 then incu = 14 '' corona
input "type time ill [ in day's ] : " ; in
dim as integer time_ill = val( in )
if time_ill = 0 then time_ill = 20 '' corona
input "type % dead [ 0 ... 100 ] : " ; in
dim as double pdead = val( in )
if pdead = 0 then pdead = 3 '' corona
input "type a % chance on activity " ; in
dim as integer activity = val( in ) ,i,j, scrnw , scrnh
if activity = 0 then activity = 100
input "type a % chance on traveling " ; in
dim as double pTravel = val( in )
screeninfo scrnw , scrnh
randomize timer
function dice( x as integer ) as integer
return cint( rnd * x )
end function
function range( low as double , high as double ) as double
return rnd * ( high - low ) + low
end function
for i = 0 to humans
h(i).x = dice( scrnw )
h(i).y = dice( scrnh )
h(i).kl = healty
h(i).tijd1 = incu '' notilljet time
h(i).tijd2 = time_ill
if rnd < pTravel then
h(i).dx = range( -5 , 5 )
h(i).dy = range( -5 , 5 )
h(i).isTraveling = 1
end if
next i
h(1).kl = ill
dim as integer done,hdead,hhealty,hbeenill
do
cls
for i = 0 to humans
circle(h(i).x,h(i).y),5,h(i).kl,,,,f
next i
for i = 0 to humans
if h(i).kl = ill then
h(i).tijd2 -= 1
if h(i).tijd2 <= 0 then h(i).kl = been_ill
if rnd < pdead / 100 / time_ill then
h(i).kl = dead
end if
end if
if h(i).kl = notilljet then
h(i).tijd1 -= 1
if h(i).tijd1 <= 0 then
h(i).kl = ill
end if
end if
for j = 0 to humans
if i <> j then
if dist( i , j ) < 20 then
if h(i).kl = ill and h(j).kl = healty then
h(j).kl = notilljet
end if
end if
end if
next j
if h(i).x <> dead then
if h(i).isTraveling then
h(i).x += h(i).dx
h(i).y += h(i).dy
end if
if rnd < activity / 100 then
select case dice( 4 )
case 0
h(i).x += 3
case 1
h(i).x -= 3
case 2
h(i).y += 3
case 3
h(i).y -= 3
case else
end select
if h(i).x < 0 then h(i).x = scrnw
if h(i).x > scrnw then h(i).x = 0
if h(i).y < 0 then h(i).y = scrnh
if h(i).y > scrnh then h(i).y = 0
end if
end if
next i
done = 1
hdead = 0
hhealty = 0
hbeenill = 0
for i = 0 to humans
if h(i).kl = notilljet or h(i).kl = ill then done = 0
if h(i).kl = dead then hdead += 1
if h(i).kl = healty then hhealty += 1
if h(i).kl = been_ill then hbeenill += 1
next
sleep 40
loop while inkey = "" and not done
locate 10 , 10
cls
print
print
print " end sim :"
print
print " stats humans :"
print
print " dead : " + str( hdead )
print
print " healty : " + str( hhealty )
print
print " been ill : " + str( hbeenill )
sleep
[/code]