fate() inlined

This commit is contained in:
timerix 2022-10-24 17:44:29 +06:00
parent 49f1931a34
commit cb8f31d998
2 changed files with 4 additions and 7 deletions

View File

@ -1,6 +0,0 @@
#include "krandom.h"
bool fate(float chance){
int limit=1/chance + 0.01f;
return rand()%limit == 0;
}

View File

@ -62,7 +62,10 @@ static inline float64 krand_nextFloat64(krand_statePtr state) {return KRAND_ALG6
///@param chance (0-1.0) is probability of success ///@param chance (0-1.0) is probability of success
bool fate(float chance); static inline bool fate(krand_statePtr state,float chance){
int limit=1/chance + 0.01f;
return KRAND_ALG32_next(state)%limit == 0;
}
#if __cplusplus #if __cplusplus
} }