Conways_game_of_life_breeder_animation.gif
Description Conways game of life breeder animation.gif | Animation of breeder pattern in Conway's Game of Life |
Date | (UTC) |
Source | |
Author |
|
Permission
( Reusing this file ) |
See below |
Recognition
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the
Creative Commons
Attribution-Share Alike 3.0 Unported
license.
-
You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
-
Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Source Code
The first generation is the bmp file 000001.bmp (which should be saved in the same folder as the script).
a=file('000001.bmp','rb+')
head=a.read(54);mat=[];wid=379;hei=192
for l in range(wid): mat.append([False]*hei)
for y in range(hei):
for x in range(wid):
mat[x][y]=(a.read(3)==chr(0)*3)
useless=a.read(wid%4)
def num(x,y):
options=[]
options.append(mat[(x+1)%wid][(y )%hei])
options.append(mat[(x+1)%wid][(y+1)%hei])
options.append(mat[(x )%wid][(y+1)%hei])
options.append(mat[(x-1)%wid][(y+1)%hei])
options.append(mat[(x-1)%wid][(y )%hei])
options.append(mat[(x-1)%wid][(y-1)%hei])
options.append(mat[(x )%wid][(y-1)%hei])
options.append(mat[(x+1)%wid][(y-1)%hei])
return options.count(True)
def newgen():
newmat=[]
for l in range(wid): newmat.append([False]*hei)
for y in range(hei):
for x in range(wid):
numnum=num(x,y)
if not mat[x][y] and numnum==3: newmat[x][y]=True
elif mat[x][y] and (numnum==2 or numnum==3): newmat[x][y]=True
return newmat
for l in range(2,499):
b=file(str(l).zfill(6)+'.bmp','wb+')
b.write(head);mat=newgen()
for y in range(hei):
for x in range(wid):
b.write(chr(255-255*int(mat[x][y]))*3)
b.write(chr(0)*(wid%4))
print chr(8)*30+str(l).zfill(6)+'.bmp finished.',
Original upload log
This image is a derivative work of the following images:
-
Image:Conways_game_of_life_breeder.png
licensed with Cc-by-sa-3.0, Cc-by-sa-3.0
- 2008-11-02T13:34:51Z Hyperdeath 379x192 (2881 Bytes) {{Information |Description= Breeder pattern in Conway's Game of Life |Source=self-made |Date= |Author= [[User:Hyperdeath|Hyperdeath]] |Permission= |other_versions= }}
Uploaded with derivativeFX