Merge branch 'sourcery/main' of https://github.com/amjadkofahi/basic-computer-games into sourcery/main

This commit is contained in:
amjad
2024-08-19 04:09:55 +03:00
70 changed files with 582 additions and 835 deletions

View File

@@ -153,11 +153,8 @@ def computer_pick(
q = pile_size - 1 if win_option == WinOptions.AvoidLast else pile_size
c = min_select + max_select
computer_pick = q - (c * int(q / c))
if computer_pick < min_select:
computer_pick = min_select
if computer_pick > max_select:
computer_pick = max_select
return computer_pick
computer_pick = max(computer_pick, min_select)
return min(computer_pick, max_select)
def computer_move(
@@ -184,7 +181,7 @@ def computer_move(
# Otherwise, we determine how many the computer selects
curr_sel = computer_pick(pile_size, min_select, max_select, win_option)
pile_size = pile_size - curr_sel
pile_size -= curr_sel
print(f"COMPUTER TAKES {curr_sel} AND LEAVES {pile_size}")
return (False, pile_size)