1 | <html> |
---|
2 | <head> |
---|
3 | <title>Random-Number Seed</title> |
---|
4 | <link rel="stylesheet" type="text/css" href="pythia.css"/> |
---|
5 | <link rel="shortcut icon" href="pythia32.gif"/> |
---|
6 | </head> |
---|
7 | <body> |
---|
8 | |
---|
9 | <script language=javascript type=text/javascript> |
---|
10 | function stopRKey(evt) { |
---|
11 | var evt = (evt) ? evt : ((event) ? event : null); |
---|
12 | var node = (evt.target) ? evt.target :((evt.srcElement) ? evt.srcElement : null); |
---|
13 | if ((evt.keyCode == 13) && (node.type=="text")) |
---|
14 | {return false;} |
---|
15 | } |
---|
16 | |
---|
17 | document.onkeypress = stopRKey; |
---|
18 | </script> |
---|
19 | <?php |
---|
20 | if($_POST['saved'] == 1) { |
---|
21 | if($_POST['filepath'] != "files/") { |
---|
22 | echo "<font color='red'>SETTINGS SAVED TO FILE</font><br/><br/>"; } |
---|
23 | else { |
---|
24 | echo "<font color='red'>NO FILE SELECTED YET.. PLEASE DO SO </font><a href='SaveSettings.php'>HERE</a><br/><br/>"; } |
---|
25 | } |
---|
26 | ?> |
---|
27 | |
---|
28 | <form method='post' action='RandomNumberSeed.php'> |
---|
29 | |
---|
30 | <h2>Random-Number Seed</h2> |
---|
31 | |
---|
32 | The seed of the random number generator can be set as follows: |
---|
33 | |
---|
34 | <br/><br/><strong>Random:setSeed</strong> <input type="radio" name="1" value="on"><strong>On</strong> |
---|
35 | <input type="radio" name="1" value="off" checked="checked"><strong>Off</strong> |
---|
36 | (<code>default = <strong>off</strong></code>)<br/> |
---|
37 | Indicates whether a user-set seed should be used every time the |
---|
38 | <code>Pythia::init</code> routine is called. If off, the random number |
---|
39 | generator is initialized with its default seed at the beginning |
---|
40 | of the run, and never again. If on, each new <code>Pythia::init</code> |
---|
41 | call (should several be made in the same run) results in the random |
---|
42 | number being re-initialized, thereby possibly starting over with the |
---|
43 | same sequence, if you do not watch out. |
---|
44 | |
---|
45 | |
---|
46 | <br/><br/><table><tr><td><strong>Random:seed </td><td></td><td> <input type="text" name="2" value="-1" size="20"/> (<code>default = <strong>-1</strong></code>; <code>maximum = 900000000</code>)</td></tr></table> |
---|
47 | The seed to be used, if <code>setSeed</code> is on.<br/> |
---|
48 | A negative value gives the default seed,<br/> |
---|
49 | a value 0 gives a random seed based on the time, and<br/> |
---|
50 | a value between 1 and 900,000,000 a unique different random number |
---|
51 | sequence. |
---|
52 | |
---|
53 | |
---|
54 | <p/> |
---|
55 | For more on random numbers see <?php $filepath = $_GET["filepath"]; |
---|
56 | echo "<a href='RandomNumbers.php?filepath=".$filepath."' target='page'>";?>here</a>. |
---|
57 | This includes methods to save and restore the state of the generator, |
---|
58 | and some preprogrammed methods to generate non-uniform random numbers. |
---|
59 | |
---|
60 | <input type="hidden" name="saved" value="1"/> |
---|
61 | |
---|
62 | <?php |
---|
63 | echo "<input type='hidden' name='filepath' value='".$_GET["filepath"]."'/>"?> |
---|
64 | |
---|
65 | <table width="100%"><tr><td align="right"><input type="submit" value="Save Settings" /></td></tr></table> |
---|
66 | </form> |
---|
67 | |
---|
68 | <?php |
---|
69 | |
---|
70 | if($_POST["saved"] == 1) |
---|
71 | { |
---|
72 | $filepath = $_POST["filepath"]; |
---|
73 | $handle = fopen($filepath, 'a'); |
---|
74 | |
---|
75 | if($_POST["1"] != "off") |
---|
76 | { |
---|
77 | $data = "Random:setSeed = ".$_POST["1"]."\n"; |
---|
78 | fwrite($handle,$data); |
---|
79 | } |
---|
80 | if($_POST["2"] != "-1") |
---|
81 | { |
---|
82 | $data = "Random:seed = ".$_POST["2"]."\n"; |
---|
83 | fwrite($handle,$data); |
---|
84 | } |
---|
85 | fclose($handle); |
---|
86 | } |
---|
87 | |
---|
88 | ?> |
---|
89 | </body> |
---|
90 | </html> |
---|
91 | |
---|
92 | <!-- Copyright (C) 2012 Torbjorn Sjostrand --> |
---|