hadthelad
@hadthelad
im making a poker game (you dont have to know how to play it) and i made a function called smartcomputerstart() which for some reason doesn't do anyth
Python
so basically i want an input statement (under variable:age) where u can only input integers and if you input anything else than it says try again. but
Python
Wumi4 Well, you can't compare a variable and a type! So there are 2 solutions for this:
Converts your variable to a string and use:
if age.isdigit():
#...
Or a more shorter way is to use isinstance():
if isinstance(age, int):
#...
`2 years ago
u dont have to know how to play poker to solve this one because my problem lies with the function smartcomputerstart(). The problem is that i have tol
Python
JBloves27 The reason why it doesn't work is because you did not state it. Whenever you make a function, you have to state it. Like this:
def function():
print('hi')
function()
Because im stating it, then it will work. You can call the function any amount of time.
I hope this helps!2 years ago
LeoXu2 When you call the function on line 174 I think you have to do smartcomputerstart() with parentheses instead of just smartcomputerstart2 years ago
so i made an ai for my poker game and it runs but doesnt pop up with any messages or impact the game in any way. the smart computer start function i h
Python
PattanAhmed @hadthelad Hi,
I have no idea what you are planning to do, Sorry!
But for your side note, You can change those If Statements into Elif Statements for increasing the speed of Executing
Comment me below if you want some Help
Thanks!
Hope this helps
> Please mark my answer if this helps2 years ago
DynamicSquid I don't understand, what are you trying to do?
Oh, also, just a tip, you might want to change those if statements to an elif statement since it's faster2 years ago
so i wrote my ai code for my poker game and whats its supposed to do is the person playing makes a decision, then the ai is supposed to react to that.
Python
DavidShen2 A few questions: is smartcomputerstart() supposed to do nothing and why is there a '' everywhere?
I haven't looked very closely yet but if smartcoumputerstart() is the ai, it doesn't do anything since there is no code for it.2 years ago
so i created this function and it seems to be good but it keeps coming up with this error for this one singular line, take a look:
dsfsofdsp[ifdsjofa
Python
Codejira From the error message I understand that opponentcards and opponentcards_twoare lists.
You can't subtract a list from another list.
What are you trying to validate?3 years ago
so here is the line that has an error:
hel sdkjfuoafk
and here is the error it gave me:
the error of my ways
so could you tell me what the error i
Python
CodingRobot12 try to convert those two variables into integers: the opponentcards and the opponentcards_two3 years ago
so this is just me being curious but how do you make an if statement where say for example you import random:
import random
and make random randint
Python
CodingCactus import random
num1 = random.randint(1,10)
num2 = random.randint(1,10)
if abs(num1 - num2) > 5:
print ('difference is greater than 5')
else:
print('difference is 5 or less')3 years ago
VulcanWM You should use the code:
import random
num1 = random.randint(1,10)
num2 = random.randint(1,10)
print("The first number is ", str(num1))
print("The second number is ", str(num2))
if num1 - num2 5:
print("The difference is bigger than 5.")
elif num2 - num1 5:
print("The difference is bigger than 5.")
elif num1 - num2 Mark this as the answer, if this was helpful or useful3 years ago
VulcanWM So you're saying if the difference between the two numbers is bigger than 2 numbers, it does something, and if it isn't, it does something else?3 years ago
so im trying to make my program so it will randomize the number of the card and the suite of the card, now i have done the number of the card being ra
Python
Bookie0 Hum, i dont know if this is what you want, but you could do something like this...:
suites = ['hearts', 'spades', 'diamonds', 'clubs']
rand_suites = random.choice(suites)
cards = ['J', 'Q', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10']
rand_cards = random.choice(cards)
number_randomizer = 1
while True:
print ((randsuites)+(randcards))
print (number_randomizer)
number_randomizer += 1
Hope this helps! =)3 years ago
so im trying to make a poker game (texas holdem) and i dont really know how to make the ai know when to stay, fold, and raise. is there a way i could
Python
gibbsfreenergy I wish I could help but I don't how poker is played. What do u mean by 'AI'? Do you mean the product of your code?3 years ago
so im trying to make a poker game (texas holdem) and i dont really know how to make the ai know when to stay, fold, and raise. is there a way i could
Python
Kandagor You need to contact the developers of other successful poker games with this question. I think only they can answer all your questions. I am engaged in creating applications and games, but I am currently at the initial stage and will not be able to answer all your questions regarding ai. But I am studying gambling, and so far, I like the design of the game the most of all poker games https://sunpower-world.com/. She's probably one of the best. Look at the AI in this game, and maybe you will find1 year ago
Muffinlavania I dont know poker.. but you use if statements
def smartcomputer():#Call this when you want it to judge
if (good card roll) or (other good card roll):
#Then do whatever for the hand
#LIKE
if opponent_cards=[4,5,6]:
draw(2) #IDK something
`3 years ago
so im trying to make a function but for some reason the line of code underneath it keeps coming up with an error saying expected indent as seen here:
Python
Nettakrim it sees
def oppenent_choice():
player_choice=input(...)
as being part of the same function
try doing
def opponent_choice():
""
player_choice=input(...)
``3 years ago
so im trying to make a poker (texas holdem) game and my first order of business was to make a deck of cards with the values of the real life cards, ra
Python
Bookie0 umm i think you can just make a list:
cards = ["Jack", "Queen", "Ace", etc.]
then do rand_cards = random.choice(cards) (but first import random)
and print(rand_cards)`
hope this helps! =)
3 years ago
so im trying to make a poker game and im just making a test to see if my random.randint works and it keeps coming up with errors basically saying you
Python
could you guys tell me a way to make it so that when someone is inputting something for their story it says to try again if you clicked enter without
Python
SixBeeps You can use a while loop for that.
response = ""
while response == "":
response = input()
`3 years ago
hi so im relatively still new to python and i decided to make a random story generator, so if you know what it is you know how your able to select the
Python
Kai_Justice I'm not sure but if you want to make something where they absolutely have to put a valid gender then try something like this:
while True:
protagonist_gender = input('\nwhat is your protagonists gender:') # <<< takes input each time loop restarts
if protagonist_gender in ['boy', 'girl', 'woman', 'man', 'male', 'female']:
print(protagonist_gender, 'is a valid gender')
break # <<< Ends loop
else:
print("Sorry,", protagonist_gender, 'is not a valid gender') # <<< Since loop doesn'3 years ago
so im making a story generator and im trying to make it when you type and invalid gender when it asks you to pick the gender of the protagonists. but
Python
i have no idea how the hell this is a syntax error:
syntax error
bruh
Python
is there a way to increase the size of text in python?