惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
Intezer
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
N
News | PayPal Newsroom
T
Tenable Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
P
Privacy International News Feed
IT之家
IT之家
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
博客园_首页
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
Martin Fowler
Martin Fowler
NISL@THU
NISL@THU
I
InfoQ
D
DataBreaches.Net
有赞技术团队
有赞技术团队
K
Kaspersky official blog
Security Latest
Security Latest
The Register - Security
The Register - Security
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic

博客园 - Hi Jew

随笔 Rails 语法笔记 - Hi Jew Cart creation 中的Ruby session问题 BizTalk Server : 提高 BizTalk 编程能力的 8 点技巧和窍门 Update SQL Server database with Updategrams 深入biztalk中sql adapter Ivar Jacobson .net如何连接oracle数据库 怎样用Codematic 连接Oracle数据库 数据库连接字符串大全 ASP.NET2.0 Provider模型(上) ——原理、模型与分析 什么是J2EE .net 和 j2ee的区别 IIS5.0和IIS6.0 Apache 或者 Apache.exe Oracle.EXE JAVA虚拟机 JAVA.exe进程 Windows XP/2003系统服务优化 安装Windows server 2003系统后无法安装显卡驱动的解决办法 (转载)
IDL实现的元胞自动机模型 Conway Life Game
Hi Jew · 2009-09-23 · via 博客园 - Hi Jew

刚用IDL实现的Conway生命游戏的元胞自动机模型,看到了不可思议的图案....

;输入参数时,dimI=dimJ

;dimI,二维元胞空间的行数

;dimJ,二维元胞空间的列数

;IterateTimes,本次迭代的数据

PRO CONWAY_LIFE_GAME,dimI,dimJ,IterateTimes

;变量定义区

;元胞空间,初始值时让对角线为生存。

cellSpace=indgen(dimI+2,dimJ+2)

;临时元胞空间,每次计算时临时保存值,每次完成计算后,将值给正式的元胞空间。

tempCellSpace=cellSpace

;用一个100X100的数组表示元胞空间,

;数组元素中的值如果为0,则表示该元胞是死亡状态,在屏幕上用一个白点表示。

;数据元素中的值如果为1,则表示该元胞是生存状态,在屏幕上用一个黑点表示。

;(1)Conway生命游戏是一个二维元胞自动机

;(2)元胞有两种状态,0代表死亡,1代表生存

;(3)元胞的邻居采用Moore型邻居形式。

; (4) 元胞的边界采用"固定边界"的形式进行处理,即边界之外的元胞的状态统一默认为0。

;####初始值时让对角线为生存,同时第一、二列为生存。####

for subi=0,(dimI+1) do begin

for subj=0,(dimJ+1) do begin

if (subi eq subj) then begin

cellSpace[subi,subj]=1

endif else begin

cellSpace[subi,subj]=0

endelse

endfor

endfor

for subi=1,(dimJ) do begin

cellSpace[subi,1]=1

cellSpace[subi,2]=1

endfor

cellSpace[0,0]=0

cellSpace[dimI+1,dimI+1]=0

;####打印初始元胞空间####

;用RGB方式表操作屏幕的像素颜色,黑色代表生存

data = BytArr(3,dimI,dimI)

;先将屏幕的一个指定区域(100X100变为白色)

for i=0,(dimI-1) do begin

for j=0,(dimI-1) do begin

data[*, i, j] = [255,255,255]

endfor

endfor

for i=1,(dimI) do begin

for j=1,(dimJ) do begin

if (cellSpace[i,j] eq 1) then begin

data[*,i-1,j-1] = [0,0,0]

endif

endfor

endfor

;        data[*,0, 9] = [255,255,255]

        Window,0, XSize = 100, YSize = 100

        Tv, data, /True

;*****初始化临时元胞空间*******

for subi=0,(dimI+1) do begin

for subj=0,(dimJ+1) do begin

tempCellSpace[subi,subj]=0

endfor

endfor

print,cellSpace

;for 迭代次数

for iTs=0,(IterateTimes) do begin

;对元胞空间中的每一个值,并结合其邻居进行分析,并按照演化规则进行操作

for subi=1,(dimI) do begin

for subj=1,(dimJ) do begin

;计算其周围邻居的数量

nNums=0

nNums=nNums+cellSpace[subi-1,subj-1]+cellSpace[subi-1,subj]+cellSpace[subi-1,subj+1]+ $

cellSpace[subi,subj-1]+cellSpace[subi+1,subj-1]+cellSpace[subi+1,subj]+cellSpace[subi+1,subj+1]+ $

cellSpace[subi,subj+1]

;如果该元胞为死亡状态....

if (cellSpace[subi,subj] eq 0) then begin

;判断其周围邻居的数量,如果邻居数量为=3,则该元胞为生存状态

if (nNums eq 3) then begin

tempCellSpace[subi,subj]=1

endif

;判断其周围邻居的数量,如果邻居的数量不<>3,则该元胞为死亡状态

if (nNums ne 3) then begin

tempCellSpace[subi,subj]=0

endif

endif

;如果该元胞为生存状态...

if(cellSpace[subi,subj] eq 1) then begin

;判断其周围邻居的数量,如果邻居数量为=3 or =2,则该元胞为生存状态

if(nNums eq 3) or (nNums eq 2) then begin

tempCellSpace[subi,subj]=1

endif

;判断其周围邻居的数量,如果邻居数量为>3或<2,则该元胞为死亡状态

if(nNums gt 3) or (nNums lt 2) then begin

tempCellSpace[subi,subj]=0

endif

endif

endfor

endfor

;将临时元胞空间的值赋给正式的元胞空间

cellSpace=tempCellSpace

print,"Afterward"

;print,cellSpace

;用RGB方式表操作屏幕的像素颜色,黑色代表生存

data = BytArr(3,dimI,dimI)

;先将屏幕的一个指定区域(100X100变为白色)

for i=0,(dimI-1) do begin

for j=0,(dimI-1) do begin

data[*, i, j] = [255,255,255]

endfor

endfor

for i=1,(dimI) do begin

for j=1,(dimJ) do begin

if (cellSpace[i,j] eq 1) then begin

data[*,i-1,j-1] = [0,0,0]

endif

endfor

endfor

;        data[*,0, 9] = [255,255,255]

;its为iterateTimes,代表演化的步数

        Window ,its+1, XSize = 100, YSize = 100

        Tv, data, /True

;endfor 迭代次数

endfor

END