News for hackers. Stuff that matters.
Re:Dungeons and Dragons Co-Creator Dies at 61 by thomaspaine on Friday April 10, 2009 @09:37AM (#556002)
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.

Re:Dungeons and Dragons Co-Creator Dies at 61 by lacker on Friday April 10, 2009 @10:34AM (#556094)
Just 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))
Re:Dungeons and Dragons Co-Creator Dies at 61 by thomaspaine on Friday April 10, 2009 @10:51AM (#556120)
Doh! 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-gen...
Re:Dungeons and Dragons Co-Creator Dies at 61 by DanielBMarkham on Friday April 10, 2009 @09:49AM (#556017)
I 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.