DNA-Bakterien

Übersicht BlitzBasic Codearchiv

Gehe zu Seite Zurück  1, 2

Neue Antwort erstellen

Fetze

BeitragFr, Jan 14, 2005 17:22
Antworten mit Zitat
Benutzer-Profile anzeigen
Danke fürs Lob ^^
Hab auch schon stundenlang vor meinen Bakterien gesessen und zugesehen, was passiert. Netter Zeitvertreib *g*

Achso, mal nebenbei:
Inarie hat geschummelt Wink

Hat es mit der Zeile "Genom_MaxChanges=40" möglich gemacht, dass Bakterien, deren DNA total kaputt ist, einfach weiterleben, anstatt zu sterben, sowie es sein sollte. Normalerweise können nur Bakterien überleben, die eine einigermaßen intakte DNA haben. Daher hatte ich als Wert "Genom_MaxChanges=10" gewählt.
Daher gibts bei ihm so ne große Artenvielfalt. Nur mal so am Rande ^^

Rob_

BeitragSo, Jan 16, 2005 17:17
Antworten mit Zitat
Benutzer-Profile anzeigen
Also bei mir sterben sie alle ab kaum haben sie sich vermert sind alle vom bildschirm weg : (
AMD Athlon 64 3500+ | Infineon 1 GB DDR RAM | nVidia Geforce 7800 GTX

MichaelB

BeitragDi, Jan 18, 2005 19:00
Antworten mit Zitat
Benutzer-Profile anzeigen
Die Idee finde ich echt klasse, hoffe schon lange auf eine Fortsetzung von SimLife bzw. Sim Earth.

Wenn man jetzt noch auf dem "Spielfeld" Bereiche mit unterschiedlichen Eigenschaften wie Feuchtigkeit, Temperatur und sowas hätte, die der Spieler beeinflussen kann, wäre das doch schon ein echt geiler Anfang.

Hoffe du findest Zeit da weiterzumachen
Gruß Michael
The old ones are the best!
User posted image

MikeDee

BeitragDi, Jun 10, 2008 19:05
Antworten mit Zitat
Benutzer-Profile anzeigen
ich weiß, der thread ist alt, aber ich würde zu gerne die simulation sehen.
Könnte vieleicht jemand daraus eine exe. machen oder i-was ähnliches, die BB demo fasst den Code nicht.
Nicht wenige benutzen die Anonymität des Internets um berühmt zu werden.

aMul

Sieger des Minimalist Compo 01/13

BeitragDi, Jun 10, 2008 19:57
Antworten mit Zitat
Benutzer-Profile anzeigen
Normalerweise mache ich sowas nicht, aber da der Code ganz interessant ist, klickst'e hier.
Panic Pong - ultimate action mashup of Pong and Breakout <= aktives Spiele-Projekt, Downloads mit vielen bunten Farben!
advASCIIdraw - the advanced ASCII art program <= aktives nicht-Spiele-Projekt, must-have für ASCII/roguelike/dungeon-crawler fans!
Alter BB-Kram: ThroughTheAsteroidBelt - mit Quelltext! | RGB-Palette in 32²-Textur / Farbige Beleuchtung mit Dot3 | Stereoskopie in Blitz3D | Teleport-Animation Screensaver

MikeDee

BeitragDi, Jun 10, 2008 20:08
Antworten mit Zitat
Benutzer-Profile anzeigen
wenn ich auf download gehe bekomme ich nur eine "Index"-seite fürs internet
Nicht wenige benutzen die Anonymität des Internets um berühmt zu werden.

aMul

Sieger des Minimalist Compo 01/13

BeitragDi, Jun 10, 2008 20:35
Antworten mit Zitat
Benutzer-Profile anzeigen
Hm, bei mir klappt es. Aber wie auch immer, hab es nochmal hier im Archiv hochgeladen:
https://www.blitzforum.de/upload/file.php?id=3051
Kann aber nicht versprechen, dass es da lange bleiben wird.
Panic Pong - ultimate action mashup of Pong and Breakout <= aktives Spiele-Projekt, Downloads mit vielen bunten Farben!
advASCIIdraw - the advanced ASCII art program <= aktives nicht-Spiele-Projekt, must-have für ASCII/roguelike/dungeon-crawler fans!
Alter BB-Kram: ThroughTheAsteroidBelt - mit Quelltext! | RGB-Palette in 32²-Textur / Farbige Beleuchtung mit Dot3 | Stereoskopie in Blitz3D | Teleport-Animation Screensaver

MikeDee

BeitragDi, Jun 10, 2008 20:47
Antworten mit Zitat
Benutzer-Profile anzeigen
ok jetzt hat es geklappt.
bei mir "stirbt" alles gleich, naja, irgendwann wird was rauskommen^^
ist was rausgekommen und es wackelt wirklich extrem, bin froh wenn ich an meinen eigenen Rechner bin (Bildschirm kaputt)-.-
(hab noch ganz vergessen Danke zu sagen)^^
Nicht wenige benutzen die Anonymität des Internets um berühmt zu werden.

DAK

BeitragMi, Jun 11, 2008 10:40
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich hab vor ein paar Monaten etwas ähnliches programmiert:

Code: [AUSKLAPPEN]
Graphics 800, 600, 16, 2
SetBuffer BackBuffer()
SeedRnd MilliSecs()

Type cell
   Field nr, x#, y#, pic, health#, maxhealth, genom$, nutrition, speed#, photosynth, breedtime, breed#, lifetime, lifespan, kill#, tarnr, startrace
   Field vircommand, virgenom$[10], infected, activatetime
End Type

Dim startgenom$(5)
Dim stats(5)
Dim stats2#(5)
Dim seq_pos$(4,1)
Dim current_cell_pic(4,1)
Dim chars$(15)
Dim saves$(10)
Dim saverace(10)
Dim savepics(10)
For i = 0 To 15
   chars$(i) = hex2(i)
Next

Global maxcells = 200
Global mh1

Const health$      ="001"
Const nutrition$   ="002"
Const speed$      ="003"
Const c_r$         ="004"   ;Farbe
Const c_g$         ="005"   ;Farbe
Const c_b$         ="006"   ;Farbe
seq_pos$(1,0)      ="007"
seq_pos$(2,0)      ="008"
seq_pos$(3,0)      ="009"
seq_pos$(4,0)      ="00A"
seq_pos$(1,1)      ="00B"
seq_pos$(2,1)      ="00C"
seq_pos$(3,1)      ="00D"
seq_pos$(4,1)      ="00E"
Const virgenom$      ="F"
Const breedtime$   ="010"
Const lifespan$      ="011"
Const photosynth$   ="012"
Const vircommand$   ="013"
Const immune$      ="123"

Global cells=0

startgenom$(5) = "0013FF0026660030200040FF00500000600000700100801400901400B00100C00100D01401300604FFFF010001011600012015000000000000000000000000000000"
startgenom$(4) = "0013FF0026660030200040FF0050FF00600000700100801400901400B00100C00100D01401300604F001010001011600012015000000000000000000000000000000"
startgenom$(3) = "0013FF0026660030200040FF0050FF00600000700100801400901400B00100C00100D01401300404FFFF02F3FF06F3FF000000000000000000000000000000000000"
startgenom$(2) = "0010280026660030200040FF0050FF00600000700100801400901400B00100C00100D014013001000000000000000000000000000000000000000000000000000000"
startgenom$(1) = "0010500020010030200040FF0050FF00600000700100801400901400A00100B00100C00100D01400E0140100C8011600012006000000000000000000000000000000"
startgenom$(0) = "001050002FFF0030200040FF00500000600000700100801400900100A01400B00100C00100D01400E0140100C8011600012006000000000000000000000000000000"

For i = 0 To 5
   savepics(i) = create_save_pic(startgenom$(i))
   saves(i+1) = startgenom(i)
   saverace(i+1) = i
Next

refreshcells()

light = 1

While Not KeyHit(1)
   Cls
   mh1 = MouseHit(1)
   If KeyHit(57) Then refreshcells()
   If KeyHit(28) Then light = 1-light
   If light Then ClsColor 50, 50, 50
   If light=0 Then ClsColor 0,0,0
   For c.cell = Each cell
      If fast=0 Or (fast=1 And flipframe=1) Then DrawImage c\pic, c\x, c\y
      If c\nutrition = 1 Then
         dir = Rand(360)
         distmax = 200
         tarnr = 0
         tarx = 0
         tary = 0
         found = 0
         For t.cell = Each cell
            If t\nutrition = 0 And t\nutrition <> 3 Then
               found = found + 1
               If dist(t\x, t\y, c\x, c\y) < distmax Then
                  distmax=dist(t\x, t\y, c\x, c\y)
                  tarnr=t\nr
                  tarx = t\x
                  tary = t\y
               EndIf
            EndIf
            If found >= stats(4) Then Exit
         Next
         If tarnr <> 0 Then
            dir = ATan2(tary-c\y, tarx-c\x)+180
         EndIf
         c\health = c\health - 1*c\speed/32
         If light Then
            If c\health<c\maxhealth Then c\health = c\health + c\photosynth/2
            c\breed = c\breed + .9
         EndIf
      ElseIf c\nutrition = 0
         c\health = c\health-.01*c\speed/32
         If c\health > c\maxhealth/2 Then c\breed=c\breed+1.8
         ok = 0
         For t.cell = Each cell
            If t\nr = c\tarnr Then ok = 1
         Next
         ok=0
         If ok = 0 Then
            tardist = 10000
            c\tarnr = 0
            For t.cell = Each cell
               If t\nutrition <> 0 And t\nutrition <> 2 Then
                  If tardist > dist(t\x, t\y, c\x, c\y) Then tardist = dist(t\x, t\y, c\x, c\y):c\tarnr = t\nr
               EndIf
            Next
         EndIf
         For t.cell = Each cell
            If t\nr = c\tarnr Then
               dir = ATan2(t\y-c\y, t\x-c\x)
               If dist(t\x, t\y, c\x, c\y) < 20 And c\health<c\maxhealth-20 Then c\health=c\health+t\health:t\health=0:t\kill=2
            EndIf
         Next
         If c\tarnr = 0 Then dir = Rand(360)
         If c\health > c\maxhealth-20 Then dir = Rand(360)
      ElseIf c\nutrition = 2
         ok = 0
         For t.cell = Each cell
            If t\nr = c\tarnr Then ok = 1
         Next
         ok=0
         If ok = 0 Then
            tardist = 10000
            c\tarnr = 0
            For t.cell = Each cell
               If t\nutrition <> 2 And t\infected=0 Then
                  If tardist > dist(t\x, t\y, c\x, c\y) Then tardist = dist(t\x, t\y, c\x, c\y):c\tarnr = t\nr
               EndIf
            Next
         EndIf
         For t.cell = Each cell
            If t\nr = c\tarnr Then
               dir = ATan2(t\y-c\y, t\x-c\x)
               If dist(t\x, t\y, c\x, c\y) < 20 Then
                  For i = 1 To Len(t\genom$)/4
                     If readblock$(t\genom$, i) = immune$ Then c\health = 0
                  Next
                  If c\health = 0 Then
                     For i = 1 To Len(c\genom$)/4
                        If readblock$(c\genom$, i) = immune$ Then c\health = c\maxhealth
                     Next
                  EndIf
                  If c\health*2>t\health Or (t\nutrition=1 And c\health*4>t\health) Then
                     c\kill = 2
                     execute = c\vircommand
                     execute = execute Mod 4
                     If execute = 2 Then
                        t\genom$ = c\genom$
                        For i = 1 To Len(t\genom$)/4
                           If readblock$(t\genom$, i) = vircommand$ Then
                              t\genom$ = replace_block$(t\genom$, i+1, "022")
                              t\vircommand = 34
                              t\startrace = c\startrace
                              c\health=0
                           EndIf
                        Next
                     EndIf
                     If execute = 1 Then
                        t\genom$ = c\genom$
                        For i = 1 To Len(t\genom$)/4
                           If readblock$(t\genom$, i) = vircommand$ Then
                              t\genom$ = replace_block$(t\genom$, i+1, "011")
                              t\vircommand = 17
                              t\startrace = c\startrace
                              c\health=0
                           EndIf
                        Next
                     EndIf
                     execute = c\vircommand
                     execute = execute Mod 8
                     If execute/4 >= 1 Then
                        blocks = Len(t\genom$)/3
                        For i = 1 To blocks Step 2
                           rb$ = readblock$(c\genom$, i)
                           If Right(rb$, 1) = virgenom$ Then
                              t\genom = replace_block$(t\genom$, unhex(Left(rb$, 2)), readblock$(c\genom$, i+1))
                           EndIf
                        Next
                     EndIf
                     t\infected=1
                  Else
                     t\health = t\health - c\health
                     c\health = -1
                  EndIf
               EndIf
            EndIf
         Next
         If c\tarnr = 0 Then dir = Rand(360)
      Else
         dir = Rand(360)
         c\health = c\health - 1*c\speed/32
      EndIf
      If c\health > c\maxhealth Then c\health = c\maxhealth
      If c\breed > c\breedtime Then
         c\health = c\maxhealth/3
         c\breed = 0
         new_cell(c\genom$, c\x+Rand(-10,10), c\y+Rand(-10,10), c\startrace)
      EndIf
      If c\infected Then
         execute = c\vircommand Mod 64
         If execute/32>=1 Then
            c\health = c\health - 19
            new_cell(c\genom$, c\x+Rand(-10,10), c\y+Rand(-10,10), 2)
         Else
            execute = execute Mod 32
            If execute/16>=1 Then
               If c\health > 150 Then new_cell(c\genom$, c\x+Rand(-10,10), c\y+Rand(-10,10), 2):c\health = c\health-100
            EndIf
         EndIf
      EndIf
      c\x = c\x + (Cos(dir)*c\speed/100)
      c\y = c\y + (Sin(dir)*c\speed/100)
      c\lifetime = c\lifetime+1
      h = ImageHeight(c\pic)/2
      If c\x > 800 Then c\x = 800
      If c\y > 600 Then c\y = 600
      If c\x < 0 Then c\x = 0
      If c\y < 80+h Then c\y = 80+h
      If c\nutrition <> 2 Then
         If c\lifetime > c\lifespan Then c\kill=c\kill+.1
         If c\health < 20 Then c\kill=c\kill+2
      Else
         If c\health <0 Then c\kill = 2
      EndIf
      If c\kill>1 Then FreeImage(c\pic):Delete c.cell
   Next
   rechoose = rechoose - 1
   If rechoose = 1 Then key=usekey:ext=0:Goto chooseagain
   For key = 1 To 10
      If KeyHit(key+1) Then
         If KeyDown(29) Or KeyDown(157) Then
            ext = 0
            While Not MouseHit(2)
               .chooseagain
               If savepics(key) Then FreeImage savepics(key)
               savepics(key) = create_save_pic(saves$(key))
               mh1 = MouseHit(1)
               Color 255, 255, 255
               part1g$ = ""
               part2g$ = ""
               For i = 1 To 22
                  part1g$ = part1g$+" "+readblock(saves$(key), i)
               Next
               part1g$ = Right(part1g$, Len(part1g$)-1)
               For i = 23 To 44
                  part2g$ = part2g$+" "+readblock(saves$(key), i)
               Next
               part2g$ = Right(part2g$, Len(part2g$)-1)
               For i = 2 To 20 Step 2
                  Line 94+32*i, 40, 94+32*i, 55
               Next
               For i = 2 To 20 Step 2
                  Line 94+32*i, 55, 94+32*i, 70
               Next
               Text 34, 40, " Genom: "+part1g$
               Text 34, 55, "        "+part2g$
               part1o$ = ""
               part2o$ = ""
               For i = 1 To 22
                  part1o$ = part1o$+" "+readblock(startgenom$(saverace(key)), i)
               Next
               part1o$ = Right(part1o$, Len(part1o$)-1)
               For i = 23 To 44
                  part2o$ = part2o$+" "+readblock(startgenom$(saverace(key)), i)
               Next
               part2o$ = Right(part2o$, Len(part2o$)-1)
               For i = 2 To 20 Step 2
                  Line 94+32*i, 10, 94+32*i, 25
               Next
               For i = 2 To 20 Step 2
                  Line 94+32*i, 25, 94+32*i, 39
               Next
               Text 10, 10, "Startgenom:"+part1o$
               Text 10, 25, "           "+part2o$
               Text 10, 70, "Mutationen: "+count_mutations(saves$(key), startgenom$(saverace(key)))
               Line 99, 39, 793, 39
               Line 0, 70, 800, 70
               Color 0, 255, 0
               Text 10, 10, "           "+compare$(part1o$, part1g$)
               Text 10, 25, "           "+compare$(part2o$, part2g$)
               Color 255, 0, 0
               Text 10, 40, "           "+compare$(part1g$, part1o$)
               Text 10, 55, "           "+compare$(part2g$, part2o$)
               DrawImage savepics(key), 20, 50
               If mh1=1 Then
                  If MouseY()>40 And MouseY()<70 Then
                     If MouseX()>98 And MouseX()<98+(Len(part1g$)*8) Then
                        For i = 1 To Len(part1g$)
                           If MouseX()>98+i*8 Then xpos = i
                        Next
                        xpos2# = xpos
                        xpos2# = xpos2#/4
                        xpos = Floor(xpos2#)+1
                        If MouseY()<55 Then
                           saves$(key) = modify_block(no_spaces(saves$(key)), xpos)
                        Else
                           saves$(key) = modify_block(no_spaces(saves$(key)), 22+xpos)
                        EndIf
                        usekey = key
                        rechoose = 3
                        ext = 1
                     EndIf
                  EndIf
               EndIf
               If ext Then Exit
               If KeyHit(1) Then End
               Flip
            Wend
         Else
            new_cell(saves(key), MouseX(), MouseY(), saverace(key))
         EndIf
      EndIf
   Next
   If MouseHit(2) Then
      chosen = 0
      For c.cell = Each cell
         h = ImageHeight(c\pic)/2
         w = ImageWidth(c\pic)/2
         If MouseX() > c\x-w And MouseX() < c\x+w Then
            If MouseY() > c\y-h And MouseY() < c\y+h Then
               FreeImage(c\pic)
               Delete c.cell
               chosen = 1
            EndIf
         EndIf
         If chosen Then Exit
      Next
      FlushMouse
   EndIf
   If mh1 Or statsin Then
      If fast=0 Or (fast=1 And flipframe=1) Then
         chosen = 0
         For c.cell = Each cell
            h = ImageHeight(c\pic)/2
            w = ImageWidth(c\pic)/2
            If MouseX() > c\x-w And MouseX() < c\x+w Then
               If MouseY() > c\y-h And MouseY() < c\y+h Then
                  chosen = c\nr
               EndIf
            EndIf
            If chosen Then Exit
         Next
         If chosen Then
            While Not MouseHit(2)
               For c.cell = Each cell
                  If chosen = c\nr Then
                     Color 255, 255, 255
                     part1g$ = ""
                     part2g$ = ""
                     For i = 1 To 22
                        part1g$ = part1g$+" "+readblock(c\genom$, i)
                     Next
                     part1g$ = Right(part1g$, Len(part1g$)-1)
                     For i = 23 To 44
                        part2g$ = part2g$+" "+readblock(c\genom$, i)
                     Next
                     part2g$ = Right(part2g$, Len(part2g$)-1)
                     For i = 2 To 20 Step 2
                        Line 94+32*i, 40, 94+32*i, 55
                     Next
                     For i = 2 To 20 Step 2
                        Line 94+32*i, 55, 94+32*i, 70
                     Next
                     Text 34, 40, " Genom: "+part1g$
                     Text 34, 55, "        "+part2g$
                     part1o$ = ""
                     part2o$ = ""
                     For i = 1 To 22
                        part1o$ = part1o$+" "+readblock(startgenom$(c\startrace), i)
                     Next
                     part1o$ = Right(part1o$, Len(part1o$)-1)
                     For i = 23 To 44
                        part2o$ = part2o$+" "+readblock(startgenom$(c\startrace), i)
                     Next
                     part2o$ = Right(part2o$, Len(part2o$)-1)
                     For i = 2 To 20 Step 2
                        Line 94+32*i, 10, 94+32*i, 25
                     Next
                     For i = 2 To 20 Step 2
                        Line 94+32*i, 25, 94+32*i, 39
                     Next
                     Text 10, 10, "Startgenom:"+part1o$
                     Text 10, 25, "           "+part2o$
                     Text 10, 70, "Mutationen: "+count_mutations(c\genom$, startgenom$(c\startrace))
                     Line 99, 39, 793, 39
                     Line 0, 70, 800, 70
                     Color 0, 255, 0
                     Text 10, 10, "           "+compare$(part1o$, part1g$)
                     Text 10, 25, "           "+compare$(part2o$, part2g$)
                     Color 255, 0, 0
                     Text 10, 40, "           "+compare$(part1g$, part1o$)
                     Text 10, 55, "           "+compare$(part2g$, part2o$)
                     DrawImage c\pic, 20, 50
                     For i = 1 To 10
                        If KeyHit(i+1) Then saves$(i)=c\genom$:saverace(i)=c\startrace
                     Next
                     Delay 100
                     Color 255, 255, 0
                     If KeyHit(1) Then End
                     Flip
                  EndIf
               Next
            Wend
         EndIf
         If statsin=1 Then fast=1
         statsin=0
      Else
         statsin=1
      EndIf
   EndIf
   If fast=0 Or (fast=1 And flipframe=1) Then
      cell_stats()
      Color 255, 255, 255
      Text 10, 10, "Zellen:         "+(stats(1)+stats(5))+"/"+maxcells
      Text 10, 25, "Beste HP:       "+stats2(1)
      Text 10, 40, "Beste MaxHP:    "+stats(2)
      Text 10, 55, "Max Mutationen: "+stats(3)
      Text 220, 25, "tier. Zellen:   "+stats(4)
      Text 220, 40, "pflanzl. Zellen:"+(stats(1)-stats(4))
      Text 220, 55, "Viren:          "+stats(5)
      If fast Then Text 760, 10, ">>"
      Line 0, 70, 800, 70
      For i = 1 To 10
         If saves(i) <> "" Then
            Rect 200+i*20, -1, 11, 21, 0
            Text 201+i*20, 3, i
         EndIf
      Next
      If mh1 Then
         If MouseY()>10 And MouseY()<20
            If MouseX()>144+Len(Str(stats(1)))*8 And MouseX()<144+Len(Str(stats(1)))*8+Len(Str(maxcells))*8
               maxcells=input2("Maximale Zellenanzahl:")
            EndIf
         EndIf
      EndIf
      Color 255, 255, 0
   EndIf
   flipframe = 1-flipframe
   If fast=0 Then Flip
   If flipframe=0 And fast=1 Then Flip
   If KeyHit(32) Then fast = 1-fast
   If statsin Then fast=0
   If KeyHit(59) Then
      For c.cell = Each cell
         FreeImage c\pic
         Delete c.cell
      Next
   EndIf
   Delay 3
Wend
End

Function input2$(capt$="", opt=0, minlen=0, maxlen=0) ;opt=0: alles, opt=1: int, minlen/maxlen: länge des inputs, 0 für unbegrenzt
   FlushKeys
   Color 128, 128, 128
   Rect 250, 200, 300, 200
   Color 0, 0, 0
   Text 400, 250, capt$, 1, 1
   Color 0, 0, 0
   Rect 300, 300, 200, 16
   Color 255, 255, 255
   Locate 302, 302
   While done=0
      done = 0
      out$ = Input()
      If Len(out$)<minlen Or (Len(out$)>maxlen And maxlen<>0) Then
         new_block$ = ""
         Color 0, 0, 0
         Text 400, 330, "Falsche Länge.", 1, 1
         If minlen = 0 Then
            Text 400, 345, "(höchstens bis "+maxlen+" Zeichen)", 1, 1
         EndIf
         If maxlen = 0
            Text 400, 345, "(mindestens "+minlen+" Zeichen)", 1, 1
         EndIf
         If minlen<>0 And maxlen<>0 Then
            Text 400, 345, "(nur "+minlen+" bis "+maxlen+" Zeichen erlaubt)", 1, 1
         EndIf
         Color 0, 0, 0
         Rect 300, 300, 200, 16
         Color 255, 255, 255
         Locate 302, 302
      ElseIf opt =1 Then
         out2 = out$
         If Str(out2) = out$ Then
            done = 1
         Else
            new_block$ = ""
            Color 0, 0, 0
            Text 400, 330, "Falsche Zeichen.", 1, 1
            Text 400, 345, "(nur Ziffern erlaubt)", 1, 1
            Color 0, 0, 0
            Rect 300, 300, 200, 16
            Color 255, 255, 255
            Locate 302, 302
         EndIf
      Else
         done = 1
      EndIf
   Wend
   FlushKeys
   FlushMouse
   Return out$
End Function

Function modify_block$(genom$, nr)
   FlushKeys
   block$ = readblock$(genom$, nr)
   Color 128, 128, 128
   Rect 250, 200, 300, 200
   Color 0, 0, 0
   Text 400, 250, block$, 1, 1
   Color 0, 0, 0
   Rect 300, 300, 200, 16
   Color 255, 255, 255
   Locate 302, 302
   While Len(new_block$)<>3
      new_block$ = Upper(Input())
      ok = 0
      new_block$ = LSet(new_block$, 3)
      new_block$ = Replace(new_block$, " ", "0")
      For x = 1 To 3
         For y = 0 To 15
            ok = ok+(chars$(y)=Mid(new_block$, x, 1))
         Next
      Next
      If ok<>3 Then
         new_block$ = ""
         Color 0, 0, 0
         Text 400, 330, "Falsche Zeichen", 1, 1
         Text 400, 345, "(nur Hexadezimalzahlen erlaubt)", 1, 1
         Color 0, 0, 0
         Rect 300, 300, 200, 16
         Color 255, 255, 255
         Locate 302, 302
      EndIf
   Wend
   times = Len(genom$)/3
   For i = 1 To times
      If nr<>i Then
         out$ = out$ + readblock$(genom$, i)
      Else
         out$ = out$ + new_block
      EndIf
   Next
   FlushKeys
   FlushMouse
   Return out$
End Function

Function replace_block$(genom$, nr, repl$)
   times = Len(genom$)/3
   For i = 1 To times
      If nr<>i Then
         out$ = out$ + readblock$(genom$, i)
      Else
         out$ = out$ + repl$
      EndIf
   Next
   Return out$
End Function

Function no_spaces$(in$)
   Return Replace(in$, " ", "")
End Function

Function compare$(genom1$, genom2$)
   length = Len(genom1$)
   If length<Len(genom2$) Then
      length=Len(genom2):genom1$=LSet(genom1$, length)
   Else
      genom2$=LSet(genom2$, length)
   EndIf
   For i = 1 To length
      comp1$ = Mid(genom1$, i, 1)
      comp2$ = Mid(genom2$, i, 1)
      If comp1$ = comp2$ Then
         out$=out$+" "
      Else
         out$=out$+comp1$
      EndIf
   Next
   Return out
End Function

Function count_mutations(genom1$, genom2$)
   length = Len(genom1$)
   If length<Len(genom2$) Then
      length=Len(genom2):genom1$=LSet(genom1$, length)
   Else
      genom2$=LSet(genom2$, length)
   EndIf
   For i = 1 To length
      comp1$ = Mid(genom1$, i, 1)
      comp2$ = Mid(genom2$, i, 1)
      If comp1$ <> comp2$ Then
         mutations = mutations+1
      EndIf
   Next
   Return mutations
End Function

Function cell_stats()
   Dim stats(5)
   Dim stats2(5)
   For c.cell = Each cell
      If c\nutrition <> 2 Then
         stats(1)=stats(1)+1
      Else
         stats(5)=stats(5)+1
      EndIf
      If c\health>stats2(1) Then stats2(1)=c\health
      If c\maxhealth>stats(2) Then stats(2)=c\maxhealth
      mutations = count_mutations(c\genom$, startgenom$(c\startrace))
      If mutations>stats(3) Then stats(3)=mutations
      If c\nutrition=0 Then stats(4) = stats(4) + 1
   Next
End Function

Function dist(x1, y1, x2, y2)
   distance = (x1-x2)^2+(y1-y2)^2
   distance = distance^.5
   Return distance
End Function

Function refreshcells()
   For c.cell = Each cell
      FreeImage(c\pic)
      Delete c.cell
   Next
   For x = 200 To 600 Step 100
      For y = 100 To 500 Step 100
         If Rand(1,10) = 10 Then
            new_cell(startgenom$(0), x, y, 0)
         ElseIf Rand(1,20) = 1 Then
            new_cell(startgenom$(2), x, y, 2)
         Else
            new_cell(startgenom$(1), x, y, 1)
         EndIf
      Next
   Next
End Function

Function hex2$(in)
   out$ = Hex(in)
   For i = 1 To 8
      If Left(out$, 1) = "0" Then out$ = Right(out$, Len(out$)-1)
   Next
   If out$="" Then out$="0"
   Return out$
End Function

Function new_cell(genom$, x, y, race=100)
   If stats(1)+stats(5)<maxcells Then
      stats(1) = stats(1) +1
      mutate_rate = Rand(-12, 3)
      cells = cells+1
      genom$ = mutate$(genom$, mutate_rate)
      c.cell = New cell
      c\nr = cells
      c\x = x
      c\y = y
      c\genom$ = genom$
      nut = 0
      vgenom = 0
      blocks = Len(genom$)/3
      Dim current_cell_pic(4,1)
      For i = 1 To blocks Step 2
         b$ = readblock$(genom$, i)
         If Left(b$,1) = "0" Then
            If b$ = health$ Then
               c\health$ = unhex(readblock(genom$, i+1)) Mod 1024
               c\maxhealth$ = c\health*3
            EndIf
            If b$ = nutrition$ Then
               c\nutrition = unhex(readblock(genom$, i+1))
               nut = 1
               virnut = 0
               For v = 1 To 3
                  virnut = virnut+(Mid(readblock(genom$,i+1), v,1) = "6")
               Next
               If c\nutrition > 2047 Then
                  c\nutrition = 0
               Else
                  c\nutrition = 1
               EndIf
               If virnut>1 Then c\nutrition = 2
            EndIf
            If b$ = speed$ Then
               c\speed$ = unhex(readblock(genom$, i+1)) Mod 512
            EndIf
            If b$ = c_r$ Then
               rc = unhex(readblock(genom$, i+1)) Mod 256
            EndIf
            If b$ = c_g$ Then
               gc = unhex(readblock(genom$, i+1)) Mod 256
            EndIf
            If b$ = c_b$ Then
               bc = unhex(readblock(genom$, i+1)) Mod 256
            EndIf
            For d=1 To 4
               For v=0 To 1
                  If b = seq_pos$(d,v) Then
                     current_cell_pic(d, v) = unhex(readblock(genom$, i+1)) Mod 64
                  End If
               Next
            Next
            If b$ = photosynth$ Then
               c\photosynth = unhex(readblock(genom$, i+1)) Mod 16
            EndIf
            If b$ = breedtime$ Then
               c\breedtime = 300+unhex(readblock(genom$, i+1)) Mod 256
            EndIf
            If b$ = lifespan$ Then
               c\lifespan = unhex(readblock(genom$, i+1))
            EndIf
            If b$ = vircommand$ Then
               c\vircommand = unhex(readblock(genom$, i+1))
            EndIf
            If b$ = virgenom$ Then
               c\virgenom$[vgenom] = unhex(readblock(genom$, i+1))
               vgenom=vgenom+1
            EndIf
         End If
      Next
      If c\nutrition = 1 Then c\speed = c\speed/2
      If nut = 0 Then c\nutrition = 3
      If race = 100 Then
         c\startrace = c\nutrition
      Else
         c\startrace = race
      EndIf
      If c\breedtime = 0 And c\nutrition <> 2 Then Delete c.cell:Return
      If c\nutrition = 2 Then
         c\activatetime = Rand(1, 50000)
         c\pic = create_vir_pic(rc, gc, bc)
      Else
         c\pic = create_cell_pic(rc, gc, bc)
      EndIf
   EndIf
End Function

Function create_save_pic(genom$)
   c.cell = New cell
   c\nr = cells
   c\x = x
   c\y = y
   c\genom$ = genom$
   nut = 0
   vgenom = 0
   blocks = Len(genom$)/3
   Dim current_cell_pic(4,1)
   For i = 1 To blocks Step 2
      b$ = readblock$(genom$, i)
      If Left(b$,1) = "0" Then
         If b$ = health$ Then
            c\health$ = unhex(readblock(genom$, i+1)) Mod 1024
            c\maxhealth$ = c\health*3
         EndIf
         If b$ = nutrition$ Then
            c\nutrition = unhex(readblock(genom$, i+1))
            nut = 1
            virnut = 0
            For v = 1 To 3
               virnut = virnut+(Mid(readblock(genom$,i+1), v,1) = "6")
            Next
            If c\nutrition > 2047 Then
               c\nutrition = 0
            Else
               c\nutrition = 1
            EndIf
            If virnut>1 Then c\nutrition = 2
         EndIf
         If b$ = speed$ Then
            c\speed$ = unhex(readblock(genom$, i+1)) Mod 512
         EndIf
         If b$ = c_r$ Then
            rc = unhex(readblock(genom$, i+1)) Mod 256
         EndIf
         If b$ = c_g$ Then
            gc = unhex(readblock(genom$, i+1)) Mod 256
         EndIf
         If b$ = c_b$ Then
            bc = unhex(readblock(genom$, i+1)) Mod 256
         EndIf
         For d=1 To 4
            For v=0 To 1
               If b = seq_pos$(d,v) Then
                  current_cell_pic(d, v) = unhex(readblock(genom$, i+1)) Mod 64
               End If
            Next
         Next
         If b$ = photosynth$ Then
            c\photosynth = unhex(readblock(genom$, i+1)) Mod 16
         EndIf
         If b$ = breedtime$ Then
            c\breedtime = 300+unhex(readblock(genom$, i+1)) Mod 256
         EndIf
         If b$ = lifespan$ Then
            c\lifespan = unhex(readblock(genom$, i+1))
         EndIf
         If b$ = vircommand$ Then
            c\vircommand = unhex(readblock(genom$, i+1))
         EndIf
         If b$ = virgenom$ Then
            c\virgenom$[vgenom] = unhex(readblock(genom$, i+1))
            vgenom=vgenom+1
         EndIf
      End If
   Next
   If c\nutrition = 1 Then c\speed = c\speed/2
   If nut = 0 Then c\nutrition = 3
   If race = 100 Then
      c\startrace = c\nutrition
   Else
      c\startrace = race
   EndIf
   If c\breedtime = 0 And c\nutrition <> 2 Then Delete c.cell:Return
   If c\nutrition = 2 Then
      c\activatetime = Rand(1, 50000)
      c\pic = create_vir_pic(rc, gc, bc)
   Else
      c\pic = create_cell_pic(rc, gc, bc)
   EndIf
   sp = c\pic
   Delete c.cell
   Return sp
End Function

Function create_cell_pic(r, g, b)
   Color r, g, b
   If r = 0 Then r = 1
   While xmax+ymax < 40
      xmax = 0
      ymax = 0
      For i = 1 To 4
         If current_cell_pic(i,1) > xmax Then xmax = current_cell_pic(i,1)
         If current_cell_pic(i,0) > ymax Then ymax = current_cell_pic(i,0)
      Next
      If xmax+ymax < 40 Then
         For i = 1 To 4
            current_cell_pic(i,0) = current_cell_pic(i,0)*2
            current_cell_pic(i,1) = current_cell_pic(i,1)*2
         Next
      EndIf
      If xmax = 0 Then
         For i = 1 To 4
            current_cell_pic(i,0) = 1
         Next
      EndIf
      If ymax = 0 Then
         For i = 1 To 4
            current_cell_pic(i,1) = 1
         Next
      EndIf
   Wend
   pic = CreateImage(ymax+1, xmax+1)
   SetBuffer ImageBuffer(pic)
   For i = 1 To 4
      nx = i+1
      If nx>4 Then nx = 1
      Line current_cell_pic(i, 0), current_cell_pic(i, 1), current_cell_pic(nx, 0), current_cell_pic(nx, 1)
   Next
   SetBuffer BackBuffer()
   MidHandle pic
   Return pic
End Function

Function create_vir_pic(r, g, b)
   Color r, g, b
   If r = 0 Then r = 1
   xmax = 0
   ymax = 0
   For i = 1 To 3
      For v = 0 To 1
         current_cell_pic(i,v) = current_cell_pic(i,v)/4
      Next
   Next
   For i = 1 To 3
      If current_cell_pic(i,0) > xmax Then xmax = current_cell_pic(i,1)
      If current_cell_pic(i,1) > ymax Then ymax = current_cell_pic(i,0)
   Next
   pic = CreateImage(ymax+1, xmax+1)
   SetBuffer ImageBuffer(pic)
   For i = 1 To 3
      nx = i+1
      If nx>3 Then nx = 1
      Line current_cell_pic(i, 0), current_cell_pic(i, 1), current_cell_pic(nx, 0), current_cell_pic(nx, 1)
   Next
   SetBuffer BackBuffer()
   MidHandle pic
   Return pic
End Function

Function mutate$(genom$, rate)
   If rate>0 Then
      For i = 1 To rate
         If Rand(1,8) = 8 Then
            sp = Rand(1, Len(genom$)-1)
            genom$ = cutout_sequence$(genom$, sp, sp)
         Else
            sp = Rand(1, Len(genom$)-1)
            genom$ = replace_sequence$(genom$, sp, sp)
         EndIf
      Next
   EndIf
   Return genom$
End Function

Function readblock$(genom$, block)
   Return Mid(genom$, block*3-2, 3)
End Function

Function replace_sequence$(genom$, start, ende)
   genom_end$ = Right(genom$, Len(genom)-ende)
   genom$ = Left(genom$, start-1)
   If ende-start+1>0 Then
   For i = 1 To ende-start+1
      genom$ = genom$+chars$(Rand(0,15))
   Next
   EndIf
   genom$ = genom$+genom_end$
   Return genom$
End Function

Function cutout_sequence$(genom$, start, ende)
   genom_end$ = Right(genom$, Len(genom)-ende)
   genom$ = Left(genom$, start-1)+genom_end$
   For i = 1 To ende-start+1
      genom$ = genom$+"0"
   Next
   Return genom$
End Function

Function unhex(in$)
   For i = 1 To Len(in$)
      out = out+unhex_1(in$, i)*16^(Len(in$)-i)
   Next
   Return out
End Function

Function unhex_1(in$, pos)
   in$ = Mid(in$, pos, 1)
   For i = 0 To 15
      If chars$(i) = in$ Then Return i
   Next
End Function


für Leute ohne BB: klick mich

es ist vll nicht so naturgetreu, dafür ist es wesentlich bedienbarer und langlebiger (es dauert min ein paar Minuten bis nichts mehr lebt)

zur Steuerung:
Enter - Licht auf-/abdrehen (abgedreht gehen die pflazenzellen ein)
Leer - neue Runde starten
F1 - Spielfelt leeren
Rechte Maus - Zelle löschen
Linke Maus - Genom der Zelle anschauen
während dem anschauen 1-9 - genom speichern
1-9 - gepeicherte zelle setzten
strg + 1-9 - gespeichertes genom anschauen
während dem anschauen linke maus auf das genom - gewählten block verändern (achtung: nur hex-zeichen)
Ein Klick auf die rechte Zahl links oben bei "Zellen:" lässt einen die maximale Zellenanzahl verändern.

Um das Ganze sich anschauen zu können, muss man Folgendes nicht unbedingt wissen, um aber alles an diesem Programm ausreizen zu können aber schon.

Zu der Erbinformation der Zellen:

Die Erbinformation ist in Doppelblöcken organisiert (z.B. 001 050). Dabei übernimmt der 1. Block (001) die Aufgabe eines Variablennamens (in diesem Fall sind das die maximalen Lebenspunkte) und der 2. Block (050) den Wert. D.H. 001 050 setzt die maximalen Lebenspunkte der Zelle auf 50.
Erlaubt sind nur Hexadezimalzahlen.
Jedes mal, wenn eine Zelle gespawnt wird, hat sie eine Chance, das ein paar Stellen ihrer Erbinformation auf eine zufälligen Wert geändert werden.

Die Bedeutung der Blocks ist jene:

"001" =Lebenspunkte, wird mod 1024 genommen (1023 ist maxwert)
"002" =Ernährung, 0-7ffe - pflanze, darüber tierische zelle. bei 2 oder 3 6ern ein virus
"003" =Bewegungsgeschwindigkeit, wird mod 512 genommen (511 ist maxwert)
"004" =Rotwert, wird mod 256 genommen
"005" =Grünwert, wird mod 256 genommen
"006" =Blauwert, wird mod 256 genommen
"007" bis "00A" =x-Positionen der ecken, mod 64
"00B" bis "00E" =y-Positionen der ecken, mod 64
"012" =Lebenspunkte, die eine Pflanze pro Frame bekommt, mod 8 (kein Effekt auf Viren/tierische Tellen)
"010" =Dauer bis zur Zellteilung, 300 + wert mod 256
"011" =Lebensdauer in Frames
"123" =wenn eine Zelle irgend einen Block hat, der so ausschaut, ist sie immun gegen Viren. Wenn ein Virus diesen Block hat, kommt er gegen die Immunität an.

"013" =Auftrag/Handlungsweise eines Viruses (kein Effekt auf nicht-Viren)
Das dafür gibts folgende Werte: (nach Bitmaskenschema zusammenfügbar, um mehrere Optionen gleichzeitig zu verwenden, 1 und 2 können nicht gleichzeitig verwendet werden.)
1 ... DNA der Zelle wird mit DNA des Virus überschrieben, Zelle spammt Zellen (Viren) mit der neuen DNA, allerdings nur so, das die Zelle dabei gerade nicht draufgeht.
2 ... DNA der Zelle wird mit DNA des Virus überschrieben, Zelle spammt Zellen (Viren) mit der neuen DNA. Dabei achtet die Zelle nicht darauf, selbst zu überleben.
4 ... Der Virus überschreibt bestimmte Teile der Erbinformation der Zielzelle.


4. funktioniert so:
(wir aktiv, nachdem 1/2 angewendet wurden, damit kann man Zielzellen andere Zellen spawnen lassen, als den Virus)
es durchsucht alle Blöcke des Virus nach Doppelblöcken, wo der 1. Block mit "F" beginnt. Dann wird bei der Zielzelle der Block mit der Nummer, die vor dem F steht (z.B. bei "05F" der 5. Block) mit dem Wert, der im 2. Block des Doppelblocks steht, überschrieben.
Beispiel dazu: "02F 100" überschreibt den 2. Block der Zielzelle (Achtung: Damit ist der 2. Block, nicht der 2. Doppelblock gemeint) mit 100.
Gewinner der 6. und der 68. BlitzCodeCompo

MikeDee

BeitragMi, Jun 11, 2008 20:26
Antworten mit Zitat
Benutzer-Profile anzeigen
des ist auch gut gemacht.
Ich hab auch eine sim im Plan, aber ich kann die nicht machen da ich noch zu wenig ahnung habe^^.
Die sim wird nur 3 eigenschaften haben (welches auch die Farbe bestimmt):
Schnelligkeit, Größe/Leben und ernährung/agressivität.

Es gibt einen "Pflanzenteppich" und ein Bakterium, welches sich vermehrt und ein nachkomme irgendwann zum Fleischfresser wird, weil die agressivität einen Wert überschritten hat.
Nicht wenige benutzen die Anonymität des Internets um berühmt zu werden.

Gehe zu Seite Zurück  1, 2

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group