Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random number guessing game.....
#11
Quote:well, that doesn't help...

so sorry, your post came before mine
y name is Nobody, and nobody's perfect. So now I am perfect Tongue

98% of the teenage population smokes or has smoked pot. If you're one of the 2% who hasn't, copy and paste this in your signature.
Reply
#12
Quote:
tannervp Wrote:well, that doesn't help...

so sorry, your post came before mine
I'm assuming you meant my (Moneo) post.

Did you read my other suggestions?
*****
Reply
#13
yep. One thing...
Code:
RANDOMIZE TIMER
INPUT "Pick a number:"; num$
getnum% = INT(RND * 20) + 1
IF num$ =

THAT's where I need help.
y name is Nobody, and nobody's perfect. So now I am perfect Tongue

98% of the teenage population smokes or has smoked pot. If you're one of the 2% who hasn't, copy and paste this in your signature.
Reply
#14
well you can either change num$ to simply num if your user is only going to be inputting numbers. Otherwise you can do the VAL command. VAL(num$) converts your string to a number. then you can do it like this
Code:
IF VAL(num$) = getnum% THEN
    PRINT "YOU WIN"
ELSEIF num > getnum'.....etc
I'd finish the code, but it looks like you need the practice and it would do you no good if I wrote the program for you
[Image: freebasic.png]
Reply
#15
surely if you give someone 5 guesss from 1-20
they can always win by splitting in half till they get it.


10 lower
5 higher
7 higher
8 higher
9 bingo
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#16
yes, that's right.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#17
The "splitting in half" technique is called a Binary Search. Some programmers may think of it, but most regular users wont.
*****
Reply
#18
binary, a wonderful thing, but anyway there are many tutorials on this, plus theres a program called Learn To Program Basic, from scholastic, i bought it in a bok order in grade 8 like 3 years ago and it had programs premade, one of them was a guessing game too, altough the basic files were different, the coding was BASICally the same, lol, no pun intended but it happened, anyway, the coding aint really that hard no offence, its all basic math really
Reply
#19
Quote:Some programmers may think of it, but most regular users wont.

i wouldnt count on it, we were taught that in the first year of secondary school(age 11-12)
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply
#20
Isn't their a EXAMPLE that shows you how to do this on QbasicNews.Com

Also A Trick i use to make random numbers easier is

Code:
Declare FUNCTION int.rnd(base1 as long, base2 as long) as long

FUNCTION int.rnd(base1 as long, base2 as long) as long
    Return int((rnd*base2)+base1)
END FUNCTION

Int.Rnd ((The lowest possible number),(the highest Possible number)
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)