.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old October 9th, 2007, 10:06 AM
Horst F. JENS's Avatar

Horst F. JENS Horst F. JENS is offline
Sergeant
 
Join Date: Oct 2003
Location: Vienna, Austria, Europe
Posts: 234
Thanks: 62
Thanked 11 Times in 6 Posts
Horst F. JENS is on a distinguished road
Default python program: DRN (2x open-ended D6 dice)

The manual on page 5 explain very good the DRN (open-ended-dice) system.
So i made a small python script to test it out. Improved my knowlege about the game's random numbers, maybe it is useful for others too.

you need python from http://www.python.org to run this script.

Code:

# works like a normal dice, but you can throw the dice again
# if the dice rolls the highest possible number.
# If the dice rolls the highest possible number, the number will be added, then
# 1 will be substracted and the dice rolls again.
# allows (theoretical) extremly highs values, but only in extrem rare situations

import random

def domdice(sides=6):
"rolls a dice. sides must be > 1"
if sides < 2:
raise SystemExit
sum = 1
dice = sides
while dice == sides:
sum -=1
dice = random.randint(1,sides)
sum += dice
return sum

#-------- try it out ------

results = {}
for x in xrange(10000):
roll = domdice()+domdice()
if roll in results:
results[roll] += 1
else:
results[roll] = 1

for key in range(1,max(results),1):
if key in results:
print "%d %d" % (key, results[key])



Reply With Quote
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:58 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.