Make pep8 happier
This commit is contained in:
parent
c9774498e0
commit
fe185631b3
2 changed files with 12 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class CustomFormatter(logging.Formatter):
|
class CustomFormatter(logging.Formatter):
|
||||||
|
|
||||||
grey = "\x1b[0;35m"
|
grey = "\x1b[0;35m"
|
||||||
|
|
23
src/game.py
23
src/game.py
|
@ -26,7 +26,7 @@ def parse_aguments():
|
||||||
default='random'
|
default='random'
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument('-be',
|
parser.add_argument('-be',
|
||||||
'--black-engine',
|
'--black-engine',
|
||||||
choices=engines_choices,
|
choices=engines_choices,
|
||||||
help='black player engine (random)',
|
help='black player engine (random)',
|
||||||
|
@ -40,7 +40,7 @@ def parse_aguments():
|
||||||
default=3,
|
default=3,
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument('-wd',
|
parser.add_argument('-wd',
|
||||||
'--white-depth-exploration',
|
'--white-depth-exploration',
|
||||||
help='White player exploration depth (minmax or alphabeta engine)',
|
help='White player exploration depth (minmax or alphabeta engine)',
|
||||||
type=int,
|
type=int,
|
||||||
|
@ -50,7 +50,7 @@ def parse_aguments():
|
||||||
parser.add_argument('-bh',
|
parser.add_argument('-bh',
|
||||||
'--black-heuristic-engine',
|
'--black-heuristic-engine',
|
||||||
help='Black player heutistic engine',
|
help='Black player heutistic engine',
|
||||||
choices= heuristic_choices,
|
choices=heuristic_choices,
|
||||||
default='score',
|
default='score',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ def parse_aguments():
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument('-bt',
|
parser.add_argument('-bt',
|
||||||
'--black-player-deepening-time',
|
'--black-player-deepening-time',
|
||||||
help='Time interval in seconds for Iterative Deepening - black player',
|
help='Time interval in seconds for Iterative Deepening - black player',
|
||||||
type=int,
|
type=int,
|
||||||
|
@ -93,7 +93,7 @@ def parse_aguments():
|
||||||
help='Weight table for weight based heuristic engines',
|
help='Weight table for weight based heuristic engines',
|
||||||
type=int,
|
type=int,
|
||||||
nargs=4,
|
nargs=4,
|
||||||
default=[-5, 2, 10,25]
|
default=[-5, 2, 10, 25]
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument('-r',
|
parser.add_argument('-r',
|
||||||
|
@ -188,7 +188,7 @@ if __name__ == '__main__':
|
||||||
heuristic_engine[args.black_heuristic_engine](
|
heuristic_engine[args.black_heuristic_engine](
|
||||||
logger, {
|
logger, {
|
||||||
'weight': args.weight,
|
'weight': args.weight,
|
||||||
'size': game.get_board_size()
|
'size': game.get_board_size()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
|
@ -202,7 +202,7 @@ if __name__ == '__main__':
|
||||||
white_time = 0
|
white_time = 0
|
||||||
black_time = 0
|
black_time = 0
|
||||||
while recursions > 0:
|
while recursions > 0:
|
||||||
while ( not game.is_game_over()):
|
while (not game.is_game_over()):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
if game._nextPlayer == 1:
|
if game._nextPlayer == 1:
|
||||||
move = bplayer.get_move(game)
|
move = bplayer.get_move(game)
|
||||||
|
@ -213,7 +213,7 @@ if __name__ == '__main__':
|
||||||
# Display informations only id we are not in recurse mode
|
# Display informations only id we are not in recurse mode
|
||||||
if args.recursions == 1:
|
if args.recursions == 1:
|
||||||
print("Player {} move: {},{}".format(
|
print("Player {} move: {},{}".format(
|
||||||
"Black (X)" if move[0] == 2 else "White (O)",
|
"Black (X)" if move[0] == 2 else "White (O)",
|
||||||
move[1],
|
move[1],
|
||||||
move[2]
|
move[2]
|
||||||
))
|
))
|
||||||
|
@ -223,7 +223,7 @@ if __name__ == '__main__':
|
||||||
score = game._nbBLACK - game._nbWHITE
|
score = game._nbBLACK - game._nbWHITE
|
||||||
if score == 0:
|
if score == 0:
|
||||||
winner = "No winner"
|
winner = "No winner"
|
||||||
elif score > 0:
|
elif score > 0:
|
||||||
winner = "Black"
|
winner = "Black"
|
||||||
else:
|
else:
|
||||||
winner = "White"
|
winner = "White"
|
||||||
|
@ -231,7 +231,7 @@ if __name__ == '__main__':
|
||||||
print("\nGAME OVER\n---\nWINNER: {} | black:{} in {:>5}s | white:{} in {:>5}s".format(
|
print("\nGAME OVER\n---\nWINNER: {} | black:{} in {:>5}s | white:{} in {:>5}s".format(
|
||||||
winner,
|
winner,
|
||||||
game._nbBLACK,
|
game._nbBLACK,
|
||||||
format(black_time,'4.3f'),
|
format(black_time, '4.3f'),
|
||||||
game._nbWHITE,
|
game._nbWHITE,
|
||||||
format(white_time, '4.3f')
|
format(white_time, '4.3f')
|
||||||
))
|
))
|
||||||
|
@ -266,7 +266,7 @@ if __name__ == '__main__':
|
||||||
print("White: {:>2} | ratio: {:>6} | time: {:>8}s | engine: {}".format(
|
print("White: {:>2} | ratio: {:>6} | time: {:>8}s | engine: {}".format(
|
||||||
white,
|
white,
|
||||||
white * 100 / numbers,
|
white * 100 / numbers,
|
||||||
format(total_time_white,'4.3f'),
|
format(total_time_white, '4.3f'),
|
||||||
wplayer._get_class_name(),
|
wplayer._get_class_name(),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -277,4 +277,3 @@ if __name__ == '__main__':
|
||||||
print("---\nBlack player options: {}\nWhite player options: {}".format(
|
print("---\nBlack player options: {}\nWhite player options: {}".format(
|
||||||
bplayer.options, wplayer.options
|
bplayer.options, wplayer.options
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue