Hey, all. I wanted a more reliable way to generate random rules than
with my brain, so I went ahead and wrote a quick python script to do
it for me, which I thought you might as well be able to see. It uses
the Linux /dev/urandom device, so the random numbers are very good and
trusted. It picks random lines out of a file, basically, and those
lines happen to be, in this case, rules from Agora. Here's some sample
output:

[EMAIL PROTECTED]:~/programming/python$ ./ms.py agoran-rules
208

[EMAIL PROTECTED]:~/programming/python$

Here's the code that does it:

#!/usr/bin/env python
import sys
from random import *

rulefile = open(sys.argv[1], "r")
rules = []
while 1:
        x = rulefile.readline()
        if not len(x):
                break
        rules.append(x)
length = len(rules)
print rules[SystemRandom().randint(0,length-1)]

Reply via email to