00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "randomserver.h"
00024 #include <cmath>
00025
00026 using namespace boost;
00027 using namespace zeitgeist;
00028
00029 FUNCTION(RandomServer,seed)
00030 {
00031 int inSeed;
00032
00033 if (
00034 (in.GetSize() != 1) ||
00035 (! in.GetValue(in.begin(),inSeed))
00036 )
00037 {
00038 return false;
00039 }
00040
00041 obj->Seed(inSeed);
00042 return true;
00043 }
00044
00045 FUNCTION(RandomServer,uniformRND)
00046 {
00047 float inMin;
00048 float inMax;
00049
00050 if (
00051 (in.GetSize() != 2) ||
00052 (! in.GetValue(in[0],inMin)) ||
00053 (! in.GetValue(in[1],inMax))
00054 )
00055 {
00056 return 0.0f;
00057 }
00058
00059 return obj->GetUniformRandom(inMin,inMax);
00060 }
00061
00062 FUNCTION(RandomServer,normalRND)
00063 {
00064 float inMean;
00065 float inSigma;
00066
00067 if (
00068 (in.GetSize() != 2) ||
00069 (! in.GetValue(in[0],inMean)) ||
00070 (! in.GetValue(in[1],inSigma))
00071 )
00072 {
00073 return 0.0f;
00074 }
00075
00076 return obj->GetNormalRandom(inMean,inSigma);
00077 }
00078
00079 FUNCTION(RandomServer,exponentialRND)
00080 {
00081 float inLambda;
00082
00083 if (
00084 (in.GetSize() != 1) ||
00085 (! in.GetValue(in[0],inLambda))
00086 )
00087 {
00088 return 0.0f;
00089 }
00090
00091 return obj->GetExponentialRandom(inLambda);
00092 }
00093
00094 void
00095 CLASS(RandomServer)::DefineClass()
00096 {
00097 DEFINE_BASECLASS(zeitgeist/Node);
00098 DEFINE_FUNCTION(seed);
00099 DEFINE_FUNCTION(uniformRND);
00100 DEFINE_FUNCTION(normalRND);
00101 DEFINE_FUNCTION(exponentialRND);
00102 }