Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all

 

Am trying to write a simple poker game using vb.net, have option strict on, am trying to generate a random number between 1 and 13 using the following line of code

number = CInt(Int((13 * Rnd()) + 1))

However the line just seems to generate the value "1" all the time and so my code goes into an infiniate loop. Would appreciate it if someone could point out what is wrong with this line of code.

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

Problem solved, not to worry.

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted

And if you are looking for truly random numbers....

 

http://www.randomnumbers.info/

 

as created by a quantum computer at the Universtiy of Geneva. Think about all the parallell universes you create with just the single click of a button...

 

Probably not applicable here, as you have a few more restrictions for a poker game, but it's pretty cool and along the same thread. Plus, I bet you don't want to have to make your app web-enabled. But you could just download blocks of random numbers. (overikill in every sense a deterministic number generator will work great)

Posted

It's usually not that hard to make your own random function, I did it in Qbasic when I was bored at school. Use the current time as a seed, possibly have a variable that counts how many times the function was used too and add that do the seed, then, to make sure the numbers aren't too close together do all types of crazy math like: if seed mod 2 = 0 then seed = seed -832478 and all types of stuff like that. You'll get some crazy cool random numbers.

 

OR!

 

look into the random class and save yourself some time

 

(Though making your own IS pretty fun)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...