1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * |
5 | * |
6 | * Deliantra is free software: you can redistribute it and/or modify |
6 | * Deliantra is free software: you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation, either version 3 of the License, or |
8 | * the Free Software Foundation, either version 3 of the License, or |
9 | * (at your option) any later version. |
9 | * (at your option) any later version. |
… | |
… | |
365 | } |
365 | } |
366 | |
366 | |
367 | void seed (uint32_t seed); |
367 | void seed (uint32_t seed); |
368 | uint32_t next (); |
368 | uint32_t next (); |
369 | |
369 | |
370 | // uniform distribution |
370 | // uniform distribution, 0 .. max (0, num - 1) |
371 | uint32_t operator ()(uint32_t num) |
371 | uint32_t operator ()(uint32_t num) |
372 | { |
372 | { |
373 | return is_constant (num) |
373 | return is_constant (num) |
374 | ? (next () * (uint64_t)num) >> 32U |
374 | ? (next () * (uint64_t)num) >> 32U |
375 | : get_range (num); |
375 | : get_range (num); |
… | |
… | |
393 | int get_range (int r_min, int r_max); |
393 | int get_range (int r_min, int r_max); |
394 | }; |
394 | }; |
395 | |
395 | |
396 | typedef tausworthe_random_generator rand_gen; |
396 | typedef tausworthe_random_generator rand_gen; |
397 | |
397 | |
398 | extern rand_gen rndm; |
398 | extern rand_gen rndm, rmg_rndm; |
399 | |
399 | |
400 | INTERFACE_CLASS (attachable) |
400 | INTERFACE_CLASS (attachable) |
401 | struct refcnt_base |
401 | struct refcnt_base |
402 | { |
402 | { |
403 | typedef int refcnt_t; |
403 | typedef int refcnt_t; |