-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
64 lines (45 loc) · 1.36 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import matplotlib.pyplot as plt
import random
from Cell import Cell
from Board import Board
import COLORS
from matplotlib import cm
grid = []
im = plt.imread("5.png")
# plt.show(plt.imshow(im))
# print(im.shape)
for row in im:
newRow = []
for cellCol in row: # cellCol = cell Colour, not column
cellCol *= 255
if len(list(cellCol)) == 3:
cellCol = list(cellCol)
cellCol.append(1)
cellCol = tuple(cellCol)
foundCell = False
for category in COLORS.CategoryToData:
val = COLORS.CategoryToData[category]
if cellCol == val["color"]:
initialTemp = val["initialTemp"]
newRow.append(Cell(initialTemp, category))
foundCell = True
if not foundCell:
raise ValueError("Invalid pixel colour: " + str(cellCol))
# print(newRow)
grid.append(newRow)
board = Board(grid)
try:
plt.imshow(board.draw(), cmap=cm.get_cmap('bwr', 256))
plt.clim(0, COLORS.MAX_TEMP)
plt.colorbar()
while True:
plt.imshow(board.draw(), cmap=cm.get_cmap('bwr', 256))
plt.ion()
plt.show()
# Adding a comment, this pauses the simulation so we can see it!
plt.pause(0.001)
for i in range(10):
board.update()
# print(str(board))
except KeyboardInterrupt:
pass