| 4 | 1/1 | 返回列表 |
| 查看: 1279 | 回復(fù): 3 | |||
chrislan625新蟲 (小有名氣)
|
[求助]
求大神教MATLAB 生命游戲代碼怎么寫
|
|
老師叫我們自學(xué) 上課就要寫出一個生命游戲的代碼 看不太懂 以下是老師給的提示 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 |
新蟲 (小有名氣)
|
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? 這是這個程序要解決的問題 |
至尊木蟲 (著名寫手)
驃騎將軍

新蟲 (小有名氣)
| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 085410人工智能專碩317求調(diào)劑(0854都可以) +4 | xbxudjdn 2026-03-18 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 26調(diào)劑/材料/英一數(shù)二/總分289/已過A區(qū)線 +8 | 步川酷紫123 2026-03-13 | 8/400 |
|
|
[考研] 求調(diào)劑 +3 | 暗涌afhb 2026-03-16 | 3/150 |
|
|
[考研] 307求調(diào)劑 +9 | 冷笙123 2026-03-17 | 9/450 |
|
|
[考研] 288求調(diào)劑,一志愿華南理工大學(xué)071005 +5 | ioodiiij 2026-03-17 | 5/250 |
|
|
[考研] 085601材料工程專碩求調(diào)劑 +10 | 慕寒mio 2026-03-16 | 10/500 |
|
|
[考研] 一志愿北京化工大學(xué)0703化學(xué)318分,有科研經(jīng)歷,求調(diào)劑 +3 | 一瓶苯甲酸 2026-03-14 | 3/150 |
|
|
[考研] 一志愿西安交通大學(xué)材料工程專業(yè) 282分求調(diào)劑 +5 | 楓橋ZL 2026-03-18 | 7/350 |
|
|
[考研] 346求調(diào)劑[0856] +3 | WayneLim327 2026-03-16 | 6/300 |
|
|
[考研] 332求調(diào)劑 +3 | ydfyh 2026-03-17 | 3/150 |
|
|
[考研] 材料工程專碩調(diào)劑 +5 | 204818@lcx 2026-03-17 | 6/300 |
|
|
[考研] 304求調(diào)劑 +12 | 小熊joy 2026-03-14 | 13/650 |
|
|
[考研] 材料,紡織,生物(0856、0710),化學(xué)招生啦 +3 | Eember. 2026-03-17 | 9/450 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機(jī)?/a> 2026-03-16 | 3/150 |
|
|
[考研] 考研求調(diào)劑 +3 | 橘頌. 2026-03-17 | 4/200 |
|
|
[考博] 26申博 +4 | 八6八68 2026-03-16 | 4/200 |
|
|
[論文投稿] 有沒有大佬發(fā)小論文能帶我個二作 +3 | 增銳漏人 2026-03-17 | 4/200 |
|
|
[考研] 326求調(diào)劑 +4 | 諾貝爾化學(xué)獎覬?/a> 2026-03-15 | 7/350 |
|
|
[考研] 中科院材料273求調(diào)劑 +4 | yzydy 2026-03-15 | 4/200 |
|
|
[考研] 266求調(diào)劑 +4 | 學(xué)員97LZgn 2026-03-13 | 4/200 |
|