Game of Life 프로그램을 만들려고합니다. 루프 관련 문제점 및 게임 보드의 정확한 업데이트.Java Game of Life 구현 : 보드 업데이트 및 무한 루프 관련 문제점.
미안하지만 나는 초보자이므로이 점에 능숙하지 않습니다. 어떤 도움을 주셔서 감사합니다.
import java.util.Random;
public class Life {
public static void main(String[] args) {
int gridSize = 200;
int cellSize = 3;
Grid grid = new Grid(gridSize, cellSize, "The Game of Life");
grid.setDelay(10);
int aliveCells;
int aliveColor = 1;
int deadColor = 0;
while (true) {
for (column = 0;; column++) {
for (row = 0;; row++) {
grid.getPos(row, column);
aliveCells = grid.matchingNeighbors(row, column, aliveColor);
if (aliveCells == 2 || aliveCells == 3) {
grid.setPos(row, column, aliveColor);
} else {
grid.setPos(row, column, deadColor);
}
grid.update();
}
}
}
그리고 무엇을 달성하려고합니까? 즉 무한 루프가 필요한 이유는 무엇입니까? – ochi
유용한 답변을 원한다면 좀 더 많은 정보를 제공해야 할 것입니다. 'while (true) {...} '를 사용하면 무한 루프가 생기고, 그 밖에 무엇을 원하는지 확실치 않습니다. –
이미 무한 루프가 있습니다. –