-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_game.py
More file actions
30 lines (27 loc) · 792 Bytes
/
run_game.py
File metadata and controls
30 lines (27 loc) · 792 Bytes
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
import socket, json
UNKNOWN = 0
EMPTY = 1
WALL = 2
GOAL = 3
PLAYER = 4
class Map:
def __init__(self, width, height, seed):
self.contents = []
for y in range(0, height):
row = []
for x in range(0, width):
row.append((EMPTY, False)) # Full of empty yet unseen squares.
self.contents.append(row)
def serialize(self):
grid = []
for y in range(0, len(self.contents)):
row = []
for x in range(0, len(self.contents[0])):
if self.contents[y][x][1]:
row.append(self.contents[y][x][0])
else:
row.append(UNKNOWN)
grid.append(row)
return json.dumps(grid)
m = Map(5, 5, 0)
print(m.serialize())