-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgame.py
51 lines (39 loc) · 1.05 KB
/
game.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
43
44
45
46
47
48
49
50
51
from squareoff import SquareOff
import player
import time
import chess
import chess.pgn
so = SquareOff()
## Some games - change comments to set mode
# Player (board input) versus stockfish
white = so.start_game(player=chess.WHITE)
black = player.player_stockfish(skill=0)
## Stockfish versus random
#so.start_game()
#white = player.player_stockfish(skill=0)
#black = player.player_random()
## Stockfish vs player (text input)
#so.start_game()
#white = player.player_stockfish(skill=0)
#black = player.player_cli()
## Player (voice) vs random
#so.start_game()
#white = player.player_voice()
#black = player.player_random()
try:
game = chess.pgn.Game()
node = game
board = chess.Board()
active, non_active = white, black
while not board.is_game_over(claim_draw = True):
move = active(board)
print(move.uci())
board.push(move)
node = node.add_variation(move)
so.make_move(move)
active, non_active = non_active, active
time.sleep(1)
so.end_game()
print(game)
finally:
so.disconnect()