-
Notifications
You must be signed in to change notification settings - Fork 0
/
a-simple_blinker.py
49 lines (37 loc) · 897 Bytes
/
a-simple_blinker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""
Game of life simple script for checking init states and checking if the evolution is
implemented correctly.
Created on Tue Jan 15 12:37:52 2019
@author: shakes
"""
import conway
N = 64
#create the game of life object
life = conway.GameOfLife(N)
life.insertBlinker((0,0))
cells = life.getStates() #initial state
#evolve once
life.evolve()
cellsUpdated1 = life.getStates()
#evolve twice
life.evolve()
cellsUpdated2 = life.getStates()
#-------------------------------
#plot cells
import matplotlib.pyplot as plt
import numpy as np
plt.figure(0)
plt.gray()
plt.imshow(cells)
ax = plt.gca()
# Minor ticks
ax.set_xticks(np.arange(-.5, N, 1), minor=True);
ax.set_yticks(np.arange(-.5, N, 1), minor=True);
#grid
ax.grid(which='minor', color='w', linestyle='-', linewidth=1)
plt.figure(1)
plt.imshow(cellsUpdated1)
plt.figure(2)
plt.imshow(cellsUpdated2)
plt.show()