Growing a Maze Question

조회 수: 7 (최근 30일)
Peter Jan Snijders
Peter Jan Snijders 2018년 9월 14일
댓글: Walter Roberson 2018년 9월 15일
I was wondering if someone could help me on this one:
A cellular automaton consists of a grid of cells where each cell is either on or off. In a single time step a new generation is computed based on the previous generation and a fixed rule. The most famous example of a cellular automaton is Conway’s Game of Life. In this exercise we will implement a variation which results in maze-like structures. Create a function with the following signature The input A is a matrix with the initial state of each cell, where a value of 0 indicates a cell is off and a 1 indicates a cell is on. The input steps indicates how many new generations need to be computed. A new generation can be computed with the following rules:
Survival: If a cell is on and it has at least one and at most four neighbors which are on, it will be on in the new generation.
Birth: If a cell is off and it has precisely three neighbors which are on, it will be on in the new generation.
Death: All other cells will be off in the new generation.
The neighbors of a cell are all cells which are directly adjacent to it, including the diagonal cells. Most cells have eight neighbors, while those at the sides of the grid have five neighbors and the cells in the corners only three neighbors.
Where do I start at all?
  댓글 수: 4
Stephen23
Stephen23 2018년 9월 14일
편집: Stephen23 2018년 9월 14일
"Where do I start at all?"
By reading about cellular automata. Read the Wikipedia article for Conway's Game of Life. Read about possible ways to write the code. Read blogs on the topic. Look at some examples in MATLAB. etc. etc.
Conway’s Game of Life has been coded up countless times in countless languages, since it was released in 1970. A search for "MATLAB Conway game of life" using [a major internet search engine] returned over 140,000 results. A search on MATLAB File Exchange for "Conway" returned 13 results (including some very nice looking ones).
The internet is full of information... why not start making use it?
Walter Roberson
Walter Roberson 2018년 9월 15일
Please do not close questions that have an answer

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2018년 9월 14일
Hint:
function ComputeLastGeneration(A, steps)
Inside that function you'll use a for loop "steps" times to compute the successive generations. Strangely the instructions don't call for an output, but it might not be a bad idea to return the final generation.

카테고리

Help CenterFile Exchange에서 Conway's Game of Life에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by