No, this is all I wish from you - I am yet to define strategy. Please do as I as
ID: 3715148 • Letter: N
Question
No, this is all I wish from you - I am yet to define strategy.
Please do as I ask, thankyou : as below
I do not know what you mean? Nothing - it is just a game I need help coding with that has a game summary win/lose/draw
Python Programming
Hi, I request Python 3.6 source code for output below, thanks.
1. Always steal
2 Always deal
3. Random
Which strategy for the computer [1,2,3]? 9
Please enter either 1, 2, or 3.
Which strategy for the computer [1,2,3]? 3
Jackpot: 100
Steal, Deal or Quit [s|d|q]? s
You chose: Steal
Comp chose: Deal
You win! You gain 100.
>> Your score: 100 -- Comp score: 0 <<
Jackpot: 100
Steal, Deal or Quit [s|d|q]? d
You chose: Deal
Comp chose: Deal
Draw! Split pot - 50 each!
>> Your score: 150 -- Comp score: 50 <<
Jackpot: 100
Steal, Deal or Quit [s|d|q]? s
You chose: Steal
Comp chose: Deal
You win! You gain 100.
>> Your score: 250 -- Comp score: 50 <<
Jackpot: 100
Steal, Deal or Quit [s|d|q]? s
You chose: Steal
Comp chose: Steal
Too greedy! You get nothing!
Careful... one more steal and you lose it all!
>> Your score: 250 -- Comp score: 50 <<
Explanation / Answer
import random
def compChoice(st):
if st == 1:
return 's'
elif st == 2:
return 'd'
else:
return 's' if (int(10*random.random()))%2 else 'd'
strategy = 0
while strategy<1 or strategy>3:
print("Which strategy for the compuuter [1,2,3]?",end='' )
strategy = int(input())
if (strategy<1 or strategy>3):
print('Please enter either 1, 2, or 3.')
yourScore = 0
compScore = 0
selection = 's'
while selection != 'q':
print("Jackpot: 100")
print("Steal, Deal or quit [s|d|q]? ", end='')
selection = input()
if(selection == 'q'):
break
print('You chose: ', end='')
if(selection == 's'):
print('Steal')
else:
print('Deal')
comp = compChoice(strategy)
print('Comp chose: ', end='')
if(comp == 's'):
print('Steal')
else:
print('Deal')
if(selection=='d' and comp=='d'):
yourScore += 50
compScore += 50
print("Draw! Split pot - 50 each")
elif(selection=='s' and comp=='s'):
print("Too greedy! You get nothing!")
elif(selection=='s' and comp=='d'):
yourScore += 100
print("You win! You gain 100.")
else:
compScore += 100
print("Too greedy! You get nothing!")
print("Careful... one more steal and you lose it all!")
print(">> Your score: " + str(yourScore) + " -- Comp score: " + str(compScore) + " <<")
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.