Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

randomserver_c.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2004 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: randomserver_c.cpp,v 1.4 2004/05/01 17:16:51 fruit Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 }

Generated on Thu Apr 6 15:25:39 2006 for rcssserver3d by  doxygen 1.4.4