|
Post by bluatigro on Mar 16, 2020 9:33:35 GMT
in folowing corona : a stay at home chalence
this is a try to prove that staing at home is the best option
i can not find the error's it shoot work i REMed the timer because the code does not spred the humans help is welkome
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activety , humans width = WindowWidth height = WindowHeight activety = 0 humans = 100 dim st$( humans ) nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill" #m "spritexy human_"; i ; " " ; dice( winx ) ; " " ; dice( winy ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" '' timer [timer.tick] , 40 wait [timer.tick] for i = 0 to humans #m "spritecolides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( k ) = "ill" then #m "spriteimage human" ; j ; " ill" st$( j ) = "ill" end if wend if rnd(0) < activity / 100 then #m "spritexy? human" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height if y > height then y = 0 select case dice( 4 ) case 0 #m "spritexy human" ; i ; " " ; x+5 ; " " ; y case 1 #m "spritexy human" ; i ; " " ; x-5 ; " " ; y case 2 #m "spritexy human" ; i ; " " ; x ; " " ; y+5 case 3 #m "spritexy human" ; i ; " " ; x ; " " ; y-5 case else end select end if next i
#m "drawsprites" wait [NEW] for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( winx ) ; " " ; dice( winy ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" prompt "activity chanse in %" ; a$ activity = val( a$ ) wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by Rod on Mar 16, 2020 11:42:25 GMT
you have the wrong variables to set out the sprites initially winx width winy height also spritecollides mis spelt and after that the activity part never seems to kick in.
|
|
|
Post by bluatigro on Mar 17, 2020 7:57:45 GMT
Rod : thanks for help i had fount some of the error's myself update : it is now working as planned insturktions : click menu | SIM | NEW SIM type a % between 0 and 100 '' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans width = WindowWidth height = WindowHeight activity = 0 humans = 100 dim st$( humans ) nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( k ) = "ill" then #m "spriteimage human_" ; j ; " ill" st$( j ) = "ill" end if if st$( j ) = "ill" then #m "spriteimage human_" ; k ; " ill" st$( k ) = "ill" end if j = j + 1 wend if rnd(0) < activity / 100 then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height if y > height then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+5 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-5 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+5 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-5 case else end select end if next i
#m "drawsprites" wait [NEW] for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" prompt "activity chanse in %" ; a$ activity = val( a$ ) wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by B+ on Mar 17, 2020 16:16:59 GMT
Scrollbars are a bit distracting but kinda neat! Idea: each human has a different mobility rate. Predict that the more mobile (thus more social) the more likely to become infected unless those that are mobile still avoid others.
|
|
|
Post by bluatigro on Mar 18, 2020 11:00:54 GMT
update : dead , notilljet and beenill states added
error : the sim stop to early
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu width = WindowWidth height = WindowHeight activity = 100 pdead = 3 timeill = 20 incu = 14 humans = 100 dim st$(humans),tijd1(humans),tijd2(humans) nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( j ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " ill" st$( k ) = "ill" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height if y > height then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+5 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-5 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+5 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-5 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = dead + 1 if st$(i) = "healty" then hhealty = healty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [NEW] for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" a$ = str$( activity ) prompt "activity chanse in %" ; a$ activity = val( a$ ) a$ = str$( incu ) prompt "incubation time in days : " ; a$ incu = val( a$ ) a$ = str$( pdead ) prompt "dead chanse in %" ; a$ pdead = val( a$ ) a$ = str$( timeill ) prompt "time ill in days : " ; a$ timeill = val( a$ ) wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by bluatigro on Mar 18, 2020 11:38:47 GMT
update : sim now takes more time
error : the illnes does not spred
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu width = WindowWidth height = WindowHeight activity = 100 pdead = 3 timeill = 20 incu = 14 humans = 300 dim st$(humans),tijd1(humans),tijd2(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( j ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " ill" st$( k ) = "ill" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height if y > height then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+5 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-5 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+5 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-5 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [NEW] for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" a$ = str$( activity ) prompt "activity chanse in %" ; a$ activity = val( a$ ) a$ = str$( incu ) prompt "incubation time in days : " ; a$ incu = val( a$ ) a$ = str$( pdead ) prompt "dead chanse in %" ; a$ pdead = val( a$ ) a$ = str$( timeill ) prompt "time ill in days : " ; a$ timeill = val( a$ ) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by bluatigro on Mar 19, 2020 5:39:54 GMT
update : it is working now
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu width = WindowWidth height = WindowHeight activity = 100 pdead = 3 timeill = 20 incu = 14 humans = 1000 dim st$(humans),tijd1(humans),tijd2(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( i ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " notilljet" st$( k ) = "notilljet" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height if y > height then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+10 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-10 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+10 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-10 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [NEW] for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" a$ = str$( activity ) prompt "activity chanse in %" ; a$ activity = val( a$ ) a$ = str$( incu ) prompt "incubation time in days : " ; a$ incu = val( a$ ) a$ = str$( pdead ) prompt "dead chanse in %" ; a$ pdead = val( a$ ) a$ = str$( timeill ) prompt "time ill in days : " ; a$ timeill = val( a$ ) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by bluatigro on Mar 19, 2020 6:28:57 GMT
forgot somting : setting the timer in [new]
error : when i do menu | SIM | NEW SIM i get a division by zero error but i do not divide in [new] so why ?
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu width = WindowWidth height = WindowHeight activity = 100 pdead = 3 timeill = 20 incu = 14 humans = 1000 dim st$(humans),tijd1(humans),tijd2(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( i ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " notilljet" st$( k ) = "notilljet" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height - 50 if y > height - 50 then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+10 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-10 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+10 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-10 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [NEW] for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" a$ = str$( activity ) prompt "activity chanse in %" ; a$ activity = val( a$ ) a$ = str$( incu ) prompt "incubation time in days : " ; a$ incu = val( a$ ) a$ = str$( pdead ) prompt "dead chanse in %" ; a$ pdead = val( a$ ) a$ = str$( timeill ) prompt "time ill in days : " ; a$ timeill = val( a$ ) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i timer 40 , [timer.tick] wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x + 1 ) end function
|
|
|
Post by bluatigro on Mar 19, 2020 6:46:11 GMT
first results : activity 100% : 42 dead + 3 healty activity 10% : 2 dead + 69 been ill what was remarkeble is that sim took less time to get to groupimumity whit 10$
i changed the stats in the code i did not find the error jet
|
|
|
Post by bluatigro on Mar 21, 2020 6:44:11 GMT
update : timer 0 in [new] added
the prompt's do not wait for return !!! and a$ = "0"
if i write a test of prompt then it works good but in my code somthing strange happends
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu width = WindowWidth height = WindowHeight activity = 100 pdead = 3 timeill = 20 incu = 14 humans = 1000 dim st$(humans),tijd1(humans),tijd2(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i ''nomainwin
menu #m , "SIM" , "NEW SIM" , [NEW] open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( i ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " notilljet" st$( k ) = "notilljet" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height - 50 if y > height - 50 then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+10 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-10 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+10 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-10 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [NEW] TIMER 0 for i = 0 to humans #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" a$ = str$( activity ) prompt "activity chanse in %" ; a$ activity = val( a$ ) a$ = str$( incu ) prompt "incubation time in days : " ; a$ incu = val( a$ ) a$ = str$( pdead ) prompt "dead chanse in %" ; a$ pdead = val( a$ ) a$ = str$( timeill ) prompt "time ill in days : " ; a$ timeill = val( a$ ) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i timer 40 , [timer.tick] wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by tenochtitlanuk on Mar 21, 2020 12:51:54 GMT
An old bug in LB/JB Timer-If you use prompt when a timer is running Liberty will ignore it.
|
|
|
Post by bluatigro on Mar 22, 2020 10:35:02 GMT
OK then i remove [new] + prompt and fix it whit input
@carl : can you fix this in LB5 ?
'' bluatigro 16 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu width = WindowWidth height = WindowHeight print "type activity chance in %" input "[ press return for 100 % ] " ; a$ activity = val( a$ ) if activity = 0 then activity = 100 print "type dead while ill chance in %" input "[ press return for 3 % [ corona ] ] " ; a$ pdead = val( a$ ) if pdead = 0 then pdead = 3 print "type time ill in day's" input "[ press return for 20 day's [ corona ] ] " ; a$ timeill = val( a$ ) if timeill = 0 then timeill = 20 print "type time infected in day's" input "[ press return for 14 day's [ corona ] " ; a$ incu = val( a$ ) if incu = 0 then incu = 14 humans = 1000 dim st$(humans),tijd1(humans),tijd2(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill next i nomainwin open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( width ) ; " " ; dice( height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( i ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " notilljet" st$( k ) = "notilljet" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height - 50 if y > height - 50 then y = 0 select case dice( 4 ) case 0 #m "spritexy human_" ; i ; " " ; x+10 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-10 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+10 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-10 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [quit] close #m end function dice( x ) dice = int( rnd(0) * x ) end function
|
|
|
Post by bluatigro on Mar 30, 2020 8:18:30 GMT
update : travelers added
'' bluatigro 30 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu , ptravel width = WindowWidth height = WindowHeight print "type activity chance in %" input "[ press return for 100 % ] " ; a$ activity = val( a$ ) input "type traveling rate in % " ; a$ ptravel = val( a$ ) if activity = 0 then activity = 100 print "type dead while ill chance in %" input "[ press return for 3 % [ corona ] ] " ; a$ pdead = val( a$ ) if pdead = 0 then pdead = 3 print "type time ill in day's" input "[ press return for 20 day's [ corona ] ] " ; a$ timeill = val( a$ ) if timeill = 0 then timeill = 20 print "type time infected in day's" input "[ press return for 14 day's [ corona ] " ; a$ incu = val( a$ ) if incu = 0 then incu = 14 humans = 1000 dim st$(humans),tijd1(humans),tijd2(humans),dx(humans),dy(humans),isTravel(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill if rnd(0) < pTravel / 100 then dx(i) = dice( -5 , 5 ) dy(i) = dice( -5 , 5 ) isTravel(i) = 1 end if next i nomainwin open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( 0 , width ) ; " " ; dice( 0 , height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait function dice( low , high ) dice = int( rnd(0) * ( high - low + 1 ) ) + int( low ) end function [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( i ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " notilljet" st$( k ) = "notilljet" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height - 50 if y > height - 50 then y = 0 if isTravel(i) then x = x + dx(i) y = y + dy(i) end if select case dice( 0 , 3 ) case 0 #m "spritexy human_" ; i ; " " ; x+10 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-10 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+10 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-10 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [quit] close #m end
|
|
|
Post by tsh73 on Mar 30, 2020 11:03:50 GMT
Hello bluatigro your program has NOMAINWIN - but it has INPUT so it just stops on INPUT NOMAINWIN had to be commented out.
Also there is a difference pTravel / ptravel so travel code does not work.
Even then it made working it's hard to tell travelers (with speeds of -5..5 ) over general populace (randomly moving +/- 10)
|
|
|
Post by bluatigro on Mar 31, 2020 6:30:40 GMT
update : ths73 remarks changed
'' bluatigro 30 mrt 2020 '' virus outbreak sim WindowWidth = DisplayWidth WindowHeight = DisplayHeight global width , height , activity , humans , pdead , timeill , incu , ptravel width = WindowWidth height = WindowHeight print "type activity chance in %" input "[ press return for 100 % ] " ; a$ activity = val( a$ ) input "type traveling rate in % " ; a$ ptravel = val( a$ ) if activity = 0 then activity = 100 print "type dead while ill chance in %" input "[ press return for 3 % [ corona ] ] " ; a$ pdead = val( a$ ) if pdead = 0 then pdead = 3 print "type time ill in day's" input "[ press return for 20 day's [ corona ] ] " ; a$ timeill = val( a$ ) if timeill = 0 then timeill = 20 print "type time infected in day's" input "[ press return for 14 day's [ corona ] ] " ; a$ incu = val( a$ ) if incu = 0 then incu = 14 humans = 1000 dim st$(humans),tijd1(humans),tijd2(humans),dx(humans),dy(humans),isTravel(humans) for i = 0 to humans tijd1(i) = incu tijd2(i) = timeill if rnd(0) < ptravel / 100 then dx(i) = dice( -10 , 10 ) dy(i) = dice( -10 , 10 ) isTravel(i) = 1 end if next i open "virus outbreak sim" for graphics as #m #m "trapclose [quit]" #m "goto 0 0" #m "backcolor black" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp healty 0 0 20 40" #m "backcolor red" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp ill 0 0 20 40" #m "backcolor white" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp dead 0 0 20 40" #m "backcolor yellow" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp notilljet 0 0 20 40" #m "backcolor blue" #m "goto 0 20" #m "down" #m "boxfilled 20 40" #m "up" #m "getbmp beenill 0 0 20 40" for i = 0 to humans #m "addsprite human_" ; i ; " healty ill dead notilljet beenill" #m "spritexy human_"; i ; " " ; dice( 0 , width ) ; " " ; dice( 0 , height ) st$( i ) = "healty" next i #m "spriteimage human_0 ill" st$( 0 ) = "ill" #m "drawsprites" timer 40 , [timer.tick] wait function dice( low , high ) dice = int( rnd(0) * ( high - low + 1 ) ) + int( low ) end function [timer.tick] scan for i = 0 to humans #m "spritecollides human_" ; i ; " hit$" j = 1 while word$( hit$ , j ) <> "" h$ = word$( hit$ , j ) k = val( word$( h$ , 2 , "_" ) ) if st$( i ) = "ill" and st$( k ) = "healty" then #m "spriteimage human_" ; k ; " notilljet" st$( k ) = "notilljet" end if j = j + 1 wend if st$(i) = "ill" then tijd2(i) = tijd2(i) - 1 if tijd2(i) <= 0 then st$(i) = "beenill" #m "spriteimage human_" ; i ; " beenill" end if if rnd(0) < pdead / 100 / timeill then st$(i) = "dead" #m "spriteimage human_" ; i ; " dead" end if end if if st$(i) = "notilljet" then tijd1(i) = tijd1(i) - 1 if tijd1(i) <= 0 then st$(i) = "ill" #m "spriteimage human_" ; i ; " ill" end if end if if rnd(0) < activity / 100 and st$(i) <> "dead" then #m "spritexy? human_" ; i ; " x y" if x < 0 then x = width if x > width then x = 0 if y < 0 then y = height - 50 if y > height - 50 then y = 0 if isTravel(i) then x = x + dx(i) y = y + dy(i) end if select case dice( 0 , 3 ) case 0 #m "spritexy human_" ; i ; " " ; x+10 ; " " ; y case 1 #m "spritexy human_" ; i ; " " ; x-10 ; " " ; y case 2 #m "spritexy human_" ; i ; " " ; x ; " " ; y+10 case 3 #m "spritexy human_" ; i ; " " ; x ; " " ; y-10 case else end select end if next i fl = 1 for i = 0 to humans if st$(i) = "ill" or st$(i) = "notilljet" then fl = 0 next i if fl then timer 0 hdead = 0 hhealty = 0 hbeenill = 0 for i = 0 to humans if st$(i) = "dead" then hdead = hdead + 1 if st$(i) = "healty" then hhealty = hhealty + 1 if st$(i) = "beenill" then hbeenill = hbeenill + 1 next i txt$ = "human stats : " + chr$(13) _ + "dead : " + str$( hdead ) + chr$(13) _ + "healty : " + str$( hhealty ) + chr$(13) _ + "been ill : " + str$( hbeenill ) notice txt$ end if #m "drawsprites" wait [quit] close #m end
|
|