-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.py
94 lines (68 loc) · 2.84 KB
/
move.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def up(piece, rangelen, currentiteration=0):
positions = []
for y in range(piece.posy-rangelen, piece.posy):
if y > 0:
positions.append((piece.posx, y))
return positions
def down(piece, rangelen, currentiteration=0):
positions = []
for y in range(piece.posy + 1, piece.posy + rangelen + 1):
if y < 8:
positions.append((piece.posx, y))
return positions
def rigth(piece, rangelen, currentiteration=0):
positions = []
for x in range(piece.posx + 1, piece.posx + rangelen + 1):
if x < 8:
positions.append((x, piece.posy))
return positions
def left(piece, rangelen, currentiteration=0):
positions = []
for x in range(piece.posx-rangelen, piece.posx):
if x > 0:
positions.append((x, piece.posy))
return positions
def bishopDownRigth(piece, rangelen, currentiteration=0):
positions = []
for x in range(piece.posy, piece.posy + rangelen + 1):
if piece.posx + x < 8 and piece.posy + x < 8:
positions.append((piece.posx + x, piece.posy + x))
return positions
def bishopDownLeft(piece, rangelen, currentiteration=0):
positions = []
for x in range(piece.posy, piece.posy + rangelen + 1):
if piece.posx - x >= 0 and piece.posy + x < 8:
positions.append((piece.posx - x, piece.posy + x))
return positions
def bishopUpRigth(piece, rangelen, currentiteration=0):
positions = []
for x in range(piece.posy - rangelen, piece.posy):
if piece.posx + (abs(x)) < 8 and piece.posy - abs(x) >= 0:
positions.append((piece.posx + (abs(x)), piece.posy - abs(x)))
return positions
def bishopUpLeft(piece, rangelen, currentiteration=0):
positions = []
for x in range(piece.posy - rangelen, piece.posy):
if piece.posx - (abs(x)) >= 0 and piece.posy - abs(x) >= 0:
positions.append((piece.posx - (abs(x)), piece.posy - abs(x)))
return positions
def horseDownRigth(piece, rangelen, currentiteration=0):
positions = []
if piece.posx + 1 < 8 and piece.posy + rangelen < 8:
positions.append((piece.posx + 1, piece.posy + rangelen))
return positions
def horseDownLeft(piece, rangelen, currentiteration=0):
positions = []
if piece.posx - 1 >= 0 and piece.posy + rangelen < 8:
positions.append((piece.posx - 1, piece.posy + rangelen))
return positions
def horseUpnLeft(piece, rangelen, currentiteration=0):
positions = []
if piece.posx - 1 >= 0 and piece.posy - rangelen >= 0:
positions.append((piece.posx - 1, piece.posy - rangelen))
return positions
def horseUpnRigth(piece, rangelen, currentiteration=0):
positions = []
if piece.posx + 1 < 8 and piece.posy - rangelen >= 0:
positions.append((piece.posx + 1, piece.posy - rangelen))
return positions