-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckmate.pseudo
More file actions
103 lines (70 loc) · 2.78 KB
/
checkmate.pseudo
File metadata and controls
103 lines (70 loc) · 2.78 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// First I will show the code needed to check if a move jeopardises the king
self.posx=
self.posy=
movedtox=
movedtoy=
self.boardtemp= [['brook1', 'bknight1', 'bbishop1', 'bqueen', 'bking', 'bbishop2', 'bknight2', 'brook2'],
['bpawn1', 'bpawn2', 'bpawn3', 'bpawn4', 'bpawn5', 'bpawn6', 'bpawn7', 'bpawn8'],
['', '', '', '', '', '', '', ''],['', '', '', '', '', '', '', ''],
['', '', '', '', '', '', '', ''],['', '', '', '', '', '', '', ''],
['wpawn1', 'wpawn2', 'wpawn3', 'wpawn4', 'wpawn5', 'wpawn6', 'wpawn7', 'wpawn8'],
['wrook1', 'wknight1', 'wbishop1', 'wking', 'wqueen', 'wbishop2', 'wknight2', 'wrook2']]
set record=self.board[self.posy][self.posx]
set self.board[self.posy][self.posx]=''
set self.board[movedtoy][movedtoy]=record
if (minicheck(self.boardtemp,colour) =False) do
availableSquares.append(square)
availableSquarex.append(self.posx)
end
ememysquarealg
empty squarealg
}
function diagonalsclear(board,colour) do
for y in range(-1,2)do
if (y=0) do
pass
end else do
for x in range(-1,2) do
if (x=0) do
pass
end else do
if emptysquarealg(movedtoy+y][movedtox+x])=Truedo
if
end
end
end
end
end
end
function minicheck(board,colour) {
//diagonal
set diagonal=diagonalsclear(board,colour)
if (diagonal=True) do
return True
end
//adjacent
set adjacent=adjacentclear(board,colour)
if (adjacent=True) do
return True
end
//knight
set knight=knightclear(board,colour)
if (knight=True) do
return True
end
}
//then the check algorithm
//then the checkmate algorithm
// for en passant check if current piece is pawn, if last moved piece was pawn and that pawn is adjacent now.
//On the other code I should've had the the endangers king called based on turn as a method of king only an used self.
//add a way to store piece just clicked on so if clicked again it's no worries
//some methods could've been subroutines
//make attribute variables private, so variable usage can be accurately traced
//I've added game over and castling(fingers crossed) and restart button. make sure to remove excess hashtags or slashes and print
//statements
//the castling gets a bit messy in terms of eval and accessing attributes without using a function.
//around line 697 and of course... 854!
//there were a couple of functions that had to be copied, so further forward thinking could've been used to avoid
//the problems. I could also have made code simpler and used less if statements.
//line 1312 look at comment
//stalemate and en passant