Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bonuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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
return 0
4 changes: 2 additions & 2 deletions roulette.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import *
from enum import Enum
from fractions import Fraction
from copy import deepcopy
from typing import Literal
Expand Down Expand Up @@ -337,4 +337,4 @@ def __str__(self):

Dealer's Health: {self.dealer_health} / {self.max_health}
Dealer's Items: {self.dealer_items}
"""
"""
6 changes: 4 additions & 2 deletions start.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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.")
print(f"Completed search in {time.time() - start_time} seconds.")
19 changes: 10 additions & 9 deletions start_gui.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -73,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)
Expand Down Expand Up @@ -203,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]

Expand Down Expand Up @@ -243,4 +244,4 @@ def search(self):
def start(self):
self.window.mainloop()

GraphicBackshot().start()
GraphicBackshot().start()