-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
116 lines (108 loc) · 4.08 KB
/
Copy pathmain.py
File metadata and controls
116 lines (108 loc) · 4.08 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Pychess main.py
from board import *
from engine import *
b = Board()
e = Engine()
human_white = False
human_turn = False
self_play = None
while self_play == None:
self_play = str(input("White : b, Black : n, chess960 : 960, self_play : self. Your choice ? "))
if self_play == "b":
human_white = True
human_turn = True
#HUMAIN VS BOT
while e.endgame == False:
if human_turn:
move = ""
# Tour du joueur humain
while move == "":
move = input("Entrez votre coup (ex: e2e4) : ")
move = e.usermove(b, move)
else:
# Tour du programme
e.search(b, human_white, None)
e.print_result(b)
# Afficher l'historique du jeu après chaque coup
b.showHistory(True)
human_turn = not human_turn
elif self_play == "n":
human_white = False
human_turn = False
#HUMAIN VS BOT
while e.endgame == False:
if human_turn:
move = ""
# Tour du joueur humain
while move == "":
move = input("Entrez votre coup (ex: e2e4) : ")
move = e.usermove(b, move)
else:
# Tour du programme
e.search(b, human_white, None)
e.print_result(b)
# Afficher l'historique du jeu après chaque coup
b.showHistory(True)
human_turn = not human_turn
elif self_play == "self":
#SELF PLAY
e.search(b, False, None)
while e.endgame == False:
e.search(b, True, None)
e.print_result(b)
# Afficher l'historique du jeu après chaque coup
b.showHistory(True)
human_turn = not human_turn
elif self_play == "960":
print("Keep only this part of a FEN : rnqbbnkr/pppppppp/8/8/8/8/PPPPPPPP/RNQBBNKR w KQkq")
fen = str(input("FEN of starting position : "))
b.setboard(fen)
print("Done !")
print()
#Asking again for color
self_play = str(input("White : b, Black : n, chess960 : 960, self_play : self. Your choice ? "))
if self_play == "b":
human_white = True
human_turn = True
#HUMAIN VS BOT
while e.endgame == False:
if human_turn:
move = ""
# Tour du joueur humain
while move == "":
move = input("Entrez votre coup (ex: e2e4) : ")
move = e.usermove(b, move)
else:
# Tour du programme
e.search(b, human_white, 960)
e.print_result(b)
# Afficher l'historique du jeu après chaque coup
b.showHistory(True)
human_turn = not human_turn
elif self_play == "n":
human_white = False
human_turn = False
#HUMAIN VS BOT
while e.endgame == False:
if human_turn:
move = ""
# Tour du joueur humain
while move == "":
move = input("Entrez votre coup (ex: e2e4) : ")
move = e.usermove(b, move)
else:
# Tour du programme
e.search(b, human_white, 960)
e.print_result(b)
# Afficher l'historique du jeu après chaque coup
b.showHistory(True)
human_turn = not human_turn
elif self_play == "self":
#SELF PLAY
e.search(b, False, 960)
while e.endgame == False:
e.search(b, True, 960)
e.print_result(b)
# Afficher l'historique du jeu après chaque coup
b.showHistory(True)
human_turn = not human_turn