Designer’s Notes from pydice

Fast-Forward Some Years

Well, pydice (in all its various forms) has been out since 2014. It seems like only a few weeks ago still. A lot has happened in eight years. During that time, I have programmed pretty much in just Python. I have moved from one IDE to another. The current one I’m using is Microsoft Visual Studio Code. I’m still running on Windows 10 because my CPU is not compatible with Windows 11. And I have Python 3.9.13 installed (I have not jumped to version 3.10 or 3.11 because my site-packages is mostly targeted for 3.9. I don’t want to risk updating to 3.11 and find out that my pip list is all for naught.

Since I no longer have Python 2.5.4 (a lost love of mine) installed, I can only run code written for it if I had made .EXE files of it. Py2exe was shear greatness for doing that at the time. I still make .EXE for my Python 3.9 code. But with PyInstaller. It’s obviously a far-improved marvel to watch execute.

At the time of this writing, Python is the number one programming language being both used and learned. Only a year or two ago, I thought Python would still be relegated to the number three spot. But no. The more new programming languages that are released, the more popular Python becomes. Python is everywhere (except for in some phones in people’s hands). But all-in-all, Python is everywhere. I don’t think Python comes pre-installed yet on Windows systems. But a lot of Windows programs come with Python terminals built into them. I still have Poser 6 and Vue 9.5 Infinite running on my computer. And they both have some version of Python running under their hoods.

Very recently, I looked into Lua and Ruby. I installed both of them and gave them a try. It’s really interesting to me how old these programming languages are. Python is over 30 years old. When I look at the TIOBE Index (https://www.tiobe.com/tiobe-index/), it’s really an eye-opener as to what’s popular in the computer programming field. A lot of the languages I used decades ago are now in the under 1% use. As I’ve said before on several occasions, “I wish Python was around in the ’70s!”

Two Camps

So what has happened with dice programs in general for Python?

I’ve notice two worlds when it comes to programming.

By the way, programming is now called coding for some reason. It’s similar to how creative writing is called typing.

Terms are dumbed down in order to not scare away potential students. Schools want to make money after all. Today’s schools are certainly doing a good job of copy/pasting their lessons. YouTube has endless video selections on how to code dice rolling programs. They all use a variation of:

diceroll = random.randint(1, 6)

or:

diceroll = random.randrange(1, 7)

or:

diceroll = int(random.random() * 6 + 1)

for rolling 6-sided dice in their code, which is done procedurally for the most part.

Over on GitHub however, a lot of the dice apps are coded in functional and/or object-oriented fashion.

Nothing seems to be called a program anymore. Nearly everything is referred to as an app now.

These apps often code their dice rolls as:

def diceroll(k, n, dice_sides=6):
   counter = {n : 0 for n in range(k, k*dice_sides + 1)}

or as:

class Die(object):
   def __init__(self, sides = 6):
     self.sides = sides

   def roll(self):
     return randint(1, self.sides)

Neither of these is very appealing to me. The functional style is hard to read, while the object-oriented style creates objects when all is needed are random numbers.

GitHub has other styles of code, such as:

diceroll(1,6,2,3)

Which typically means something along the lines of roll 2 dice numbered 1-6 and add a die-modifier of 3 to the result. Again, it was hard to read some of the apps coded this way. I blame GitHub for propagating such code via their forking. Everyone is copy/pasting over there.

I Still Propose

It might just be me (in fact, I am sure of it), but I still prefer to use:

roll('2d6+3')

and:

roll('d20')

in my games. That will never change.

Shawn Driscoll
July 19th, 2022
US, California