.TH "KRandomSequence" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KRandomSequence \- A class to create a pseudo-random sequence.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <krandomsequence.h>\fP
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKRandomSequence\fP (long lngSeed=0)"
.br
.ti -1c
.RI "virtual \fB~KRandomSequence\fP ()"
.br
.ti -1c
.RI "\fBKRandomSequence\fP (const \fBKRandomSequence\fP &a)"
.br
.ti -1c
.RI "\fBKRandomSequence\fP & \fBoperator=\fP (const \fBKRandomSequence\fP &a)"
.br
.ti -1c
.RI "void \fBsetSeed\fP (long lngSeed=1)"
.br
.ti -1c
.RI "double \fBgetDouble\fP ()"
.br
.ti -1c
.RI "unsigned long \fBgetLong\fP (unsigned long max)"
.br
.ti -1c
.RI "bool \fBgetBool\fP ()"
.br
.ti -1c
.RI "void \fBrandomize\fP (QGList *list)"
.br
.ti -1c
.RI "void \fBmodulate\fP (int i)"
.br
.in -1c
.SH "Detailed Description"
.PP 
A class to create a pseudo-random sequence. 

Given a seed number, this class will produce a sequence of pseudo-random numbers. This would typically be used in applications like games.
.PP
In general, you should instantiate a KRandomSequence object and pass along your seed number in the constructor. From then on, simply call getDouble or getLong to obtain the next number in the sequence.
.PP
\fBAuthor:\fP
.RS 4
Sean Harmer <sh@astro.keele.ac.uk> 
.RE
.PP

.PP
Definition at line 39 of file krandomsequence.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KRandomSequence::KRandomSequence (long lngSeed = \fC0\fP)"
.PP
Creates a pseudo-random sequence based on the seed lngSeed. 
.PP
A Pseudo-random sequence is different for each seed but can be reproduced by starting the sequence with the same seed.
.PP
If you need a single value which needs to be unpredictable, you need to use kapp->random() instead.
.PP
\fBParameters:\fP
.RS 4
\fIlngSeed\fP Seed to initialize the sequence with. If lngSeed is 0, the sequence is initialized with a value from \fBKApplication::random()\fP. 
.RE
.PP

.PP
Definition at line 32 of file krandomsequence.cpp.
.PP
References setSeed().
.SS "KRandomSequence::~\fBKRandomSequence\fP ()\fC [virtual]\fP"
.PP
Standard destructor. 
.PP
Definition at line 42 of file krandomsequence.cpp.
.SS "KRandomSequence::KRandomSequence (const \fBKRandomSequence\fP & a)"
.PP
Copy constructor. 
.PP
Definition at line 47 of file krandomsequence.cpp.
.SH "Member Function Documentation"
.PP 
.SS "\fBKRandomSequence\fP & KRandomSequence::operator= (const \fBKRandomSequence\fP & a)"
.PP
Assignment. 
.PP
Definition at line 55 of file krandomsequence.cpp.
.PP
References m_lngSeed1, m_lngSeed2, and m_lngShufflePos.
.SS "void KRandomSequence::setSeed (long lngSeed = \fC1\fP)"
.PP
Restart the sequence based on lngSeed. 
.PP
\fBParameters:\fP
.RS 4
\fIlngSeed\fP Seed to initialize the sequence with. If lngSeed is 0, the sequence is initialized with a value from \fBKApplication::random()\fP. 
.RE
.PP

.PP
Definition at line 69 of file krandomsequence.cpp.
.PP
References KApplication::random().
.PP
Referenced by KRandomSequence().
.SS "double KRandomSequence::getDouble ()"
.PP
Get the next number from the pseudo-random sequence. 
.PP
\fBReturns:\fP
.RS 4
a pseudo-random double value between [0,1[ 
.RE
.PP

.PP
Definition at line 185 of file krandomsequence.cpp.
.SS "unsigned long KRandomSequence::getLong (unsigned long max)"
.PP
Get the next number from the pseudo-random sequence. 
.PP
\fBReturns:\fP
.RS 4
a pseudo-random integer value between [0, max[ with 0 <= max < 1.000.000 
.RE
.PP

.PP
Definition at line 205 of file krandomsequence.cpp.
.PP
Referenced by randomize().
.SS "bool KRandomSequence::getBool ()"
.PP
Get a boolean from the pseudo-random sequence. 
.PP
\fBReturns:\fP
.RS 4
a boolean which is either true or false 
.RE
.PP

.PP
Definition at line 213 of file krandomsequence.cpp.
.SS "void KRandomSequence::randomize (QGList * list)"
.PP
Put a list in random order. 
.PP
\fBParameters:\fP
.RS 4
\fIlist\fP the list whose order will be modified 
.RE
.PP

.PP
Definition at line 229 of file krandomsequence.cpp.
.PP
References getLong().
.SS "void KRandomSequence::modulate (int i)"
.PP
Modulate the random sequence. 
.PP
If S(i) is the sequence of numbers that will follow given the current state after calling modulate(i), then S(i) != S(j) for i != j and S(i) == S(j) for i == j.
.PP
This can be useful in game situation where 'undo' restores the state of the random sequence. If the game modulates the random sequence with the move chosen by the player, the random sequence will be identical whenever the player 'redo'-s his or hers original move, but different when the player chooses another move.
.PP
With this scenario 'undo' can no longer be used to repeat a certain move over and over again until the computer reacts with a favorable response or to predict the response for a certain move based on the response to another move. 
.PP
\fBParameters:\fP
.RS 4
\fIi\fP the sequence identified 
.RE
.PP

.PP
Definition at line 168 of file krandomsequence.cpp.

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
