| 5 | 1/1 | 返回列表 |
| 查看: 1281 | 回復: 3 | ||
| 當前只顯示滿足指定條件的回帖,點擊這里查看本話題的所有回帖 | ||
chrislan625新蟲 (小有名氣)
|
[求助]
求大神教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 |
至尊木蟲 (著名寫手)
驃騎將軍

新蟲 (小有名氣)
|
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? 這是這個程序要解決的問題 |
新蟲 (小有名氣)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 278求調(diào)劑 +6 | 煙火先于春 2026-03-17 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 材料專業(yè)求調(diào)劑 +6 | hanamiko 2026-03-18 | 6/300 |
|
|
[考研] 295求調(diào)劑 +4 | 一志愿京區(qū)211 2026-03-18 | 6/300 |
|
|
[考研] 294求調(diào)劑材料與化工專碩 +15 | 陌の森林 2026-03-18 | 15/750 |
|
|
[考研] 323求調(diào)劑 +3 | 洼小桶 2026-03-18 | 3/150 |
|
|
[考研] 材料學求調(diào)劑 +4 | Stella_Yao 2026-03-20 | 4/200 |
|
|
[考研] 281求調(diào)劑(0805) +14 | 煙汐憶海 2026-03-16 | 25/1250 |
|
|
[考研] 0856調(diào)劑,是學校就去 +8 | sllhht 2026-03-19 | 9/450 |
|
|
[考研] 081700化工學碩調(diào)劑 +3 | 【1】 2026-03-16 | 3/150 |
|
|
[考研] 0703化學調(diào)劑 +5 | pupcoco 2026-03-17 | 8/400 |
|
|
[考研] 材料考研調(diào)劑 +3 | xwt。 2026-03-19 | 3/150 |
|
|
[考研] 材料工程專碩調(diào)劑 +5 | 204818@lcx 2026-03-17 | 6/300 |
|
|
[考研] 344求調(diào)劑 +6 | knight344 2026-03-16 | 7/350 |
|
|
[考研] 311求調(diào)劑 +6 | 26研0 2026-03-15 | 6/300 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠意在機?/a> 2026-03-16 | 3/150 |
|
|
[考研] 293求調(diào)劑 +11 | zjl的號 2026-03-16 | 16/800 |
|
|
[考研] 085601求調(diào)劑 +4 | Du.11 2026-03-16 | 4/200 |
|
|
[考研] 302求調(diào)劑 +4 | 小賈同學123 2026-03-15 | 8/400 |
|
|
[考研] 26考研一志愿中國石油大學(華東)305分求調(diào)劑 +3 | 嘉年新程 2026-03-15 | 3/150 |
|
|
[考研] 288求調(diào)劑 +4 | 奇點0314 2026-03-14 | 4/200 |
|