Skip to content

Commit d630d9d

Browse files
committed
Migrated engine from python to C++, Added pruning techniques, implemented some of UCI, Added connector to connect engine to pygame gui
1 parent ec6135a commit d630d9d

20 files changed

+4172
-177
lines changed

Mr Bob.exe

371 KB
Binary file not shown.
7.57 KB
Binary file not shown.

__pycache__/config.cpython-37.pyc

61 Bytes
Binary file not shown.
1.05 KB
Binary file not shown.
0 Bytes
Binary file not shown.

bitboards.py

Lines changed: 705 additions & 126 deletions
Large diffs are not rendered by default.

config.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@
22
board_height = 600
33
board_width = 600
44

5-
lightSquareColor = (162, 162, 162)
6-
darkSquareColor = (98, 98, 98)
5+
# lightSquareColor = (162, 162, 162)
6+
# darkSquareColor = (98, 98, 98)
77

8-
lightSquareColorSelected = (162, 162, 192)
9-
darkSquareColorSelected = (98, 98, 128)
8+
lightSquareColor = (172, 172, 162)
9+
darkSquareColor = (108, 108, 98)
10+
11+
# lightSquareColorSelected = (162, 162, 192)
12+
# darkSquareColorSelected = (98, 98, 128)
13+
lightSquareColorSelected = (192, 182, 162)
14+
darkSquareColorSelected = (128, 118, 98)
1015

1116

1217
color_side = 'black' # The side of the board in which you are viewing
1318
is_playing_white = False # Manual control over white pieces, False = Engine
14-
is_playing_black = False # Manual control over white pieces, False = Engine
19+
is_playing_black = True # Manual control over white pieces, False = Engine
1520

16-
# Engine depth
17-
white_Max_Depth = 1
18-
black_Max_Depth = 4
21+
# Engine depth (Obviously, More depth is better, but lower depth is faster)
22+
white_Max_Depth = 7
23+
black_Max_Depth = 7
24+
Late_Move_Reduction = 2
25+
Late_Move_Reduction_Depth = 1
1926

2027
killerSlots = 2
2128
searchmethod = 0 # 0 = alphabeta, 1 = minimax

connector.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import subprocess
2+
import time
3+
import config
4+
5+
def put(command):
6+
7+
engine.stdin.write(command + "\n")
8+
engine.stdin.flush()
9+
10+
while True:
11+
12+
s = "isready"
13+
engine.stdin.write(s + "\n")
14+
engine.stdin.flush()
15+
response = engine.stdout.readline().strip()
16+
if response.startswith("readyok"):
17+
# print ("Process response:", response)
18+
return
19+
else:
20+
21+
break
22+
23+
def search(depth):
24+
# using the 'isready' command (engine has to answer 'readyok')
25+
# to indicate current last line of stdout
26+
start = time.time() * 1000
27+
bestMove = ""
28+
29+
s = "go " + str(depth)
30+
engine.stdin.write(s + "\n") # Include '\n'
31+
engine.stdin.flush()
32+
while True:
33+
34+
end = time.time() * 1000
35+
36+
if (end - start) > 10000000:
37+
return bestMove
38+
39+
40+
41+
response = engine.stdout.readline().strip()
42+
if response.startswith("Best move found:"):
43+
bestMove = response[17:21]
44+
print(response)
45+
# print(bestMove)
46+
elif response == 'end':
47+
break
48+
elif response != '':
49+
i = 0
50+
print ("Process response:", response)
51+
else:
52+
break
53+
54+
return bestMove
55+
56+
57+
58+
engine = subprocess.Popen(
59+
'Mr Bob.exe',
60+
universal_newlines = True,
61+
stdin=subprocess.PIPE,
62+
stdout=subprocess.PIPE,
63+
)

engine/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
all: main.cpp bitboard.cpp dumb7flooding.cpp zobrist_hashing.cpp
3+
g++ -O3 -Wall -std=c++11 -o "../Mr Bob" main.cpp bitboard.cpp dumb7flooding.cpp zobrist_hashing.cpp

0 commit comments

Comments
 (0)