Const winwidth%=600 Const winheight%=600 Const cellsize%=2 Const auto%=False Global cw%=winwidth%/(winwidth%/cellsize%) Global ch%=winheight%/(winheight%/cellsize%) Global ccw%=winwidth%/cw% Global cch%=winheight%/ch% Global d%=0 Global density%=5 Global born%,bp%,living%,lp%,sr$,br$ sr$="23":br$="3";Original ;sr$="24":br$="3";Dreher ;sr$="12345":br$="3";Labyrinth ;sr$="12":br$="34678" ;sr$="23":br$="35" ;sr$="23":br$="36" ;sr$="24":br$="34" ;sr$="34":br$="34" ;sr$="34":br$="347" ;sr$="68":br$="34567" ;sr$="135":br$="36" ;sr$="137":br$="346" ;sr$="137":br$="348" ;sr$="146":br$="345" ;sr$="148":br$="345" ;sr$="235":br$="36";Pluskette ;sr$="236":br$="3" ;sr$="236":br$="37" ;sr$="237":br$="3" ;sr$="237":br$="368" ;sr$="238":br$="3" ;sr$="238":br$="357" ;sr$="346":br$="34" ;sr$="347":br$="348" ;sr$="357":br$="345" ;sr$="1256":br$="367" ;sr$="1357":br$="1357";Kopierwelt Dim oldstate%(ccw%,cch%),statecolor%(ccw%,cch%) Dim newstate%(ccw%,cch%) Global win%=CreateWindow("Conway",GraphicsWidth()*0.5-(winwidth%*0.5),GraphicsHeight()*0.5-(winheight%*0.5),winwidth%,winheight%,Desktop(),1+8+32):RestoreWindow win% Global can%=CreateCanvas(0,0,winwidth%,winheight%,win%) SeedRnd MilliSecs() InitWorld() ;ShuffleRules() SetBuffer CanvasBuffer(can%) ClsColor 64,64,64:Cls Local once%,clock%=MilliSecs() Local capture%=MilliSecs() Local take%,shot% Local pause%,paint%,erase% Local scr%=MilliSecs(),scrs% Repeat Select WaitEvent(0) Case $101 Select EventData() Case 1 Exit Case 57 If pause%=True Then pause%=False Else pause%=True Case 63 InitWorld() Case 64 ShuffleRules() Case 78 d%=d%+10 Case 74 If d%>0 Then d%=d%-10 Case 200 If density%<100 Then density%=density%+1 Case 208 If density%>0 Then density%=density%-1 End Select SetStatusText(win%,sr$+" / "+br$+Chr$(9)+density%+"%"+Chr$(9)+d%+"ms") Case $201 Select EventData() Case 1 paint%=True Case 2 erase%=True End Select Case $202 Select EventData() Case 1 paint%=False Case 2 erase%=False End Select Case $803 Exit End Select If paint%=True Then PaintCells() If erase%=True Then EraseCells() If MilliSecs()>clock%+d% Then If pause%=False Then UpdateWorld() DrawWorld() clock%=MilliSecs() End If ; If MilliSecs()>scr%+10 Then ; scrs%=scrs%+1 ; If scrs%<80 Then SaveBuffer(CanvasBuffer(can%),"anim\frame"+scrs%+".bmp") ; scr%=MilliSecs() ; End If If auto%=True Then If MilliSecs()>capture%+100 Or born%=0 Then bp%=Ceil(Float(100)/Float(ccw%*cch%)*Float(born%)) lp%=Ceil(Float(100)/Float(ccw%*cch%)*Float(living%)) If bp%>0 And bp%<=10 And lp%<=10 And shot%=0 Then SaveBuffer(CanvasBuffer(can%),"worlds\"+sr$+"_"+br$+".bmp"):shot%=1 End If take%=take%+1 If take%=1 Then take%=0 shot%=0 ShuffleRules() Else InitWorld() End If capture%=MilliSecs() End If End If Forever SetBuffer DesktopBuffer() End ;FUNCTIONS------------------------------------------------- Function ShuffleRules() Local n%,r$ sr$="" br$="" For n%=1 To Rand(1,5) r$=Str(Rand(1,8)) If Instr(sr$,r$)=0 Then sr$=sr$+r$ Next For n%=1 To Rand(1,5) r$=Str(Rand(1,8)) If Instr(br$,r$)=0 Then br$=br$+r$ Next InitWorld() End Function Function PaintCells() Local mx%=MouseX(can%)/cw% Local my%=MouseY(can%)/ch% oldstate%(mx%,my%)=1 newstate%(mx%,my%)=1 statecolor%(mx%,my%)=0 DrawWorld() End Function Function EraseCells() Local mx%=MouseX(can%)/cw% Local my%=MouseY(can%)/ch% oldstate%(mx%,my%)=0 newstate%(mx%,my%)=0 statecolor%(mx%,my%)=0 DrawWorld() End Function Function InitWorld() Local x%,y%,n%,r% For y%=0 To cch% For x%=0 To ccw% oldstate%(x%,y%)=0 newstate%(x%,y%)=0 Next Next If density%>0 Then r%=Float(ccw%*cch%)/Float(100)*Float(density%) For n%=1 To r% x%=Rand(0,ccw%) y%=Rand(0,cch%) oldstate%(x%,y%)=1 Next Else oldstate%(ccw%*0.5,cch%*0.5)=1 End If SetStatusText(win%,sr$+" / "+br$+Chr$(9)+density%+"%"+Chr$(9)+d%+"ms") End Function Function UpdateWorld() Local x%,y%,x2%,y2%,n% born%=0 living%=0 For y%=0 To cch% For x%=0 To ccw% n%=0 x2%=x%-1:If x2%<0 Then x2%=ccw% y2%=y%-1:If y2%<0 Then y2%=cch% n%=n%+oldstate%(x2%,y2%) x2%=x% y2%=y%-1:If y2%<0 Then y2%=cch% n%=n%+oldstate%(x2%,y2%) x2%=x%+1:If x2%>ccw% Then x2%=0 y2%=y%-1:If y2%<0 Then y2%=cch% n%=n%+oldstate%(x2%,y2%) x2%=x%+1:If x2%>ccw% Then x2%=0 y2%=y% n%=n%+oldstate%(x2%,y2%) x2%=x%+1:If x2%>ccw% Then x2%=0 y2%=y%+1:If y2%>cch% Then y2%=0 n%=n%+oldstate%(x2%,y2%) x2%=x% y2%=y%+1:If y2%>cch% Then y2%=0 n%=n%+oldstate%(x2%,y2%) x2%=x%-1:If x2%<0 Then x2%=ccw% y2%=y%+1:If y2%>cch% Then y2%=0 n%=n%+oldstate%(x2%,y2%) x2%=x%-1:If x2%<0 Then x2%=ccw% y2%=y% n%=n%+oldstate%(x2%,y2%) Select oldstate%(x%,y%) Case 0 If Instr(br$,Str(n%))<>False Then newstate%(x%,y%)=1:statecolor%(x%,y%)=0:born%=born%+1 Case 1 If Instr(sr$,Str(n%))<>False Then newstate%(x%,y%)=1 statecolor%(x%,y%)=statecolor%(x%,y%)+5 If statecolor%(x%,y%)>150 Then statecolor%(x%,y%)=150 living%=living%+1 Else newstate%(x%,y%)=0 End If End Select Next Next FlipState() End Function Function FlipState() Local x%,y% For y%=0 To cch% For x%=0 To ccw% oldstate%(x%,y%)=newstate%(x%,y%) Next Next End Function Function DrawWorld() Local x%,y%,c% Cls For y%=0 To cch% For x%=0 To ccw% If oldstate%(x%,y%)=1 Then If statecolor%(x%,y%)=0 Then Color 255,55,55 Else Color 250-statecolor%(x%,y%),50+statecolor%(x%,y%)*0.25,50+statecolor%(x%,y%)*0.5 End If Rect x%*cw%,y%*ch%,cw%,ch%,1 End If Next Next FlipCanvas can% End Function