Ask your own question, for FREE!
OpenStudy Feedback 12 Online
OpenStudy (vuriffy):

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!

OpenStudy (vuriffy):

You may have any amount of tries to find the correct number, enjoy.

OpenStudy (tteesstt8080):

Very nice! :) Great job!

jagr2713 (jagr2713):

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

jagr2713 (jagr2713):

@Vuriffy ill create one and tell me which one you like best but you did an AMAZING job :D Props!

jigglypuff314 (jigglypuff314):

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 ;)

jigglypuff314 (jigglypuff314):

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

jigglypuff314 (jigglypuff314):

having guessesTaken==guesses checked before guess==number means that if the player guesses correctly on the last try, they are told they lost

OpenStudy (vuriffy):

@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!

jigglypuff314 (jigglypuff314):

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

OpenStudy (vuriffy):

@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. >.<

OpenStudy (vuriffy):

@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.

jigglypuff314 (jigglypuff314):

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

OpenStudy (vuriffy):

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!

OpenStudy (vuriffy):

I am fairly new, so I don't have too much experience with coding yet. :P I'm like one month in.

jigglypuff314 (jigglypuff314):

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 .-.

jagr2713 (jagr2713):

@Vuriffy how do i send me code on here? Just attach the file ?

OpenStudy (vuriffy):

Well, if it has a URL, copy and paste, but I am sure you can just attach the file, yes.

jagr2713 (jagr2713):

Tell me what you think

jigglypuff314 (jigglypuff314):

ohhh organizing the code with methods/functions very good ^_^

OpenStudy (vuriffy):

The only issue it says is that, raw_input is not defined?

jagr2713 (jagr2713):

Yes thanks Oppsss... The version of python i have is newer so just change raw_input to input :P

jagr2713 (jagr2713):

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

jagr2713 (jagr2713):

Believe it or not but @jigglypuff314 was the one too help me during my python times back in spring ^_^

OpenStudy (vuriffy):

The computer guessed 0, but the game says 1-10. :o

OpenStudy (vuriffy):

Your random.randint is beyond the choice range 1-10, you have 0,11, why not 1,10?

OpenStudy (vuriffy):

Then did error when I just put in 7?

jigglypuff314 (jigglypuff314):

randint is actually including, not excluding so computerChoice = random.randint(1,10) would be better

jagr2713 (jagr2713):

Sorry its suppose to be 1,10

OpenStudy (vuriffy):

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. (:

jigglypuff314 (jigglypuff314):

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)

jagr2713 (jagr2713):

@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

jigglypuff314 (jigglypuff314):

@jagr2713 http://prntscr.com/dh65is

OpenStudy (vuriffy):

I just changed those to "userChoice" is that what they are supposed to be?

jagr2713 (jagr2713):

OMG! lol see when you go way too FAST ! :D Thanks @jigglypuff314

jigglypuff314 (jigglypuff314):

yup

jagr2713 (jagr2713):

realChoice nor user

jigglypuff314 (jigglypuff314):

why realChoice? realChoice is set to 0

OpenStudy (vuriffy):

It worked just fine with userChoice.

OpenStudy (518nad):

nice gj :) it will be useful to show people how to embed diff funcs in the same script

jigglypuff314 (jigglypuff314):

you can also include "you have ", guesses, " left."

OpenStudy (vuriffy):

Hmm, that would be nice to incorporate.

jagr2713 (jagr2713):

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

OpenStudy (518nad):

ill give u a new project

OpenStudy (518nad):

wanna try it?

jagr2713 (jagr2713):

@Vuriffy for that you would need a counter :D

OpenStudy (vuriffy):

@518nad Sure, but I must sleep soon, so I might go at it tomorrow!

OpenStudy (518nad):

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

OpenStudy (vuriffy):

realChoice = realChoice + realChoice Yeah, I was really confused about this line.

jagr2713 (jagr2713):

Yes sorry :P realChoice = userChoice + realChoice :D

OpenStudy (vuriffy):

@518nad That would seem like fun, wow.

jagr2713 (jagr2713):

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

jagr2713 (jagr2713):

I might do that @518nad

OpenStudy (vuriffy):

@jagr2713 I play around with it tomorrow, and we can compare sometime?

OpenStudy (vuriffy):

I will*

jagr2713 (jagr2713):

Most definitely :D Ill do it tonight cause i am bored but yes :D

OpenStudy (vuriffy):

Alright, sweet! Well, bed time for myself, sleep well everyone and have a wonderful day tomorrow!!

jagr2713 (jagr2713):

You too :D Night!

jigglypuff314 (jigglypuff314):

oh yeah, we have a computer science section we can talk there next time x'D

OpenStudy (vuriffy):

Sure thing! :D

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!