-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplay_against_player.py
42 lines (29 loc) · 1001 Bytes
/
play_against_player.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
import random
import chess
import chess.pgn
import chess.polyglot
from headers import *
from parameters import *
from piece_square_tables import *
from piece_values import *
from main import make_move
moves = []
board = chess.Board()
number_of_moves = 1
while not board.is_game_over(claim_draw=draw_agreement_allowed):
if board.turn:
board.push(make_move(40))
print(f"The move is: {moves[-1]}\n" f"The number of moves: {number_of_moves}\n"
f"\n" f"{board}\n")
else:
user_move = input("Enter your move:")
board.push_san(user_move)
print(f"The move is: {moves[-1]}\n" f"The number of moves: {number_of_moves}\n"
f"\n" f"{board}\n")
number_of_moves = number_of_moves + 1
game = chess.pgn.Game()
for key, value in headers.items():
game.headers[key] = value
game.headers["Result"] = str(board.result(claim_draw=draw_agreement_allowed))
game.add_line(moves)
print(game)