I am trying to find out how to balance risk and reward in a higher or lower game in order to play as optimal as possible. The game I am trying to make an algorithm for is the push your luck game on coolmathgames (trying to get better at coding and problem solving) The game has a spinner with numbers 1-13 The goal is to get 100 points in total. You start off by spinning the wheel and landing on a number, n. After each spin the number that the spinner lands on gets added to a temporary score and gets removed from the spinner for the round. You then also get to choose between 4 options, bank, lower, higher, or free spin. If you bank, your temporary score gets added to your current score which is 0 at start of the game. If you choose lower or higher, the spinner spins again and depending on your choice and the new number that was picked you either lose all your temporary points and wait out the round or you can bank, pick higher or lower again, or use your free spin. I did not code the game but this should show the different conditions.
if choice == bank: # bank
score += tempscore
tempscore = 0
newround()
elif choice == lower: # lower
if newnumber < oldnumber:
tempscore += newnumber
numberslist.remove(newnumber)
spin()
else:
tempscore = 0
loseround()
elif choice == higher: # higher
if newnumber > oldnumber:
tempscore += newnumber
numberslist.remove(newnumber)
spin()
else:
tempscore = 0
newround()
else: # freespin
freespinused = True
tempscore += newnumber
numberslist.remove(newnumber)
spin()
So far I have some data that I could use in figuring out the best move which includes
- Probability of having a higher/lower number as a percentage
- Average value of the numbers higher/lower
- Sum of all the values that are higher/lower
- How many numbers are higher/lower
- Average profit (sum of values * probability of next number being higher/lower)
- Total chance of losing (Each of the higher/lower probabilities multiplied together.)
- Free spin used So far I have tried just deciding with the probabilities of not losing which I think is really bad. I have also tried looking up how to balance risk and reward but I could only really find articles about what risk and reward ratios are but I could not find any way to balance them or any sort of algorithm that decides based on probability values and that is what my major problem is. Here is my "algorithm" so far.
def CalculateChoice(self):
if self.higherchance == .5 and self.lowerchance == .5 and self.freespinused == False:
print('Free Spin')
elif self.higherchance == .5 and self.lowerchance == .5:
if self.expectedhigherchance > .5:
if self.higheravgprofit > self.loweravgprofit:
print('higher')
else:
print('Lower')
elif self.expectedhigherchance > .5:
print('higher')
elif self.expectedlowerchance > .5:
print('Lower')
elif self.expectedlowerchance < .5 and self.expectedhigherchance < .5:
print('Bank')
If someone could link me to an article or give me an existing solution that would be amazing! :)