'Refactored by Sourcery'

This commit is contained in:
Sourcery AI
2023-05-24 23:55:27 +00:00
committed by amjad
parent 7c1e336f14
commit 71d02673a9
70 changed files with 582 additions and 835 deletions

View File

@@ -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