\section{KRandom\-Sequence Class Reference}
\label{classKRandomSequence}\index{KRandomSequence@{KRandomSequence}}
A class to create a pseudo-random sequence.  


{\tt \#include $<$krandomsequence.h$>$}

\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KRandom\-Sequence} (long lng\-Seed=0)
\item 
virtual {\bf $\sim$KRandom\-Sequence} ()
\item 
{\bf KRandom\-Sequence} (const {\bf KRandom\-Sequence} \&a)
\item 
{\bf KRandom\-Sequence} \& {\bf operator=} (const {\bf KRandom\-Sequence} \&a)
\item 
void {\bf set\-Seed} (long lng\-Seed=1)
\item 
double {\bf get\-Double} ()
\item 
unsigned long {\bf get\-Long} (unsigned long max)
\item 
bool {\bf get\-Bool} ()
\item 
void {\bf randomize} (QGList $\ast$list)
\item 
void {\bf modulate} (int i)
\end{CompactItemize}


\subsection{Detailed Description}
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.

In general, you should instantiate a KRandom\-Sequence object and pass along your seed number in the constructor. From then on, simply call get\-Double or get\-Long to obtain the next number in the sequence.

\begin{Desc}
\item[Author:]Sean Harmer $<${\tt sh@astro.keele.ac.uk}$>$ \end{Desc}




Definition at line 39 of file krandomsequence.h.

\subsection{Constructor \& Destructor Documentation}
\index{KRandomSequence@{KRandom\-Sequence}!KRandomSequence@{KRandomSequence}}
\index{KRandomSequence@{KRandomSequence}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KRandom\-Sequence::KRandom\-Sequence (long {\em lng\-Seed} = {\tt 0})}\label{classKRandomSequence_a0}


Creates a pseudo-random sequence based on the seed lng\-Seed. 

A Pseudo-random sequence is different for each seed but can be reproduced by starting the sequence with the same seed.

If you need a single value which needs to be unpredictable, you need to use kapp-$>$random() instead.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em lng\-Seed}]Seed to initialize the sequence with. If lng\-Seed is 0, the sequence is initialized with a value from {\bf KApplication::random()}{\rm (p.\,\pageref{classKApplication_e15})}. \end{description}
\end{Desc}


Definition at line 32 of file krandomsequence.cpp.

References set\-Seed().\index{KRandomSequence@{KRandom\-Sequence}!~KRandomSequence@{$\sim$KRandomSequence}}
\index{~KRandomSequence@{$\sim$KRandomSequence}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KRandom\-Sequence::$\sim${\bf KRandom\-Sequence} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKRandomSequence_a1}


Standard destructor. 



Definition at line 42 of file krandomsequence.cpp.\index{KRandomSequence@{KRandom\-Sequence}!KRandomSequence@{KRandomSequence}}
\index{KRandomSequence@{KRandomSequence}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KRandom\-Sequence::KRandom\-Sequence (const {\bf KRandom\-Sequence} \& {\em a})}\label{classKRandomSequence_a2}


Copy constructor. 



Definition at line 47 of file krandomsequence.cpp.

\subsection{Member Function Documentation}
\index{KRandomSequence@{KRandom\-Sequence}!operator=@{operator=}}
\index{operator=@{operator=}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KRandom\-Sequence} \& KRandom\-Sequence::operator= (const {\bf KRandom\-Sequence} \& {\em a})}\label{classKRandomSequence_a3}


Assignment. 



Definition at line 55 of file krandomsequence.cpp.

References m\_\-lng\-Seed1, m\_\-lng\-Seed2, and m\_\-lng\-Shuffle\-Pos.\index{KRandomSequence@{KRandom\-Sequence}!setSeed@{setSeed}}
\index{setSeed@{setSeed}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KRandom\-Sequence::set\-Seed (long {\em lng\-Seed} = {\tt 1})}\label{classKRandomSequence_a4}


Restart the sequence based on lng\-Seed. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em lng\-Seed}]Seed to initialize the sequence with. If lng\-Seed is 0, the sequence is initialized with a value from {\bf KApplication::random()}{\rm (p.\,\pageref{classKApplication_e15})}. \end{description}
\end{Desc}


Definition at line 69 of file krandomsequence.cpp.

References KApplication::random().

Referenced by KRandom\-Sequence().\index{KRandomSequence@{KRandom\-Sequence}!getDouble@{getDouble}}
\index{getDouble@{getDouble}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double KRandom\-Sequence::get\-Double ()}\label{classKRandomSequence_a5}


Get the next number from the pseudo-random sequence. 

\begin{Desc}
\item[Returns:]a pseudo-random double value between [0,1[ \end{Desc}


Definition at line 185 of file krandomsequence.cpp.\index{KRandomSequence@{KRandom\-Sequence}!getLong@{getLong}}
\index{getLong@{getLong}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}unsigned long KRandom\-Sequence::get\-Long (unsigned long {\em max})}\label{classKRandomSequence_a6}


Get the next number from the pseudo-random sequence. 

\begin{Desc}
\item[Returns:]a pseudo-random integer value between [0, max[ with 0 $<$= max $<$ 1.000.000 \end{Desc}


Definition at line 205 of file krandomsequence.cpp.

Referenced by randomize().\index{KRandomSequence@{KRandom\-Sequence}!getBool@{getBool}}
\index{getBool@{getBool}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KRandom\-Sequence::get\-Bool ()}\label{classKRandomSequence_a7}


Get a boolean from the pseudo-random sequence. 

\begin{Desc}
\item[Returns:]a boolean which is either true or false \end{Desc}


Definition at line 213 of file krandomsequence.cpp.\index{KRandomSequence@{KRandom\-Sequence}!randomize@{randomize}}
\index{randomize@{randomize}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KRandom\-Sequence::randomize (QGList $\ast$ {\em list})}\label{classKRandomSequence_a8}


Put a list in random order. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em list}]the list whose order will be modified \end{description}
\end{Desc}


Definition at line 229 of file krandomsequence.cpp.

References get\-Long().\index{KRandomSequence@{KRandom\-Sequence}!modulate@{modulate}}
\index{modulate@{modulate}!KRandomSequence@{KRandom\-Sequence}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KRandom\-Sequence::modulate (int {\em i})}\label{classKRandomSequence_a9}


Modulate the random sequence. 

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.

This can be useful in game situation where \char`\"{}undo\char`\"{} 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 \char`\"{}redo\char`\"{}-s his or hers original move, but different when the player chooses another move.

With this scenario \char`\"{}undo\char`\"{} 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. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em i}]the sequence identified \end{description}
\end{Desc}


Definition at line 168 of file krandomsequence.cpp.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
krandomsequence.h\item 
krandomsequence.cpp\end{CompactItemize}
