OpenCores
URL https://opencores.org/ocsvn/thor/thor/trunk

Subversion Repositories thor

[/] [thor/] [trunk/] [FT64v5/] [software/] [CC64/] [source/] [rand.h] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 robfinch
/**********************************************************************
2
 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; either version 2, or (at your option)
6
   any later version.
7
 
8
   This program is distributed in the hope that it will be useful,
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
   GNU General Public License for more details.
12
***********************************************************************/
13
 
14
#pragma once
15
 
16
/* This is duplicated in shared.h to avoid extra includes: */
17
#define MAX_UINT32 0xFFFFFFFF
18
 
19
typedef unsigned int RANDOM_TYPE;
20
 
21
typedef struct {
22
  RANDOM_TYPE v[56];
23
  int j, k, x;
24
  bool is_init;                 /* initially 0 for static storage */
25
} RANDOM_STATE;
26
 
27
namespace RTFClasses
28
{
29
class Random
30
{
31
private:
32
        static RANDOM_STATE rand_state;
33
        RANDOM_STATE static getRandState(void) {
34
                return rand_state;
35
        }
36
        void static setRandState(RANDOM_STATE state) {;
37
                rand_state = state;
38
        }
39
public:
40
        bool static isInit(void) {
41
                return rand_state.is_init;
42
        }
43
        RANDOM_TYPE static rand(RANDOM_TYPE size);
44
        void static srand(RANDOM_TYPE seed);
45
        void test(int n);
46
};
47
};

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.