Anyone want to play my game? I made it up, it's for my computer science project, I think I did fairly well. https://repl.it/E5XD/10 Just press "run" and enjoy. I increased it to 1000, but it's supposed to be 100. :D So enjoy!
You may have any amount of tries to find the correct number, enjoy.
Very nice! :) Great job!
Wow i love your python code :D I created something similar to this back in spring semester of my class. Looks great :D But seems like your code is like confusing me cause its all over the place but where is your def main():? A lot of stuff seems to be missing and the import random Should be at the top of the code not with the function
@Vuriffy ill create one and tell me which one you like best but you did an AMAZING job :D Props!
very cool! although, the person can simply set the number of guesses to be 10000000 and always get the number ;) perhaps you can only give a finite number of guesses :3 you should also print out that the number they should be guessing is between 1 and 100 (including) because there are 101 possibility, the most efficient search method (binary search) would take about 7 tries (max) [ \(log_2(n) = log_2(101) \) ] therefore, you can consider setting the number of guesses allowed to be 7 tries, instead of letting the player choose I think it would add more fun in pressuring the player, and actually gives them a chance to fail ;)
wait wait wait... hold up... @Vuriffy you ordered the if statements so that telling the player they are wrong comes before telling them they are right and I got http://prntscr.com/dh5rwl
having guessesTaken==guesses checked before guess==number means that if the player guesses correctly on the last try, they are told they lost
@jigglypuff314 I haven't been able to understand how to fix that, if you can help me understand how to fix that, that would be wonderful!
the code reads its instructions top to bottom it sees the if statement with the guessesTaken==guesses first, and ends there you can try reordering the if statements so like if guess==number elif guessesTaken==guesses elif guess > number else guess < number I'm not *sure* if it will fix that problem (or cause different problems), but you can try that ;P
@jagr2713 I moved the code around a few times, I believe I had import random at top, not sure when I moved it into my game code. >.<
@jigglypuff314 Just copying and pasting what you had did not call for any invalid syntax, so I would just have to get the correct answer on the last guess to make sure if there is any difference.
whoa there don't copy paste me x'D I only know java, not python I was talking about theory, so you can reorganize how your code is, accordingly
I just wanted to see if it would say invalid syntax. X D, well it did after I shifted it and press run, I understand what you mean, I will attempt to do it, hopefully it works out! Thank you for the heads up!
I am fairly new, so I don't have too much experience with coding yet. :P I'm like one month in.
that's really really impressive then! :O I've dabbled a lil on and off for a few months now, and I'm taking a really difficult class in Data Structures ;-; it's kicking my butt but I can tell you that if you guess numbers using the binary search method, you can get the right answer with no more than 7 guesses every time ^_^ (if there are 100 possible numbers to guess) >what I learned from my computer science class .-.
@Vuriffy how do i send me code on here? Just attach the file ?
Well, if it has a URL, copy and paste, but I am sure you can just attach the file, yes.
Tell me what you think
ohhh organizing the code with methods/functions very good ^_^
The only issue it says is that, raw_input is not defined?
Yes thanks Oppsss... The version of python i have is newer so just change raw_input to input :P
But little advice.. Add more loops because when you ask for an input and if the user just puts like "W" instead of "Yes" i will still run BUT with the loops, it will help so that won't happen :D
Believe it or not but @jigglypuff314 was the one too help me during my python times back in spring ^_^
The computer guessed 0, but the game says 1-10. :o
Your random.randint is beyond the choice range 1-10, you have 0,11, why not 1,10?
Then did error when I just put in 7?
randint is actually including, not excluding so computerChoice = random.randint(1,10) would be better
Sorry its suppose to be 1,10
I feel like I am being way too critical, @jagr2713 I don't mean to offend you, just trying to register it all in my head. (:
and you're getting that error because the if statements are comparing runtime var to computerchoice when it's supposed to be userchoice (not runTime)
@Vuriffy No please this is how we learn :D I see a lot of mistakes but i was just trying to finish it fast before you go to sleep :D But just change it to 1,10 and the error will go away
I just changed those to "userChoice" is that what they are supposed to be?
OMG! lol see when you go way too FAST ! :D Thanks @jigglypuff314
yup
realChoice nor user
why realChoice? realChoice is set to 0
It worked just fine with userChoice.
nice gj :) it will be useful to show people how to embed diff funcs in the same script
you can also include "you have ", guesses, " left."
Hmm, that would be nice to incorporate.
I was taught when lets say we have a program that ask for input for pencils pencils = input("How many pencils?: ") realPencils = pencils + realPencils Basically it helps so when you run it again... the output from the pencils doesn't run again. So it basically reads pencil plus 0 @jigglypuff314 i made another error D: its suppose to be realChoice = userChoice + realChoice
ill give u a new project
wanna try it?
@Vuriffy for that you would need a counter :D
@518nad Sure, but I must sleep soon, so I might go at it tomorrow!
ya its not for right now, u can try it some time though, try to turn this into a battleship game, make it a 10,10 grid (or just choices from 1 to 100), and theh have to guess the 5 or so places the ships are at to win
realChoice = realChoice + realChoice Yeah, I was really confused about this line.
Yes sorry :P realChoice = userChoice + realChoice :D
@518nad That would seem like fun, wow.
Sounds fun! @518nad So create 5 func's and make the tries unlimited... So when they guess one just go to the other func but tell them correct, this is in ____ Spot :D
I might do that @518nad
@jagr2713 I play around with it tomorrow, and we can compare sometime?
I will*
Most definitely :D Ill do it tonight cause i am bored but yes :D
Alright, sweet! Well, bed time for myself, sleep well everyone and have a wonderful day tomorrow!!
You too :D Night!
oh yeah, we have a computer science section we can talk there next time x'D
Sure thing! :D
Join our real-time social learning platform and learn together with your friends!