Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Random without Repitition

Author
Message
Chessplayer
22
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 13th Dec 2003 01:47
I have 500 name$ that need to be placed randomly to each planet$, and I sort of got there with the following code:



This code will eventually place all of name$ under random planet$, but it would take close to forever for all of the names to get placed. Is there an easier way to delegate the name$ to the planet$ without repitition?

This is still Chessplaer! I just decided to spell my handle correctly!
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 13th Dec 2003 02:11 Edited at: 13th Dec 2003 02:13
I havn't tested this for I don't have 500 names to play with

I take it that name$() is a fixed list of names copied into planet$() in a random way, so why not shuffle them:



...adjust the value of the for loop if you need it more or less shuffled.

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Chessplayer
22
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 13th Dec 2003 02:14
Thx a lot! (Yes, name$ is a fixed set of names)

This is still Chessplaer! I just decided to spell my handle correctly!
Chessplayer
22
Years of Service
User Offline
Joined: 22nd Dec 2002
Location:
Posted: 14th Dec 2003 02:21
Just out of curiosity, are there any other ways to do this?

This is still Chessplaer! I just decided to spell my handle correctly!
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 14th Dec 2003 05:50
Make sure to use Randomize Timer() which will make everything more random when using RND()

Just put Randomize Timer() at the top of your program with SYNC ON and stuff.

RPGamer


Dont forget to Join the Forums!

Login to post a reply

Server time is: 2025-05-22 01:54:12
Your offset time is: 2025-05-22 01:54:12