Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5d5de1

Browse files
committed
Make games.py PEP8 compliant
1 parent b8fac0a commit c5d5de1

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

games.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
"""Games, or Adversarial Search. (Chapter 5)
2-
"""
1+
"""Games, or Adversarial Search (Chapter 5)"""
32

43
import collections
5-
import math
64
import random
75

86
from utils import * # noqa
97

108
infinity = float('inf')
9+
GameState = collections.namedtuple('GameState', 'to_move, utility, board, moves')
1110

1211
# ______________________________________________________________________________
1312
# Minimax Search
@@ -156,7 +155,7 @@ def alphabeta_player(game, state):
156155

157156
def play_game(game, *players):
158157
"""Play an n-person, move-alternating game."""
159-
158+
160159
state = game.initial
161160
while True:
162161
for player in players:
@@ -170,7 +169,6 @@ def play_game(game, *players):
170169

171170

172171
class Game:
173-
174172
"""A game is similar to a problem, but it has a utility for each
175173
state and a terminal test instead of a path cost and a goal
176174
test. To create a game, subclass this class and implement actions,
@@ -235,10 +233,8 @@ def terminal_test(self, state):
235233
def to_move(self, state):
236234
return ('MIN' if state in 'BCD' else 'MAX')
237235

238-
GameState = collections.namedtuple('GameState', 'to_move, utility, board, moves')
239236

240237
class TicTacToe(Game):
241-
242238
"""Play TicTacToe on an h x v board, with Max (first player) playing 'X'.
243239
A state has the player to move, a cached utility, a list of moves in
244240
the form of a list of (x, y) positions, and a board, in the form of

0 commit comments

Comments
 (0)