Strange randomDirection() behaviour

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Strange randomDirection() behaviour

Post by spara »

I was testing random moon positioning and noticed something quite strange in Oolite 1.77.1.

This code

Code: Select all

	for (var i = 0; i < 3; i++) {
			system.addMoon("moon" + i).texture= "pack1_moon1.png";
			log("test",Vector3D.randomDirection());
	}
	log("test1",Vector3D.randomDirection());
	log("test2",Vector3D.randomDirection());
	log("test3",Vector3D.randomDirection());
gives me this

Code: Select all

23:49:50.066 [test]: (0.737364, -0.377414, 0.560225)
23:49:50.150 [test]: (0.737364, -0.377414, 0.560225)
23:49:50.233 [test]: (0.737364, -0.377414, 0.560225)
23:49:50.233 [test1]: (-0.646662, 0.148543, -0.748173)
23:49:50.233 [test2]: (0.19337, -0.980838, -0.0237779)
23:49:50.233 [test3]: (0.951423, 0.286867, 0.11181)
in the log. For some reason random is not very random if I texture moons with a for loop. Without that texture line, randomDirection works just fine. Adding moons without texturing also seems to be ok. When I texture it, random stops working inside that loop. It seems to do the same with added planets too. Weird or what.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Strange randomDirection() behaviour

Post by cim »

Can you check it in 1.79? There were a few cases in 1.77 where the RNG was getting its seed reset unnecessarily, which are now fixed, so this bug may already be gone.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Strange randomDirection() behaviour [fixed in 1.79]

Post by spara »

Just checked. Works ok with 1.79, so it's a 1.77.1 bug.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Strange randomDirection() behaviour

Post by cim »

Thanks. I've made a note that if possible the fix should be brought back in to the 1.78 branch.
Post Reply