Python Forum
Making a percentile dice roller and dice roller
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a percentile dice roller and dice roller
#3
I'm not clear where you are going with this, especially the B55x2 line, so I've take the liberty of rewriting and extending what you've shared somewhat in the hope it will give you some ideas on how to achieve your intended objective.

In your original code, there is no means of entering/varying the amount, so I've chosen to make this a random amount, and I've also given the user an opening balance that the amount comes off of. If they win, they get their stake back, otherwise they lose their stake. (Incidentally, you'd varied the spelling of the amount variable.)

When the user runs out of money or either the host or the user gets a certain number of wins, the game ends. Your current code has an infinite loop in it.

I've shown how to use f-strings properly. (There could be calculations or functions calls inside of the {} if you wanted.)

The convention in Python followed by the majority of programmers is to use all lowercase in variable names, so I changed your variable names accordingly.

from random import randint
min = 1
max = 100

user = 'User'
host = 'Host'
amount = 10
user_balance = 1000

max_wins = 100
user_wins = 0  # introduced so the while loop does not run forever
host_wins = 0
 
B55x2 = f'!55x2 {User} {Amount}'  # no idea what this is for as it is never changed
while user_wins < max_wins and host_wins < max_wins and user_balance > 0:
    amount = randint(1, user_balance)
    print(f'{user} bet on 55x2 vs {host} for a bet of {amount}')
    roll = randint(min, max)
    print (f'{host} rolled {roll} with percentile dice')
    if roll > 54:
        print(f'{user} has Won their bet!')
        user_wins += 1
        user_balance += amount
    else:
        print(f'{host} has Lost their bet!')
        host_wins += 1
        user_balance -= amount
        
print(f'Host wins: {host_wins}, User wins: {user_wins} and balance: {user_balance}')
I am trying to help you, really, even if it doesn't always seem that way
Reply


Messages In This Thread
RE: Making a percentile dice roller and dice roller - by gruntfutuk - Sep-30-2018, 12:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  np.percentile returns wrong value? AceTylercholine 2 614 Jul-13-2023, 06:59 PM
Last Post: Skaperen
  While loop not ending (Best of 10 dice game) K3nidi 3 1,456 Jul-09-2022, 09:53 AM
Last Post: K3nidi
  Dice Roll (Find out how many rolls until specified streak) DustinKlent 4 3,913 Jun-13-2021, 09:44 AM
Last Post: Gribouillis
  Help with dice roll program kraco 4 2,043 Sep-22-2020, 02:06 PM
Last Post: kraco
  Help with rerolling the dice blacklight 3 2,890 Jul-01-2020, 05:35 PM
Last Post: blacklight
  game of the goose - dice problem koop 4 3,409 Apr-11-2020, 02:48 PM
Last Post: ibreeden
  simple dice roll Byzas 1 2,315 Mar-21-2019, 02:29 AM
Last Post: ichabod801
Photo roll of the dice kyle007 0 1,695 Mar-11-2019, 01:58 AM
Last Post: kyle007
  Dice game Mazzo76 1 1,945 Feb-26-2019, 11:55 AM
Last Post: Larz60+
  Issue with my 'roll the dice simulation'-exercise (cannot break out of the loop) Placebo 2 3,465 Sep-30-2018, 01:19 PM
Last Post: Placebo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020