View Issue Details

IDProjectCategoryView StatusLast Update
0003962Spring engineGeneralpublic2013-10-09 02:48
Reportersilentwings Assigned ToKloot  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version94.1.1+git 
Summary0003962: loadscreen is not picked randomly
Descriptionin 94.1.1-996, using the new loadscreens, the random number generator is not initialized properly and it always picks the same loadscreen.
TagsNo tags attached.
Checked infolog.txt for Errors

Relationships

related to 0004040 resolvedKloot test.lua broken / Spring.GetTimer() (?) 

Activities

jK

2013-08-25 01:18

developer   ~0011373

call math.randomseed

silentwings

2013-08-26 11:56

reporter   ~0011407

I can't see what's the cause, but in 94.1.1-1014 this bug is still present (even though it has math.randomseed).

abma

2013-08-27 04:14

administrator   ~0011434

Last edited: 2013-08-27 04:26

math.randomseed(os.time()) doesn't work for me, but this does:

for i = 1, tonumber(os.date("%S")) do
    math.random()
end

not sure whats the cause.

related to https://github.com/spring/spring/blob/develop/rts/lib/lua/include/luaconf.h#L513 ?

in cont/base/springcontent/LuaIntro/Addons/bg_texture.lua does always return 6 for me:

math.randomseed(os.time())
Spring.Echo(math.random(10))

abma

2013-08-27 04:24

administrator   ~0011435

also, os.time() shouldn't be used it seems:

http://www.lua.org/manual/5.1/manual.html#pdf-os.time
" The returned value is a number, whose meaning depends on your system. In POSIX, Windows, and some other systems, this number counts the number of seconds since some given start time (the "epoch"). In other systems, the meaning is not specified, and the number returned by time can be used only as an argument to date and difftime. "

jK

2013-08-27 05:29

developer   ~0011437

does math.randomseed(os.clock()) work?

silentwings

2013-08-27 11:48

reporter   ~0011440

Last edited: 2013-08-27 11:52

Not for me - to me it looks a though os.time() and os.clock() work correctly byt math.randomseed(..) has no effect, regardless of what it's argument is.

(I don't know why but each time a non-developer makes a comment on a thread that's set to 'feedback', mantis automatically changes to 'assigned'.)

abma

2013-08-27 12:10

administrator   ~0011441

Last edited: 2013-08-27 12:12

output of this:
function widget:GameFrame(n)
        if (n % 400) == 0 then
        Spring.Echo(os.time())
        end
end

seems to change every 2 minutes. (128 seconds?!)


[f=0025200] 1377598080
[f=0025600] 1377598208
[f=0026000] 1377598208
[f=0026400] 1377598208
[f=0026800] 1377598208
[f=0027200] 1377598208
[f=0027600] 1377598208
[f=0028000] 1377598208
[f=0028400] 1377598208
[f=0028800] 1377598208
[f=0029200] 1377598336
...

is a float to small for time?

silentwings

2013-08-27 14:44

reporter   ~0011442

Not sure, I think what os.time() returns is dependent on the system, but there must also be more to it because I tried math.randomseed(..) with some randomly typed seeds and still got the same loadscreen.

abma

2013-10-08 15:05

administrator   ~0011727

@silentwings:

did https://github.com/spring/spring/commit/4f102cd934eaa9c8ba77522844f106efffe6194f fix it for you?

(this seems to have fixed some time issues)

silentwings

2013-10-09 02:15

reporter   ~0011730

yes it works fine for me now

Issue History

Date Modified Username Field Change
2013-08-25 00:43 silentwings New Issue
2013-08-25 01:18 jK Note Added: 0011373
2013-08-25 01:18 jK Status new => resolved
2013-08-25 01:18 jK Resolution open => no change required
2013-08-25 01:18 jK Assigned To => jK
2013-08-25 01:21 jK Changeset attached => spring develop 3cb085fa
2013-08-25 01:21 jK Resolution no change required => fixed
2013-08-26 11:56 silentwings Note Added: 0011407
2013-08-26 11:56 silentwings Status resolved => feedback
2013-08-26 11:56 silentwings Resolution fixed => reopened
2013-08-27 04:14 abma Note Added: 0011434
2013-08-27 04:20 abma Note Edited: 0011434
2013-08-27 04:24 abma Note Added: 0011435
2013-08-27 04:26 abma Note Edited: 0011434
2013-08-27 05:29 jK Note Added: 0011437
2013-08-27 11:48 silentwings Note Added: 0011440
2013-08-27 11:48 silentwings Status feedback => assigned
2013-08-27 11:52 silentwings Note Edited: 0011440
2013-08-27 12:10 abma Note Added: 0011441
2013-08-27 12:10 abma Note Edited: 0011441
2013-08-27 12:11 abma Note Edited: 0011441
2013-08-27 12:11 abma Note Edited: 0011441
2013-08-27 12:12 abma Note Edited: 0011441
2013-08-27 14:44 silentwings Note Added: 0011442
2013-10-08 15:05 abma Note Added: 0011727
2013-10-08 22:10 abma Status assigned => feedback
2013-10-08 22:11 abma Relationship added related to 0004040
2013-10-09 02:15 silentwings Note Added: 0011730
2013-10-09 02:15 silentwings Status feedback => assigned
2013-10-09 02:48 abma Status assigned => resolved
2013-10-09 02:48 abma Resolution reopened => fixed
2013-10-09 02:48 Kloot Assigned To jK => Kloot
2013-10-09 02:48 Kloot Status resolved => assigned
2013-10-09 02:48 Kloot Status assigned => resolved