random number?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
JJPeerless
Posts: 82
Joined: Mon Jun 20, 2005 3:32 am

random number?

Post by JJPeerless »

how can i generate a random number between some min and max value for the PSP..
Lain_OTN
Posts: 17
Joined: Tue Mar 01, 2005 7:18 am

Post by Lain_OTN »

Google is your friend.
Search for Pseudo Random Generators in C

like: http://astronomy.swin.edu.au/~pbourke/analysis/random/

EDIT: You can also search for rand in the API documentation:
http://pspdev.ofcode.com/api.php?simple ... on1=Search
seems like the ssl library has rand functions, How it works... no idea :p
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Google for mersenne twister. It is a very good psuedo random number generator that gives both better random numbers than most other software generators and is faster than virtually all even half decent software based pseudo random number generators.

Just use time, user input, or a combination of the two to seed it. (i.e. grab a seed from the clock and then turn out thousands of random numbers while waiting for user input at the menu)
Shoot Pixels Not People!
Makeshift Development
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Funny you mention the mersenne twister, as it's part of the UtilsForUser library in utils.prx:

Code: Select all

<FUNCTION>
        <NID>0xE860E75E</NID>
        <NAME>sceKernelUtilsMt19937Init</NAME>
</FUNCTION>
<FUNCTION>
        <NID>0x06FB8A63</NID>
        <NAME>sceKernelUtilsMt19937UInt</NAME>
</FUNCTION>
Vampire
Posts: 138
Joined: Tue Apr 12, 2005 8:16 am

Post by Vampire »

mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

A note about that thread - the MT functions I referred to do not require a seperate PRX from UMD - they are already loaded in RAM when your program runs.

My guess is that Ridge Racers had a seperate MT module for speed. Or something.
th0mas
Posts: 43
Joined: Sun Apr 24, 2005 1:59 am
Location: Canada
Contact:

Post by th0mas »

This is a little OT for PSP dev, but related to something I'm working on. Hopefully it survives the lockhammer..

Let's say I have 6 unique arbitrary 32-bit integers.

Does anyone know of a method that one could concoct a function that appears to be a pseudo-random number generator that, given the first of the 6 integers as seed, output the second integer. Given the second integer as seed, it would return the third, and so forth. After the 6 values the numbers could actually be pseudo-prime, it doesn't matter. I've taken number theory and never ran into this (or at least, slept through it), nor could I find anything on google.

Any directions you could point me in?
Post Reply