| 查看: 1419 | 回复: 3 | |||
[求助]
求大神教MATLAB 生命游戏代码怎么写
|
|
老师叫我们自学 上课就要写出一个生命游戏的代码 看不太懂 以下是老师给的提示 Skeleton program function game_of_life( nx, ny, nstep ) %GAME_OF_LIFE Implements the Conway game of life % This function implements the Conway game of life in which beings are % generated and destroyed in a manner meant to represent evolution. They % are destroyed when they have too few or two many neighbours, and are % generated at a location with the right number of neighbours. % % Input parameters % nx The number of squares along the x-direction % ny The number of squares along the y-direction % nstep The number of iterations in the game % % Output parameters % None % % % Define some constants delay = 0.1; % The time between images in seconds dx = [-1, 0, 1, -1, 1, -1, 0, 1]; dy = [ 1, 1, 1, 0, 0, -1, -1, -1]; % % Initialise the grid world = zeros(nx+2, ny+2); % Extra sites around the edge fixed to zero [Add code here] % % Display the world imagesc(world); pause(delay); % % Step through all the moves for i = 1:nstep % % Count the number of neighbours for each site [Add code here] % % Update the world [Add code here] % % Display the world imagesc(world); pause(delay); end end |
» 猜你喜欢
申请2027年材料/化学类博士
已经有5人回复
系统今天又提示维护了,估计离放榜不远了
已经有14人回复
2026年国自然面上资助率
已经有6人回复
你们的时间戳变了吗
已经有4人回复
微信指数没变化,科研之友没阅读
已经有16人回复
小木虫看见有人已经知道结果了
已经有17人回复
今年的WR进展到哪一步了?
已经有9人回复
产物和副产物价值比较
已经有5人回复
时间戳他又来了
已经有17人回复
这个自发加氧反应的机理是什么?
已经有7人回复
» 本主题相关价值贴推荐,对您同样有帮助:
修改一个C语言生命游戏程序
已经有3人回复
|
1. Consider the following starting configuration: a world made of 5x5 squares, with 3 creatures in a horizontal line (XXX) at the centre. How many creatures are alive after 5 steps? 2. Consider the following starting configuration: a world made of 7x7 squares, with 5 creatures in a horizontal line (XXXXX) at the centre. How many creatures are alive after 5 steps? 这是这个程序要解决的问题 |
2楼2013-11-11 05:42:48
libralibra
至尊木虫 (著名写手)
骠骑将军
- 程序强帖: 40
- 应助: 817 (博后)
- 金币: 12914.1
- 红花: 64
- 帖子: 2238
- 在线: 287.3小时
- 虫号: 696514
- 注册: 2009-02-05
- 专业: 计算机软件

3楼2013-11-11 21:15:04
4楼2013-11-15 09:24:29











回复此楼