3 ms·
Wow, the first program I wrote was a D&D character generator too. My friend always has a giant excel spreadsheet open when he's DMing. The tactile response of t
by thomaspaine 18y ago
Wow, the first program I wrote was a D&D character generator too. My friend always has a giant excel spreadsheet open when he's DMing. The tactile response of the dice is fun, but calculating stuff like weight modifiers can be tedious.
Btw, For the 3d6 problem, you could do:
sum([random.randint(1,6) for i in xrange(3)])
That's the python version. I have no idea what I did when I first implemented this in C++ 10 years ago.
- DanielBMarkham 18y agoI believe I started on the program hanging out at Radio Shack in the evenings programming the display TRS-80 (There were no other computers around). I continued it on the school's Commodore Pet a year later. It went through several revisions. It got so I could write the first few hundred lines in BASIC just from memory! C++ would be an awesome language for a generator. Sounds like you came along about 10 or 15 years after me. I wonder how many times this same problem has been solved by new programmers eager to "do something"? Yep dice are fun. Looking up everything in one of those tables is not.
- lacker 18y agoJust FYI, you can clean this up a teeny bit by removing the square brackets to make it a generator expression. Not a big deal but someone might be enlightened. sum(random.randint(1, 6) for _ in range(3))
- thomaspaine 18y agoDoh! You're right. And I just read an article yesterday comparing the speed of generators with list comprehensions http://ikanobori.jp/weblog/2009/04/08/python-sum-of-file-generators-vs-list-comprehensions/ http://ikanobori.jp/weblog/2009/04/08/python-sum-of-file-gen...