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

新蟲 (小有名氣)
| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿吉林大學(xué)材料學(xué)碩321求調(diào)劑 +9 | Ymlll 2026-03-18 | 12/600 |
|
|---|---|---|---|---|
|
[考研] 307求調(diào)劑 +9 | 冷笙123 2026-03-17 | 9/450 |
|
|
[考研] 0856調(diào)劑,是學(xué)校就去 +6 | sllhht 2026-03-19 | 7/350 |
|
|
[考博] 申博26年 +3 | 八6八68 2026-03-19 | 3/150 |
|
|
[考研] 288求調(diào)劑,一志愿華南理工大學(xué)071005 +5 | ioodiiij 2026-03-17 | 5/250 |
|
|
[考研] 復(fù)試調(diào)劑 +4 | z1z2z3879 2026-03-14 | 6/300 |
|
|
[考博] 東華理工大學(xué)化材專業(yè)26屆碩士博士申請(qǐng) +8 | zlingli 2026-03-13 | 8/400 |
|
|
[考研] 【考研調(diào)劑】化學(xué)專業(yè) 281分,一志愿四川大學(xué),誠(chéng)心求調(diào)劑 +5 | 吃吃吃才有意義 2026-03-19 | 5/250 |
|
|
[考研] 材料080500調(diào)劑求收留 +4 | 一顆meteor 2026-03-13 | 4/200 |
|
|
[考研] 332求調(diào)劑 +3 | ydfyh 2026-03-17 | 3/150 |
|
|
[考研] 330求調(diào)劑 +3 | 小材化本科 2026-03-18 | 3/150 |
|
|
[考研] 08工科 320總分 求調(diào)劑 +5 | 梨花珞晚風(fēng) 2026-03-17 | 5/250 |
|
|
[考研] 收復(fù)試調(diào)劑生 +4 | 雨后秋荷 2026-03-18 | 4/200 |
|
|
[考研] 生物學(xué)071000 329分求調(diào)劑 +3 | 我愛生物生物愛?/a> 2026-03-17 | 3/150 |
|
|
[考研] 301求調(diào)劑 +9 | yy要上岸呀 2026-03-17 | 9/450 |
|
|
[考研] 求老師收留調(diào)劑 +4 | jiang姜66 2026-03-14 | 5/250 |
|
|
[考研] 0856專碩279求調(diào)劑 +5 | 加油加油!? 2026-03-15 | 5/250 |
|
|
[考研] 294求調(diào)劑 +3 | Zys010410@ 2026-03-13 | 4/200 |
|
|
[考研] 266求調(diào)劑 +4 | 學(xué)員97LZgn 2026-03-13 | 4/200 |
|
|
[考研] 304求調(diào)劑 +7 | 7712b 2026-03-13 | 7/350 |
|