#!/usr/bin/env python
import string
+from random import random
+
+orderings = None
class Idler:
def __init__(self, v):
def reset(self):
self.idle_state = 0
+class OrderMaker:
+ def __init__(self, n=8):
+ self.n = n
+ self.a = []
+ self.u = []
+ self.s = []
+ for x in range(0,n):
+ self.u.append(False)
+ self.go()
+
+ def go(self):
+ from copy import deepcopy
+ if len(self.s) == self.n:
+ self.a.append(deepcopy(self.s))
+ else:
+ for x in range(0,self.n):
+ if self.u[x]: continue
+ self.s.append(x)
+ self.u[x] = True
+ self.go()
+ self.u[x] = False
+ self.s.pop()
+
+ def order(self):
+ return self.a
+
class GrayIdler(Idler):
- def __init__(self, v, one=None, zero=None):
+ def __init__(self, v, one=None, zero=None, reorder=0):
self.bits = 8
self.size = 1 << self.bits
self.i = 0
self.v = v
self.one = one
self.zero = zero
+ self.reorder = reorder
+ global orderings
+ if not orderings:
+ orderings = OrderMaker().order()
def next(self):
output = self.do_next_state()
output = string.replace(output, "0", self.zero)
if self.one:
output = string.replace(output, "1", self.one)
+ if self.reorder:
+ global orderings
+ newoutput = ""
+ for i in range(0,8):
+ newoutput += output[orderings[self.reorder][i]]
+ output = newoutput
self.v.display(" %8.8s " % (output))
self.i = (self.i + 1) % self.size
def reset(self):
self.i = 0
self.grayCode = 0
+ if self.reorder:
+ self.reorder = int(random()*40320)
GrayIdler(v,one="*",zero="-"),
GrayIdler(v,one="/",zero="\\"),
GrayIdler(v,one="X",zero="O"),
+ GrayIdler(v,one="*",zero="-",reorder=1),
+ GrayIdler(v,one="/",zero="\\",reorder=1),
+ GrayIdler(v,one="X",zero="O",reorder=1),
]
idler = choose_idler()
time_to_autologout = time() + 15
if time_to_idle == None and cur_user == '':
- time_to_idle = time() + 2
+ time_to_idle = time() + 30
choose_idler()
if time_to_idle != None and cur_user != '': time_to_idle = None
if time_to_idle is not None and time() > time_to_idle: idle_step()
+ if time() > time_to_idle + 300:
+ time_to_idle = time()
+ choose_idler()
mk.update_display()