Shawn Driscoll's Tech Blog

Stuff That Happened in the Past

Wednesday, January 29, 2014

Python Programming: Building Character

I recently posted a YouTube video showing how to quickly generate the beginnings of a role-playing character for Traveller, using Python 2.5.4.

The source code is below:

from random import randint

char_name = ['STR', 'DEX', 'END', 'INT', 'EDU', 'SOC', 'PSI']

char = [0,0,0,0,0,0,0]

for i in range(len(char_name)):
    char[i] = randint(1,6) + randint(1,6)
for i in range(len(char_name)):
    print '%s: %d' % (char_name[i], char[i])

I may do more such posts here in the future, now that I've recently learned how to properly post program code.

No comments:

Post a Comment