forked from urav06/chess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (44 loc) · 1.49 KB
/
Copy pathmain.py
File metadata and controls
53 lines (44 loc) · 1.49 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
"""
Entrypoint for manual tests
"""
import time
from bots import MinMaxBot
from engine import Color, Game, from_fen
def main() -> None:
players = (
MinMaxBot(max_depth=3, color=Color.BLACK),
MinMaxBot(max_depth=6, color=Color.WHITE),
# RandomBot(color=Color.BLACK)
# MinMaxBot(max_depth=4, color=Color.WHITE),
)
game = Game()
from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR", game)
while next(game.legal_moves(), False):
active_player = (
players[0] if game.active_color == players[0].color else players[1]
)
st = time.time()
selected_move = active_player.select_move(game)
et = time.time()
active_player.move_count += 1
active_player.clock += et - st
game.execute_move(selected_move)
print(f"{active_player.name} played {selected_move}")
print(game.board)
inactive_player = (
players[1] if game.active_color == players[0].color else players[0]
)
if game.is_in_checkmate(game.active_color):
print(
f"{inactive_player.name} wins by checkmate in {inactive_player.move_count} moves."
)
elif game.is_in_stalemate(game.active_color):
print(
f"{inactive_player.name} draws by stalemate in {inactive_player.move_count} moves."
)
else:
print("Something fucky happened.")
players[0].display_time_taken()
players[1].display_time_taken()
if __name__ == "__main__":
main()