-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboard.py
60 lines (46 loc) · 1.1 KB
/
board.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
import random
import os
def create_matrix(level):
f = open("desafios.txt")
content = f.readlines()
f.close()
valid_tabs = []
for line in content:
count = 0
for c in line:
if c == '.':
count += 1
if count >= level[0] and count <= level[1]:
valid_tabs.append(line)
print(valid_tabs)
line = valid_tabs[random.randint(0, len(valid_tabs))]
count = 0
for i in range(16):
if line[i] == '.':
count += 1
m = []
i = 0
j = 4
for k in range(4):
l = line[i:j]
m.append(list(l))
i = j
j = j + 4
return m, count
def show_tab(m):
for i in range (4):
if i == 2:
print("- - + - -")
for j in range(4):
if j == 2:
print("|", end=" ")
print(m[i][j], end=" ")
print()
print("\n")
def update_tab(tab,play):
tab[play.x][play.y] = play.n
def clear_console():
command = 'clear'
if os.name in ('nt', 'dos'):
command = 'cls'
os.system(command)