[Tutor] results not quite 100 percent yet
bhaaluu
bhaaluu at gmail.com
Wed Feb 20 21:23:57 CET 2008
As far as I can see, these routines give me the results
I'm looking for. I get a distribution of four negative numbers,
four positive integers in the range 10 to 110, and nothing
is placed in room 6 or room 11:
#!/usr/bin/python
import random
#print "\n"*30
table= [[ 0, 2, 0, 0, 0, 0, 0], # 1
[ 1, 3, 3, 0, 0, 0, 0], # 2
[ 2, 0, 5, 2, 0, 0, 0], # 3
[ 0, 5, 0, 0, 0, 0, 0], # 4
[ 4, 0, 0, 3,15,13, 0], # 5
[ 0, 0, 1, 0, 0, 0, 0], # 6
[ 0, 8, 0, 0, 0, 0, 0], # 7
[ 7,10, 0, 0, 0, 0, 0], # 8
[ 0,19, 0, 0, 0, 8, 0], # 9
[ 8, 0,11, 0, 0, 0, 0], # 10
[ 0, 0,10, 0, 0, 0, 0], # 11
[ 0, 0, 0,13, 0, 0, 0], # 12
[ 0, 0,12, 0, 5, 0, 0], # 13
[ 0,15,17, 0, 0, 0, 0], # 14
[14, 0, 0, 0, 0, 5, 0], # 15
[17, 0,19, 0, 0, 0, 0], # 16
[18,16, 0,14, 0, 0, 0], # 17
[ 0,17, 0, 0, 0, 0, 0], # 18
[ 9, 0, 0,16, 0, 0, 0]] # 19
# Distribute the treasure
J = 0
while J <= 3:
T = int(random.random()*19)+1
if T == 6:
continue
if T == 11:
continue
if T == 13:
continue
if table[T-1][6] != 0:
continue
b = range(10,110)
treasure = random.choice(b)
table[T-1][6] = treasure
J += 1
# Place androids/aliens in rooms
J = 4
while J > 0:
T = int(random.random()*19)+1
if T == 6:
continue
if T == 11:
continue
if T == 13:
continue
if table[T-1][6] != 0:
continue
table[T-1][6] = -J
J -= 1
#print dir(table)
for i in range(0,19):
print ("%3d" % table[i][6]), "Rm#",i+1
I simply threw away all the previous attempts that weren't
quite 100% and started over. The final test will be to put
these routines in the old games, and see how they work.
--
b h a a l u u at g m a i l dot c o m
"You assist an evil system most effectively by obeying its
orders and decrees. An evil system never deserves such
allegiance. Allegiance to it means partaking of the evil.
A good person will resist an evil system with his or her
whole soul." [Mahatma Gandhi]
More information about the Tutor
mailing list