mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-26 04:41:52 -08:00
'Refactored by Sourcery'
This commit is contained in:
@@ -83,11 +83,10 @@ LOSING_BOOK_SIZE = 50
|
||||
|
||||
def draw_pit(line: str, board, pit_index) -> str:
|
||||
val = board[pit_index]
|
||||
line = line + " "
|
||||
line += " "
|
||||
if val < 10:
|
||||
line = line + " "
|
||||
line = line + str(val) + " "
|
||||
return line
|
||||
line += " "
|
||||
return line + str(val) + " "
|
||||
|
||||
|
||||
def draw_board(board) -> None:
|
||||
@@ -148,7 +147,7 @@ def play_game(board: List[int]) -> None:
|
||||
print(msg)
|
||||
break
|
||||
if landing_spot == home:
|
||||
landing_spot, is_still_going, home, msg = computer_move(msg + " , ", board)
|
||||
landing_spot, is_still_going, home, msg = computer_move(f"{msg} , ", board)
|
||||
if not is_still_going:
|
||||
print(msg)
|
||||
break
|
||||
@@ -248,7 +247,7 @@ def computer_move(msg: str, board) -> Tuple[int, bool, int, str]:
|
||||
|
||||
move_str = chr(42 + selected_move)
|
||||
if msg:
|
||||
msg += ", " + move_str
|
||||
msg += f", {move_str}"
|
||||
else:
|
||||
msg = move_str
|
||||
|
||||
@@ -323,10 +322,7 @@ def execute_move(move, home: int, board) -> Tuple[int, bool, int]:
|
||||
# losses.
|
||||
losing_book[game_number] = losing_book[game_number] * 6 + move_digit
|
||||
|
||||
if player_has_stones(board) and computer_has_stones(board):
|
||||
is_still_going = True
|
||||
else:
|
||||
is_still_going = False
|
||||
is_still_going = bool(player_has_stones(board) and computer_has_stones(board))
|
||||
return last_location, is_still_going, home
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user