Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
seedrandom.py
Go to the documentation of this file.
1 _seed=0
2 RAND_MAX = 0x7fffffff
3 def getallchar ():
4  rez = ""
5  for i in range(256):
6  rez += "%c"% i
7  return rez
8 allchar = getallchar()
9 aye = allchar.find('a')
10 AAYE= allchar.find('A')
11 Uhun= allchar.find('0')
12 totalnormchar=26+26+10
14  global allchar,aye,AAYE, Uhun
15  charnum=allchar.find(c)
16  if (charnum-aye<26):
17  charnum = charnum-aye
18  else:
19  if (charnum-AAYE<26):
20  charnum = charnum-AAYE+26
21  else:
22  if (charnum-Uhun<10):
23  charnum = charnum-Uhun+26+26
24  return charnum
25 def seedstring (stru):
26  num=long(0)
27  l=len (stru)
28  for i in range(l):
29  global totalnormchar,RAND_MAX
30  num+=long(getNumFromChar(stru[l-i-1]))
31  num*=long(totalnormchar);
32  num = (num % long(RAND_MAX))
33  try:
34  num = int(num)
35  except:
36  print 'warning'
37  return num
38 def interleave (slist):
39  touch=1
40  index=0
41  rez=''
42  while (touch):
43  touch=0
44  for s in slist:
45  if len(s)>index:
46  touch=1
47  rez+=s[index]
48  index+=1
49  return rez
50 _seed=0
51 def rands(intseed):
52  global RAND_MAX
53  intseed = long( long(intseed) * long(1103515245) + long(12345))
54  intseed = long(intseed) %long(RAND_MAX)
55  try:
56  intseed=int(intseed)
57  except:
58  return intseed
59  return intseed
60 def rand():
61  global _seed
62  _seed = rands (_seed)
63  return _seed
64 def seed (seednum):
65  global _seed
66  _seed = seednum