forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

random number?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
JJPeerless



Joined: 20 Jun 2005
Posts: 82

PostPosted: Wed Jun 22, 2005 5:56 am    Post subject: random number? Reply with quote

how can i generate a random number between some min and max value for the PSP..
Back to top
View user's profile Send private message
Lain_OTN



Joined: 01 Mar 2005
Posts: 17

PostPosted: Wed Jun 22, 2005 6:34 am    Post subject: Reply with quote

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?simpleSearch=&keyword=rand&button1=Search
seems like the ssl library has rand functions, How it works... no idea :p
Back to top
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Wed Jun 22, 2005 7:37 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jun 22, 2005 7:45 am    Post subject: Reply with quote

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

Code:
<FUNCTION>
        <NID>0xE860E75E</NID>
        <NAME>sceKernelUtilsMt19937Init</NAME>
</FUNCTION>
<FUNCTION>
        <NID>0x06FB8A63</NID>
        <NAME>sceKernelUtilsMt19937UInt</NAME>
</FUNCTION>
Back to top
View user's profile Send private message
Vampire



Joined: 12 Apr 2005
Posts: 138

PostPosted: Wed Jun 22, 2005 7:55 am    Post subject: Reply with quote

http://forums.ps2dev.org/viewtopic.php?t=1878
Back to top
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jun 22, 2005 9:53 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
th0mas



Joined: 24 Apr 2005
Posts: 43
Location: Canada

PostPosted: Wed Jun 22, 2005 11:49 pm    Post subject: Reply with quote

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?
_________________
http://th0mas.xbox-scene.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group