资源简介
生命游戏其实是一个零玩家游戏,它包括一个二维矩形世界,这个世界中的每个方格居住着一个活着的或死了的细胞。一个细胞在下一个时刻生死取决于相邻八个方格中活着的或死了的细胞的数量。如果相邻方格活着的细胞数量过多,这个细胞会因为资源匮乏而在下一个时刻死去;相反,如果周围活细胞过少,这个细胞会因太孤单而死去。实际中,你可以设定周围活细胞的数目怎样时才适宜该细胞的生存。如果这个数目设定过低,世界中的大部分细胞会因为找不到太多的活的邻居而死去,直到整个世界都没有生命;如果这个数目设定过高,世界中又会被生命充满而没有什么变化。实际中,这个数目一般选取2或者3;这样整个生命世界才不至于太过荒凉或拥挤,而是一种动
代码片段和文件信息
%Conway‘s life with GUI
clf
clear all
%=============================================
%build the GUI
%define the plot button
plotbutton=uicontrol(‘style‘‘pushbutton‘...
‘string‘‘Run‘ ...
‘fontsize‘12 ...
‘position‘[1004005020] ...
‘callback‘ ‘run=1;‘);
%define the stop button
erasebutton=uicontrol(‘style‘‘pushbutton‘...
‘string‘‘Stop‘ ...
‘fontsize‘12 ...
‘position‘[2004005020] ...
‘callback‘‘freeze=1;‘);
%define the Quit button
quitbutton=uicontrol(‘style‘‘pushbutton‘...
‘string‘‘Quit‘ ...
‘fontsize‘12 ...
‘position‘[3004005020] ...
‘callback‘‘stop=1;close;‘);
number = uicontrol(‘style‘‘text‘ ...
‘string‘‘1‘ ...
‘fontsize‘12 ...
‘position‘[204005020]);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2226 2014-02-08 11:33 calife.m
----------- --------- ---------- ----- ----
2226 1
评论
共有 条评论