Skip to content

Commit a6575af

Browse files
author
Jake Kim
committed
nit: update md, rename, remove unused files.
1 parent 009b5d8 commit a6575af

File tree

10 files changed

+33
-549
lines changed

10 files changed

+33
-549
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pygame/
2+
gol
3+
*.o

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ CFLAGS = -Ilife/src -Ilife/test/support #-DVERBOSE
33
TARGET = life
44

55
$(TARGET): objects
6-
$(CC) -o conway *.o
6+
$(CC) -o gol *.o
77

88
objects:
9-
$(CC) $(CFLAGS) -c GoL.c life/src/*.c life/test/support/*.c
9+
$(CC) $(CFLAGS) -c main.c life/src/*.c life/test/support/*.c
1010

1111
clean:
12-
rm *.o conway
12+
rm *.o gol
1313

default.sh

-2
This file was deleted.

life/life

-13.8 KB
Binary file not shown.

GoL.c main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ char *input_matrix(int width, int height)
5252
size_t size;
5353

5454
/* get matrix from stdin */
55-
printf(">> insert %d x %d matrix\n", width, height);
55+
printf(">> insert %d x %d matrix (o: alive, else: empty)\n", width, height);
5656

5757
while (strlen(matrix) < width * height)
5858
{

python/reame.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
## Python version via 'pygame'
3+
4+
- it's not complete. work in progess
5+
6+
- to execute in Linux,
7+
```
8+
$ python GoL.py
9+
```
10+
11+
if the 'No module name' error occurs, type this
12+
13+
```
14+
$ sudo apt-get install python-pygame
15+
```
16+
if it still doesn't works, try this
17+
```
18+
$ sh pygame.sh
19+
```
20+
this process will help you install pygame module.
21+
and after then, retry python GoL.py
22+
23+
- to execute in Window,
24+
- if you haven't installed python,download Python3 from [official homepage](https://www.python.org).
25+
- install 'pygame' library. Follow the guide of [this site](http://dogdriip.tistory.com/3).

readme.md

+2-111
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Game of Life (콘웨이의 생명 게임)
22

3-
> 주어진 n x m matrix 가 있습니다. 각 cell 에는 세포가 있습니다(총 n * m 개의 cell 이 있습니다).
3+
> 주어진 n x m matrix 가 있습니다. 각 cell 에는 세포가 있습니다(총 n * m 개의 cell 이 있습니다).
44
>
55
> 각 세포는 죽거나 살아있는 상태입니다. 한 주기마다 세포는 다음과 같은 규칙에 따라 상태가 바뀌게됩니다.
66
>
@@ -13,117 +13,8 @@
1313
> 이 프로그램은 초기 세포 matrix가 표준 입력으로 주어졌을 때 t 주기 후 세포 matrix 를 화면에 출력합니다.
1414
1515

16-
17-
---
18-
1. 언어는 **C**로 작성하였으며, **bash shell** 상에서 실행되도록하였습니다.
19-
20-
2. 입력 형태는 **표준입력**, 출력 형태는 **표준출력** 입니다.
21-
22-
3. 프로그램 실행 시 명령행 인자로 **출력할 matrix의 크기****주기 t**를 입력해야합니다.
23-
24-
4. 초기 세포 matrix 를 표준입력으로 전달하기 위해서는,
25-
26-
1. 실행 이후에 matrix를 manual하게 적어주거나
27-
2. **리디렉션**을 이용하여 초기 세포 matrix가 적힌 파일을 실행 시 전달하면 됩니다.
28-
29-
5. You can also run it by typing "**sh default.sh**" on BASH shell.
30-
31-
32-
자세한 실행 방법은 아래를 참고해 주세요.
33-
34-
*Ubuntu 16.04 LTS에서 vim으로 작성하였습니다. Linux 이외의 환경에서의 동작을 보장하지 않습니다.*
35-
36-
37-
3816
## How to Compile
39-
40-
- bash쉘에서 GoL.c파일을 gcc로 컴파일한다. (실행 파일명을 'GoL'로 지정하는 경우)
41-
42-
```
43-
$ gcc -o GoL GoL.c
44-
```
45-
46-
47-
48-
## How to Execute
49-
50-
- 아래와 같은 명령으로 실행한다. (포함된 map.txt파일을 전달하는 경우)
51-
52-
```
53-
$ ./GoL 25 38 100 < map.txt
54-
```
55-
56-
​ 위 명령어는 프로그램으로 25 x 38배열을 전달하고, 100주기 만큼 수행하겠다는 의미이다.
57-
그리고 리디렉션 문자 ''**<**''를 사용하여 파일의 내용을 표준입력으로 전달한 것이다.
58-
59-
​ 실행파일명 뒤의 세개의 인자는 필수적으로 전달되어야한다. (usage: ./실행파일명 <행> <열> <주기>)
60-
61-
62-
63-
- 다음과 같이 map 파일 없이도 실행할 수 있다.
64-
65-
```
66-
$ ./GoL 5 5 10
67-
```
68-
69-
​ 이 경우, 아래 처럼 실행 이후 직접 5 x 5 배열을 1과 0으로 작성해주어야한다.
70-
71-
![image1](./images/image1.png)
72-
73-
- 입력이 요구하는 크기를 초과하는 경우, 초과된 부분만 무시된다. 덜 입력된 경우, 나머지는 0으로 채워진다.
74-
- 경우에 따라 크기에 맞지않는 입력은 Segment Fault를 발생시킬 수 있으므로, 프로그램 실행시 정한 옵션에 맞는 배열 입력을 권장한다.
75-
76-
77-
78-
79-
- 실행 시 다음과 같은 결과를 확인할 수 있다.
80-
81-
![image2](./images/image2.png)
82-
83-
- GoL.c 파일에 define된 **DELAY** 값을 조절하거나, **usleep함수를** 주석처리하면 수행 속도를 조절할 수 있다.
84-
85-
```c
86-
#include<stdio.h>
87-
#include<stdlib.h>
88-
#include<unistd.h>
89-
90-
#define TRUE 1
91-
#define FALSE 0
92-
#define DELAY 50000 //here
93-
94-
/*~~~~~~~in main()~~~~~~~~*/
95-
96-
while( gen <= t ){
97-
print_status(cells);
98-
99-
update_generation(cells);
100-
101-
usleep(DELAY); // or here.
102-
}
103-
104-
```
105-
---
106-
## Python version via 'pygame'
107-
108-
- it's not complete. still ongoing
109-
110-
- to execute in Linux,
111-
```
112-
$ python GoL.py
113-
```
114-
115-
if the 'No module name' error occurs, type this
116-
117-
```
118-
$ sudo apt-get install python-pygame
119-
```
120-
if it still doesn't works, try this
12117
```
122-
$ sh pygame.sh
18+
$ make
12319
```
124-
this process will help you install pygame module.
125-
and after then, retry python GoL.py
12620

127-
- to execute in Window,
128-
- if you haven't installed python,download Python3 from [official homepage](https://www.python.org).
129-
- install 'pygame' library. Follow the guide of [this site](http://dogdriip.tistory.com/3).

source_old/GoL_adj.c

-132
This file was deleted.

0 commit comments

Comments
 (0)