.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 3: The Awakening (http://forum.shrapnelgames.com/forumdisplay.php?f=138)
-   -   python program: DRN (2x open-ended D6 dice) (http://forum.shrapnelgames.com/showthread.php?t=36343)

Horst F. JENS October 9th, 2007 10:06 AM

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.

<font class="small">Code:</font><hr /><pre>
# 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 &gt; 1"
if sides &lt; 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])


</pre><hr />

WraithLord October 9th, 2007 05:26 PM

Re: python program: DRN (2x open-ended D6 dice)
 
Thanks!

It is in my to do list to use python in order to write a combat simulator from dominions. I have already done some nice things with python such as py_eye (like gods eye from dom-II), and an automatic PBEM manager but unfortunately I still haven't started working on the combat sim http://forum.shrapnelgames.com/images/smilies/frown.gif

Horst F. JENS October 10th, 2007 02:40 AM

Re: python program: DRN (2x open-ended D6 dice)
 
cool! Let us resurrect the old DomPPP combat simulator :-)

Zylithan October 10th, 2007 03:05 AM

Re: python program: DRN (2x open-ended D6 dice)
 
combat simulator.... yes please!

WraithLord October 10th, 2007 04:17 AM

Re: python program: DRN (2x open-ended D6 dice)
 
Very well then. I'll make it my next project, right after I complete my personal search engine I'll start on the combat simulator.

Morkilus October 10th, 2007 04:23 PM

Re: python program: DRN (2x open-ended D6 dice)
 
I miss Saber Cherry. http://forum.shrapnelgames.com/images/smilies/frown.gif

NTJedi October 10th, 2007 04:24 PM

Re: python program: DRN (2x open-ended D6 dice)
 
Quote:

Morkilus said:
I miss Saber Cherry. http://forum.shrapnelgames.com/images/smilies/frown.gif

I miss The Paladin... he did some great tools.


All times are GMT -4. The time now is 06:26 AM.

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