Show HN: Life4.py – 명령 터미널에서 John Conway의 Game of Life를 시각화합니다.
hackernews
|
|
📦 오픈소스
#ai 딜
#game of life
#python
#시각화
#오픈소스
#터미널
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
파이썬 프로그램인 life4.py는 존 콘웨이의 '라이프 게임'을 명령 터미널에서 시각화하며, 사용자가 그리드 크기와 생성 및 생존 규칙을 설정하여 세포의 진화 과정을 제어할 수 있습니다. 이 프로그램은 별도의 카메라 컨트롤러를 통해 화면의 시점을 상하좌우로 이동하거나 줌인/줌아웃 기능을 지원하여 복잡한 세포 패턴을 관찰할 수 있도록 돕습니다. 또한 'life_startcondition.txt' 파일을 통해 시드 패턴을 변경하여 게임의 전개를 다양하게 조작할 수 있습니다.
본문
life4.py - Program that visualizes John Conway's "Game of Life" in a command terminal. life4.py is a Python program that visualizes John Conway's "Game of Life" in a command terminal, with additional controls to move the viewpoint and to zoom in on or out of the animation. See for background and details: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life Summary: The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which (at any given time) is in one of two possible states, "live" (alternatively "on") or "dead" (alternatively "off"). Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. The way the pattern of cells develops is driven by two rules, the so-called "Birth- and Survival-rules". The result looks like a busy scene of moving "micro-organism"-like creatures, crawling, expanding, dying out and re-emerging. Place the file 'life_startcondition.txt' in the same directory as the program life4.py. This is the initial pattern of ones and zeroes constituting the 'seed' of the system, determining how the game will start and develop. In order to start the "Game of Life" animation, type the following command in a command terminal, followed by 4 integer arguments: ./life4.py 82 48 3 23 The first two arguments are the horizontal and vertical grid sizes of the image "canvas" in the terminal. The values 82 and 48 are an example of an adequate grid size, but can of course be replaced by other values, dependent upon terminal-type and terminal/character size. The third and fourth argument represent the settings of the "Birth rule" and "Survival rule" respectively. Respective values 3 and 23 render a good probability that the life action on the canvas will persist and develop for quite some time before dying out (that is: dependant upon which start condition has been chosen). Immediately after the command has been given, a small second terminal window pops up that acts as a "camera control". This enables controlling the view point ("camera") on the life animation in the first terminal window, to move upward, downward, leftward or rightward, by pressing the corresponding arrow keys. Additionally, zooming in and out as well as resetting the position is possible as follows: zoom in zoom out reset, center In order to stop the program, press: Ctrl-C or The zip file 'life_startconditions.zip' contains alternative versions to 'life_startcondition.txt', by which the game can be made to develop differently. Written by Rob Toscani ([email protected]).
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유