0
나는 Conway의 Game of Life의 초기 설정을 어지럽 혔고 몇 가지 문제가 있습니다. 나는 살아있는 이웃 입자 (이 'positionSum'이라고 부름)의 수가 정확히 계산되지 않은 이유를 알아낼 수 없다. 다음 MATLAB 코드가 있습니다.Conway의 삶의 게임 부정확 한 이웃 수
간단한 코드로 작업하기 위해 3x3 그리드부터 시작합니다.
R = 3; C = 3; % row and column numbers
X = rand(R, C); % generates random grid
Y = X < 0.5; % creates array of logicals
A = Y;
imshow(Y, 'InitialMagnification', 'fit') % shows initial cell configuration
north = [R, 1:R-1]; % north neighbour
east = [2:C, 1]; % east neighbour
south = [2:R, 1]; % south neighbour
west = [C, 1:C-1]; % west neighbour
% gives the total number of live neighbours
positionSum = A(north, :) + A(south, :) + A(:, east) + A(:, west) ...
+ A(north, east) + A(north, west) + A(south, east) + A(south, west)
이 프로세스를 사용하면 잘못된 총계가 발생한다고 생각합니다. 나는 다음과 같은 수를 얻을 수 (here를 볼 때) 왼쪽 상단에 흰색과 3 × 3 바둑판를 들어
:4 5 4
5 4 5
4 5 4
[this] (https://stackoverflow.com/a/3514906/52738) 여기에 연결하는 것으로 생각했습니다. 재미있을 수도 있습니다. – gnovice