[TI-BASIC] Non-Repeating Random Numbers

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Floodkiller
Sir Posts-A-Lot
Posts: 245
Joined: Mon 14 Nov, 2005 9:47 pm
Location: Getting overwhelmed by everything
Contact:

[TI-BASIC] Non-Repeating Random Numbers

Post by Floodkiller »

Right now I'm stuck on trying to do a non-repeating random number routine that won't take up too much memory. The only one I know how to do only works with about 2 or 3 numbers, but I need to do one for 26 numbers. Could anyone help me?
Main Projects:
Zombie Attack: 20%

Side Projects:
???-25%

Image

Staff member of Hikaru Rakuen Programming.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

do you know you can do:

Code: Select all

if sum(L1 = somevalue or variable )>0
then
"the number is allready in the list atleast once
else
"its a new one
end
i think you can now easily make your own routine
if a for loop isn't fast enough for your purpose if you would have to run it every time again you could generate several lists of a weird size (say, 17 or 23) and then append them (augment(list to start with, list to append to it -> target list ) and use that list, it would be fairly fast.
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

well, another method of generating non-repeating random numbers is to fill a list with numbers in the range that you're looking for sequentially ( {1,2,3,4...} ) and then use the random number generator to select the number of an element. Remove that element(shortening the list) and put that element in the random numbers list. Then the next time you run the random number generator feed it the decremented number that represents the last element in the list as the top bound. It could probably work nicely in a good for loop. That will give you numbers in random order, if that's what you're looking for.
In Memory of the Maxcoderz Trophy Image
Floodkiller
Sir Posts-A-Lot
Posts: 245
Joined: Mon 14 Nov, 2005 9:47 pm
Location: Getting overwhelmed by everything
Contact:

Post by Floodkiller »

Thanks, both of you. I made a routine combining ideas from both of your suggestions.
Main Projects:
Zombie Attack: 20%

Side Projects:
???-25%

Image

Staff member of Hikaru Rakuen Programming.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

You're welcome, may we know what you're using it for?
I hope it's something cool :D
Floodkiller
Sir Posts-A-Lot
Posts: 245
Joined: Mon 14 Nov, 2005 9:47 pm
Location: Getting overwhelmed by everything
Contact:

Post by Floodkiller »

I am making the 83+ family version of Deal or No Deal. The routine was so that it would always randomize the 26 breifcases.

Right now I've got the routine done, as well as the main display for the breifcases. Now I gotta put in the results for picking them, as well as a screen to show the money amounts you have left, plus the routine for having the banker pick the deal amount, but I've already got that figured out.
Main Projects:
Zombie Attack: 20%

Side Projects:
???-25%

Image

Staff member of Hikaru Rakuen Programming.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Sounds cool, do you have any screeny's?
Floodkiller
Sir Posts-A-Lot
Posts: 245
Joined: Mon 14 Nov, 2005 9:47 pm
Location: Getting overwhelmed by everything
Contact:

Post by Floodkiller »

not really since I am still trying to get my computer at home to swallow ti-connect so I can even do anything. If I finish the program before I get TI-Connect, then the screenies will probably be with the file if it gets accepted to Ticalc.org.

Which is most likely, since I could probably finish the game after a few more lines of code, then just to test for bugs.
Main Projects:
Zombie Attack: 20%

Side Projects:
???-25%

Image

Staff member of Hikaru Rakuen Programming.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Sounds cool, I hope you're going to shoot the screen (lol :P ) with the program running on PindurTI, it makes great screenshots, animated black'n white if you want to which is really cool.
Floodkiller
Sir Posts-A-Lot
Posts: 245
Joined: Mon 14 Nov, 2005 9:47 pm
Location: Getting overwhelmed by everything
Contact:

Post by Floodkiller »

Actually, I just ran into a huge problem while beta testing...

I need a new formula for calculating the bankers offer, since the first one I came up with isn't working out as I thought it would, which finds the mean of the remaining breifcases. It works when there are just 2 left (lol). So now I need to find out a formula that will properly do amounts like the show does, maybe a probability formula (too bad I don't know how to make one yet :( ).

I will post some screenies when I get home today.

Edit: Looks like I can't make jpegs or access photobucket on a Windows 98 comp. I guess I can do pics this weekend when I get to the computer at my dad's house (much better :D)
Main Projects:
Zombie Attack: 20%

Side Projects:
???-25%

Image

Staff member of Hikaru Rakuen Programming.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Looks like I can't make jpegs
you shouldn't make jpegs anyway.. blurry edges.. PNG is cool
What exactly does that formula have to do?
I wrote some crazy formula's in the past, I could do it again if i knew what it had to do, I hope :P
Floodkiller
Sir Posts-A-Lot
Posts: 245
Joined: Mon 14 Nov, 2005 9:47 pm
Location: Getting overwhelmed by everything
Contact:

Post by Floodkiller »

You shouldn't make jpegs anyway
Reason: 98 only makes bitmaps, plus I can't seem to access an image hosting site with dial up. :P
I wrote some crazy formula's in the past, I could do it again if i knew what it had to do, I hope
Ok, let me try to describe it, if I can:
The amount that the offer is depends on three different variables:
1. What money amounts are left in play (easy enough :D )
2. How high each of these amounts are (tricky stuff)
3. The chances of you picking a high amount vs. a low amount (aka probability)

In summurization, the bank offer is decided on:
1. How high your highest amount is vs. how low your lowest amount is.
2. How many high amounts you have vs. how many low amounts you have.
3. The number of cases to open each turn.

Number one works like a mean formula, which is what I tried first (not knowing how I could figure in the second one), and it makes an offer depending on the midpoint between the lowest and highest numbers. However, this doesn't exactly work with a maximum of at least 20 numbers.

Number two depends usually on the highest number on the list, then the next closest numbers. If, for example, you have 500000, 400000, 300000, 200000, and 100000, your bank offer will be a significant difference from if you had 1000000, 10, 5, 1, and 0.01.

Number three depends on how many cases you have to open (ex. opening 5 cases the next round will get less of an offer than opening 2 cases the next round because of the probability of eliminating your big amounts is greater when opening more).

If this doesn't cover it, I'll try to describe it more. Also, thanks for attempting this. My brain was really hurting trying to figure this out, and I was able to confuse my math teacher when he tried to do this (I got 5 bonus points for doing it though :D).
Main Projects:
Zombie Attack: 20%

Side Projects:
???-25%

Image

Staff member of Hikaru Rakuen Programming.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

Reason: 98 only makes bitmaps
comon man even ms paint can make PNG's

alright that sounds quite scary, if you can tell me how much it all depends on it then I should be able to get some sort of formula though.
Examples would be great, if you have any examples I can probebly get some formula to work while im pretending to do home work.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Post by benryves »

King Harold wrote:
Reason: 98 only makes bitmaps
comon [sic] man even ms paint can make PNG's
That's his point, not in Windows 98. I think only XP's Paint can do it, I'm not sure they'd added that in 2000. PNG is a pretty wasteful format in any case, GIF would be more appropriate.

I suggest saving as a Windows .bmp file then converting using XnView (freeware) to GIF. tinypic should be good for hosting.

Sounds like an interesting project. :)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

not in windows 98?!?!?! !!!!!!
alright I don't have 98 so I didn't know, but my parents have winME and ME paint does infact make png's.

bloody microsoft..

It probebly has to do something with PNG being relatively new no? That is no excuse for win98 however, PNG has been around since longer then when they released win98.

but about that formula.. If you give some examples it should be a piece of cake (or maybe not, but atleast it would be easier)
Post Reply