/Classes/RNG.h
C Header | 39 lines | 14 code | 10 blank | 15 comment | 0 complexity | 0235b07e771c5a1c1f78fded6b8236f4 MD5 | raw file
Possible License(s): Apache-2.0
1// 2// RNG.h 3// 4// Created by Karl Stenerud on 10-02-15. 5// 6 7#import "SynthesizeSingleton.h" 8 9/** Random number generator interface */ 10@interface RNG : NSObject 11{ 12 unsigned int seedValue; 13} 14/** The current seed value being used */ 15@property(nonatomic,readwrite,assign) unsigned int seedValue; 16 17SYNTHESIZE_SINGLETON_FOR_CLASS_HEADER(RNG); 18 19/** Initialize with the specified seed value. 20 * This must ONLY be called BEFORE accessing sharedInstance. 21 */ 22- (id) initWithSeed:(unsigned int) seed; 23 24/** Returns a random unsigned int from 0 to 0xffffffff */ 25- (unsigned int) randomUnsignedInt; 26 27/** Returns a random probability value from 0.0 to 1.0 */ 28- (double) randomProbability; 29 30/** Returns a random integer from minValue to maxValue */ 31- (int) randomNumberFrom: (int) minValue to: (int) maxValue; 32 33/** Returns a random integer from minValue to maxValue, but does not return exceptValue */ 34- (int) randomNumberFrom: (int) minValue to: (int) maxValue except:(int) exceptValue; 35 36/** Randomly returns YES or NO */ 37- (bool) randomBool; 38 39@end