[NTG-context] randomize

Hans Hagen pragma at wxs.nl
Wed Apr 7 09:17:53 CEST 2010


On 7-4-2010 5:05, Aditya Mahajan wrote:
> On Tue, 6 Apr 2010, Wolfgang Werners-Lucchini wrote:
>
>> Hallo,
>>
>> I get allways (10 times at least) the same result:
>> -------------------------------------------------------------
>> \starttext
>> \startluacode
>> math.randomseed(os.time())
>> \stopluacode
>>
>> Encode your Name and Surname as a
>> \startluacode
>> local a = {'null-terminated', 'dollar-terminated', 'Pascal'}
>> context('%s string', a[math.random(1,3)])
>> \stopluacode
>> \stoptext
>> -------------------------------------------------------------
>> How can I randomize this?
>
> Hmm... which version are you using? I do get a ranom output each time.
> Tested with 2009.12.31 and 2010.03.20.
>
> Since the math seed is set after \starttext, it should overwrite the
> value after reading the tuc file.
>
> Actually, I consider saving the random number in tuc file to be a
> misfeature. A random sequence generator should generate a random
> sequence. If I want the same behavior all the time, I can use
> \setupsystem[random=12345] (which should also set math.randomseed).

the reason is that otherwise (esp if the randomization produced 
different input, graphic sizes, etc) you can get oscilation and endless 
runs due to never quite right multipass data which is pretty hard to debug

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list