forked from github/server
disable randomness that causes some tests to become intermittent.
fix normalvariante and chance so they work better with constant rng always returning zero
This commit is contained in:
parent
5d710fa79f
commit
83d40962d2
|
@ -17,6 +17,7 @@ require 'eressea.path'
|
|||
require 'tests.e2'
|
||||
require 'lunit'
|
||||
|
||||
rng_default(0)
|
||||
rules = require('eressea.' .. config.rules)
|
||||
result = lunit.main()
|
||||
return result.errors + result.failed
|
||||
|
|
|
@ -17,6 +17,7 @@ require 'eressea.xmlconf'
|
|||
require 'tests.e3'
|
||||
require 'lunit'
|
||||
|
||||
rng_default(0)
|
||||
eressea.settings.set("rules.alliances", "0")
|
||||
rules = require('eressea.' .. config.rules)
|
||||
result = lunit.main()
|
||||
|
|
|
@ -218,6 +218,9 @@ function test_gmtool()
|
|||
local r1 = region.create(1, 0, "plain")
|
||||
local r2 = region.create(1, 1, "plain")
|
||||
local r3 = region.create(1, 2, "plain")
|
||||
if not gmtool then
|
||||
return
|
||||
end
|
||||
gmtool.open()
|
||||
gmtool.select(r1, true)
|
||||
gmtool.select_at(0, 1, true)
|
||||
|
|
|
@ -6,6 +6,7 @@ function setup()
|
|||
eressea.game.reset()
|
||||
eressea.settings.set("rules.food.flags", "4") -- food is free
|
||||
eressea.settings.set("NewbieImmunity", "0")
|
||||
eressea.settings.set("study.random_progress", "0")
|
||||
end
|
||||
|
||||
local function create_faction(race)
|
||||
|
|
|
@ -990,6 +990,12 @@ static void parse_inifile(lua_State * L, const dictionary * d, const char *secti
|
|||
}
|
||||
}
|
||||
|
||||
static int lua_rng_default(lua_State *L) {
|
||||
UNUSED_ARG(L);
|
||||
random_source_inject_constant(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tolua_bind_open(lua_State * L);
|
||||
|
||||
int tolua_bindings_open(lua_State * L, const dictionary *inifile)
|
||||
|
@ -1060,6 +1066,7 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
|
|||
tolua_function(L, TOLUA_CAST "get_ship", tolua_get_ship);
|
||||
tolua_function(L, TOLUA_CAST "get_building", tolua_get_building);
|
||||
tolua_function(L, TOLUA_CAST "get_region", tolua_get_region);
|
||||
tolua_function(L, TOLUA_CAST "rng_default", lua_rng_default);
|
||||
tolua_function(L, TOLUA_CAST "factions", tolua_get_factions);
|
||||
tolua_function(L, TOLUA_CAST "regions", tolua_get_regions);
|
||||
tolua_function(L, TOLUA_CAST "read_turn", tolua_read_turn);
|
||||
|
|
|
@ -46,7 +46,7 @@ double normalvariate(double mu, double sigma)
|
|||
double z;
|
||||
for (;;) {
|
||||
double u1 = rng_double();
|
||||
double u2 = 1.0 - rng_double();
|
||||
double u2 = rng_double();
|
||||
z = NV_MAGICCONST * (u1 - 0.5) / u2;
|
||||
if (z * z / 4.0 <= -log(u2)) {
|
||||
break;
|
||||
|
@ -73,7 +73,7 @@ bool chance(double x)
|
|||
{
|
||||
if (x >= 1.0)
|
||||
return true;
|
||||
return rng_double() < x;
|
||||
return (1-rng_double()) < x;
|
||||
}
|
||||
|
||||
typedef struct random_source {
|
||||
|
|
Loading…
Reference in New Issue