-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathputPice.py
More file actions
76 lines (54 loc) · 1.31 KB
/
putPice.py
File metadata and controls
76 lines (54 loc) · 1.31 KB
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
65
66
67
68
69
70
71
72
73
74
75
mtz = [] # 0 = - , 1 = B, 2 = N
def putPice(fil, col, color):
global mtz
for i in range(-1, 2):
for j in range(-1, 2):
if((i,j) == (0,0)):
continue
if(mtz[fil+i][col+j] != color):
if(path(fil, col, j, i, color) == color):
mtz[fil][col] = color
def path(fil, col, vx, vy, color):
global mtz
fil += vy
col += vx
if(mtz[fil][col] == '-'):
return 2
if(mtz[fil][col] == color):
return color
if(path(fil, col, vx, vy, color) == color):
mtz[fil][col] = color
return color
return '-'
def printMatrix(mtz):
print(end=" ")
for i in range(8):
print(i, end=" ")
print("")
i =0
for row in mtz:
print(i, end=" ")
i += 1
for column in row:
print(column, end=" ")
print("")
for row in range(8):
mtz.append(['-','-','-','-','-','-','-','-'])
mtz[3][3] = 'B'
mtz[4][4] = 'B'
mtz[4][3] = 'N'
mtz[3][4] = 'N'
col = 0
col1 = 'B'
col2 = 'N'
color = 'N'
while (col != 9):
printMatrix(mtz)
print("turno de ", color)
fil = int(input("Digite el fila "))
col = int(input("Digite el columna "))
putPice(fil, col, color)
if(color == col1):
color = col2
else:
color = col1