-
Notifications
You must be signed in to change notification settings - Fork 1
/
Game.py
58 lines (50 loc) · 1.02 KB
/
Game.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
import pickle
import os
class Game:
def __init__(self):
self.board = 'size of board = 0'
print self.board
self.it = 0
self.load()
def load(self):
if os.path.exists('board.txt'):
f = open('board.txt','r')
self.matrix = pickle.load(f)
f.close()
print 'loaded board.txt'
else:
self.matrix = [] #matrix 10 x 10
for y in range(10):
self.matrix.append([])
for x in range(10):
self.matrix[y].append(1)
def save(self):
if not os.path.exists('board.txt'):
f = open('board.txt','w')
pickle.dump(self.matrix,f)
f.close()
print 'saved board.txt'
else:
print 'not saved board.txt'
def update(self):
out = ""
# for a in range(0,10):
# if a == self.it:
# out +='0'
# else:
# out +='-'
# print out
# self.it +=1
for y in range(10):
for x in range(10):
if y == 5 and x == 5:
self.matrix[y][x] = 1
out+=chr(self.matrix[y][x])
print out
out = ""
self.it+=1
def over(self):
if self.it < 1:
return bool(0)
else:
return bool(1)