From 050c837d32b445c60e28ca57d15c879b0f47b19c Mon Sep 17 00:00:00 2001 From: schodet Date: Sun, 29 Feb 2004 18:00:14 +0000 Subject: Add: routines pour les nombres aléatoires. --- 2004/i/nono/src/utils/Makefile.defs | 4 ++++ 2004/i/nono/src/utils/rand.cc | 44 +++++++++++++++++++++++++++++++++++++ 2004/i/nono/src/utils/rand.h | 30 +++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 2004/i/nono/src/utils/Makefile.defs create mode 100644 2004/i/nono/src/utils/rand.cc create mode 100644 2004/i/nono/src/utils/rand.h (limited to '2004/i/nono/src') diff --git a/2004/i/nono/src/utils/Makefile.defs b/2004/i/nono/src/utils/Makefile.defs new file mode 100644 index 0000000..34ca3dc --- /dev/null +++ b/2004/i/nono/src/utils/Makefile.defs @@ -0,0 +1,4 @@ +LIBS += utils.a +utils_a_SOURCES = rand.cc + +utils.a: ${utils_a_SOURCES:%.cc=utils.a(%.o)} diff --git a/2004/i/nono/src/utils/rand.cc b/2004/i/nono/src/utils/rand.cc new file mode 100644 index 0000000..623ddc1 --- /dev/null +++ b/2004/i/nono/src/utils/rand.cc @@ -0,0 +1,44 @@ +// rand.cc +// nono - programme du robot 2004. {{{ +// +// Copyright (C) 2004 Nicolas Schodet +// +// Robot APB Team/Efrei 2004. +// Web: http://assos.efrei.fr/robot/ +// Email: robot AT efrei DOT fr +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// }}} +#include "rand.h" + +#include + +/// Classe d'initialisation du générateur de nombres aléatoires. +class RandInit +{ + public: + /// Constructeur. + RandInit (void); +}; + +static RandInit randInit; + +/// Constructeur. +RandInit::RandInit (void) +{ + srand (time (0)); +} + diff --git a/2004/i/nono/src/utils/rand.h b/2004/i/nono/src/utils/rand.h new file mode 100644 index 0000000..0addb8d --- /dev/null +++ b/2004/i/nono/src/utils/rand.h @@ -0,0 +1,30 @@ +#ifndef rand_h +#define rand_h +// rand.h +// nono - programme du robot 2004. {{{ +// +// Copyright (C) 2004 Nicolas Schodet +// +// Robot APB Team/Efrei 2004. +// Web: http://assos.efrei.fr/robot/ +// Email: robot AT efrei DOT fr +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// }}} + +#include + +#endif // rand_h -- cgit v1.2.3