From d353cf5146da47789a2ad41676423c6526aa6957 Mon Sep 17 00:00:00 2001 From: Quint Guvernator Date: Fri, 17 Jan 2025 16:08:33 +0100 Subject: [PATCH 1/2] fix imports --- roulette.py | 4 ++-- start.py | 6 ++++-- start_gui.py | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/roulette.py b/roulette.py index 6d05a62..5fb8a09 100644 --- a/roulette.py +++ b/roulette.py @@ -1,4 +1,4 @@ -from enum import * +from enum import Enum from fractions import Fraction from copy import deepcopy from typing import Literal @@ -337,4 +337,4 @@ def __str__(self): Dealer's Health: {self.dealer_health} / {self.max_health} Dealer's Items: {self.dealer_items} -""" \ No newline at end of file +""" diff --git a/start.py b/start.py index af6f0e0..2872cf9 100644 --- a/start.py +++ b/start.py @@ -1,6 +1,8 @@ -from backshot import * import time +from backshot import BackshotRoulette +from roulette import BuckshotRouletteMove, Items + bot = BackshotRoulette() def string_to_item(item_string: str): @@ -86,4 +88,4 @@ def idiot_input(prompt: object = "", condition = lambda x: 1): print(bot.search(depth, position)) print(f"Searched {bot.positions_searched} positions in {time.time() - depth_start_time} seconds.") -print(f"Completed search in {time.time() - start_time} seconds.") \ No newline at end of file +print(f"Completed search in {time.time() - start_time} seconds.") diff --git a/start_gui.py b/start_gui.py index 060ad17..f628530 100644 --- a/start_gui.py +++ b/start_gui.py @@ -1,7 +1,8 @@ import tkinter as tk from tkinter import ttk -from backshot import * -import time + +from backshot import BackshotRoulette +from roulette import BuckshotRouletteMove, Items def font(size: int, bold = False): font_name = "Arial Black" if bold else "Arial" @@ -243,4 +244,4 @@ def search(self): def start(self): self.window.mainloop() -GraphicBackshot().start() \ No newline at end of file +GraphicBackshot().start() From 33acbf5911fb9cb8c8cc4bf6674fcd325b90a197 Mon Sep 17 00:00:00 2001 From: Quint Guvernator Date: Fri, 17 Jan 2025 16:13:08 +0100 Subject: [PATCH 2/2] complete .live_shells/.blank_shells refactor --- bonuses.py | 16 ++++++++-------- start_gui.py | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bonuses.py b/bonuses.py index 71e3976..be0148a 100644 --- a/bonuses.py +++ b/bonuses.py @@ -37,7 +37,7 @@ def item_bonus(items: list): def item_usage_bonus(move: ValidMoves, state: BuckshotRouletteMove): match move: case ValidMoves.USE_BEER: - if state.get_current_shell() == None and state.live_shells < state.blank_shells: return 250 + if state.get_current_shell() == None and state.unknown_live_shells < state.unknown_blank_shells: return 250 return 0 case ValidMoves.USE_CIGARETTES: @@ -47,10 +47,10 @@ def item_usage_bonus(move: ValidMoves, state: BuckshotRouletteMove): case ValidMoves.USE_HAND_SAW: if state.get_current_shell() == "live": return 250 - if state.live_shells >= state.blank_shells: return 100 + if state.unknown_live_shells >= state.unknown_blank_shells: return 100 case ValidMoves.USE_HANDCUFFS: - if state.live_shells + state.blank_shells == 2: return 250 + if state.unknown_live_shells + state.unknown_blank_shells == 2: return 250 return 100 case ValidMoves.USE_MAGNIFYING_GLASS: @@ -72,7 +72,7 @@ def known_shell_bonus(move: ValidMoves, state: BuckshotRouletteMove): elif (not state.is_players_turn) and move != ValidMoves.SHOOT_DEALER: return INF elif state.get_current_shell() == None: - chance_live_loaded = Fraction(state.live_shells, state.live_shells + state.blank_shells) + chance_live_loaded = Fraction(state.unknown_live_shells, state.unknown_live_shells + state.unknown_blank_shells) if state.is_players_turn and move == ValidMoves.SHOOT_DEALER: chance_live_loaded *= 100 elif (not state.is_players_turn) and move == ValidMoves.SHOOT_PLAYER: chance_live_loaded *= 100 @@ -95,13 +95,13 @@ def low_health_penalty(state: BuckshotRouletteMove): return 0 def shoot_other_person_bonus(move: ValidMoves, state: BuckshotRouletteMove): - chance_live_loaded = Fraction(state.live_shells, state.live_shells + state.blank_shells) + chance_live_loaded = Fraction(state.unknown_live_shells, state.unknown_live_shells + state.unknown_blank_shells) if state.get_current_shell() != None or chance_live_loaded < 0.5: return 0 if state.is_players_turn and move == ValidMoves.SHOOT_DEALER: - return 100 * (state.live_shells - state.blank_shells) + return 100 * (state.unknown_live_shells - state.unknown_blank_shells) elif (not state.is_players_turn) and move == ValidMoves.SHOOT_PLAYER: - return 100 * (state.live_shells - state.blank_shells) + return 100 * (state.unknown_live_shells - state.unknown_blank_shells) - return 0 \ No newline at end of file + return 0 diff --git a/start_gui.py b/start_gui.py index f628530..2b11ee6 100644 --- a/start_gui.py +++ b/start_gui.py @@ -74,20 +74,20 @@ def set_up_inputs(self): ) self.player_health.grid(row = 3, column = 1) - self.live_shells = tk.Spinbox(self.window, + self.unknown_live_shells = tk.Spinbox(self.window, from_ = 0, to = 4, font = font(16), state = "readonly" ) - self.live_shells.grid(row = 5, column = 1) - self.blank_shells = tk.Spinbox(self.window, + self.unknown_live_shells.grid(row = 5, column = 1) + self.unknown_blank_shells = tk.Spinbox(self.window, from_ = 0, to = 4, font = font(16), state = "readonly" ) - self.blank_shells.grid(row = 6, column = 1) + self.unknown_blank_shells.grid(row = 6, column = 1) self.dealer_items = tk.Entry(self.window, font = font(16) @@ -204,8 +204,8 @@ def search(self): max_health = get_int_value(self.maximum_health) dealer_health = max(max_health, get_int_value(self.dealer_health)) player_health = max(max_health, get_int_value(self.player_health)) - lives = get_int_value(self.live_shells) - blanks = get_int_value(self.blank_shells) + lives = get_int_value(self.unknown_live_shells) + blanks = get_int_value(self.unknown_blank_shells) dealer_items = string_to_item(self.dealer_items.get())[:8] player_items = string_to_item(self.player_items.get())[:8]