-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverifmove.py
76 lines (66 loc) · 2.34 KB
/
verifmove.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
65
66
67
68
69
70
71
72
73
74
75
76
from math import sqrt
def FouMoveVerif(zx, zy, x, y, nx, ny, plate, piece, pieceAdv):
if zx < 0:
tx = -1
elif zx > 0:
tx = 1
if zy < 0:
ty = -1
elif zy > 0:
ty = 1
F = [(x + zx, y + zy, zy**2 == zx**2, plate[-y - ty][x - tx] == "#", not plate[-y - ty][x - tx] in pieceAdv or x + tx == nx and y + ty == ny)]
for i in range(1, max(int(sqrt(zx**2)), int(sqrt(zy**2)))):
if F[0] == (nx, ny, True, True, True):
x += tx
y += ty
zy = ny - y
zx = nx - x
else:
return False
def TourMoveVerif(zx, zy, x, y, nx, ny, plate, piece, pieceAdv, outEquation):
if zx < 0:
tx = -1
elif zx > 0:
tx = 1
elif zx == 0:
tx = 0
if zy < 0:
ty = -1
elif zy == 0:
ty = 0
elif zy > 0:
ty = 1
T = [(y + zy, x, plate[-y - ty][x + tx] == "#", not plate[-y - ty][x - tx] in pieceAdv or x + tx == nx and y + ty == ny),
(y, x + zx, plate[-y - ty][x + tx] == "#", not plate[-y - ty][x - tx] in pieceAdv or x + tx == nx and y + ty == ny)]
for i in range(1, max(int(sqrt(zx**2)), int(sqrt(zy**2)))):
if T[outEquation] == (nx, ny, True, True):
x += tx
y += ty
zy = ny - y
zx = nx - x
else:
return False
def DameMoveVerif(zx, zy, x, y, nx, ny, plate, piece, pieceAdv, outEquation):
if zx < 0:
tx = -1
elif zx > 0:
tx = 1
elif zx == 0:
tx = 0
if zy < 0:
ty = -1
elif zy == 0:
ty = 0
elif zy > 0:
ty = 1
D = [(x + zx, y + zy, zy**2 == zx**2, plate[-y - ty][x + tx] == "#", not plate[-y - ty][x - tx] in pieceAdv or x + tx == nx and y + ty == ny),
(y + zy, x, True, plate[-y - ty][x + tx] == "#", not plate[-y - ty][x - tx] in pieceAdv or x + tx == nx and y + ty == ny),
(y, x + zx, True, plate[-y - ty][x + tx] == "#", not plate[-y - ty][x - tx] in pieceAdv or x + tx == nx and y + ty == ny)]
for i in range(1, max(int(sqrt(zx**2)), int(sqrt(zy**2)))):
if D[outEquation] == (nx, ny, True, True, True):
x += tx
y += ty
zy = ny - y
zx = nx - x
else:
return False