forked from pearstopher/chess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_gui.py
More file actions
40 lines (32 loc) · 995 Bytes
/
example_gui.py
File metadata and controls
40 lines (32 loc) · 995 Bytes
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
# Chess Program
#
# This chess program currently responds to the user by making random moves.
#
# Basic requirements:
# > pip install python-chess
# > pip install pygame
#
import chess
from ChessHelpers import ChessEngineHelper
CHECKMATE = 1000
STALEMATE = 0
GUI = True # choose between graphical or terminal interface
if GUI:
from interface.gui import play_chess
else:
from interface.tui import play_chess
def main():
# create a chess board object
board = chess.Board()
# run the game loop to display the board UI
# parameters:
# a chess board
# a move generation function for white (optional, defaults to player)
# a move generation function for black (optional, defaults to player)
#
# return value:
# the outcome of the game (ignored)
move_generator = ChessEngineHelper.MoveGenerator()
play_chess(board, black=move_generator.mini_max_move)
if __name__ == '__main__':
main()