Skip to content

Commit b8511d3

Browse files
author
DESKTOP-5DN6SL3\Ferdi
committed
Chess AI
1 parent ca50398 commit b8511d3

File tree

25 files changed

+1456
-0
lines changed

25 files changed

+1456
-0
lines changed

AImoves.py

Lines changed: 536 additions & 0 deletions
Large diffs are not rendered by default.

__init__.py

Whitespace-only changes.

backend.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import numpy as np
2+
3+
4+
5+
class gameBoard():
6+
def __init__(self):
7+
#pieces notation white: 1 black:2
8+
#pawn: 1 Rook: 2 Knight: 3 Bishop: 4 Queen: 5 King: 6
9+
#0 = empty
10+
self.board = np.array([[22, 23, 24, 25, 26, 24, 23, 22],
11+
[21, 21, 21, 21, 21, 21, 21, 21],
12+
[0, 0, 0, 0, 0, 0, 0, 0 ],
13+
[0, 0, 0, 0, 0, 0, 0, 0 ],
14+
[0, 0, 0, 0, 0, 0, 0, 0 ],
15+
[0, 0, 0, 0, 0, 0, 0, 0 ],
16+
[11, 11, 11, 11, 11, 11, 11, 11],
17+
[12, 13, 14, 15, 16, 14, 13, 12]])
18+
19+
self.board3 = np.array([[22, 0, 0, 0, 26, 0, 0, 22],
20+
[0, 0, 0, 0, 0, 0, 0, 0],
21+
[0, 0, 0, 0, 0, 0, 0, 0 ],
22+
[0, 0, 0, 0, 0, 0, 0, 0 ],
23+
[0, 0, 0, 0, 0, 0, 0, 0 ],
24+
[0, 0, 0, 0, 0, 0, 0, 0 ],
25+
[0, 0, 0, 0, 0, 0, 0, 0],
26+
[0, 0, 0, 0, 16, 0, 0, 0]])
27+
28+
self.WhitesTurn = True
29+
self.MoveLog = np.array([])
30+
#self.MoveLog = []
31+
self.whiteKingPosition = (7, 4)
32+
self.blackKingPosition = (0, 4)
33+
self.checkmate = False
34+
self.stalemate = False
35+
self.inCheck = False
36+
self.pins = []
37+
self.checks = [] #pieces which put the king in check
38+
self.currentCastleRights = CastleRights(True, True, True, True)
39+
#annotation bqs: Black queen side bks: black king side wqs: white queen side wks: white king side
40+
#stores the castle rights for undoing a move
41+
self.CastleRightsLog = [CastleRights(self.currentCastleRights.bqs, self.currentCastleRights.bks,
42+
self.currentCastleRights.wqs, self.currentCastleRights.wks)]
43+
44+
45+
46+
#class for storing the castle rights
47+
class CastleRights():
48+
def __init__(self, bqs, bks, wqs, wks):
49+
self.wks = wks
50+
self.bks = bks
51+
self.wqs = wqs
52+
self.bqs = bqs

images/2.png

116 KB
Loading

images/3.png

79.8 KB
Loading

images/4.png

25.7 KB
Loading

images/5.png

27.5 KB
Loading

images/bB.png

60.1 KB
Loading

images/bK.png

85 KB
Loading

images/bN.png

73.8 KB
Loading

0 commit comments

Comments
 (0)