Just got off of a two month long software development internship. It was a lot of fun and I learned a lot but programming for 8 hours a day doesn’t leave me with enough energy to put time into my personal projects. The other night I was looking Project folder, looking for anything that I could finish or revamp. My D&D character creator that I partially built around 6 or 8 months ago was something I was really itching to finish. With some of the new skills I picked up over the internship building a UI I thought it would be cool to take my character creator out of the command line and build a UI for it.
I’m probably going to use CustomTkinter, It’s very easy to use and is written exclusively in Python. I already improved one of the main sections of my original program. If you know anything about D&D you’ll know you roll for 6 stats by rolling 5 6 sided dice dumped the lowest number and add them together. Well originally I got lazy and just had the program pick a number between 8 and 18, plus it’s not very fun to play with a 8 for one of your stats anyway but I wanted to change it so the program was in line with the rules.
Then I started thinking, how many attempts would it take to get the ideal character? There’s always somebody in the group who rolls an 18 and or doesn’t roll below a 15 somehow. I’ve never actually done any research or testing on how often that can actually happen. So for fun I just added a for loop with a section asking how many times you would like to run the program.
These are the best stats I was able to get after 100000 attempts.

import random
print("Time to roll your D&D character stats!")
attempts = int(input("How many attempts would you like? "))
best_stats = []
# Loop
for _ in range(attempts):
current_stats = []
# Generate six stats for each set
for _ in range(6):
stat_roll = [random.randint(1, 6) for _ in range(4)]
stat_roll.sort(reverse=True)
stat_roll = stat_roll[:3] # Drop the lowest roll
stat = sum(stat_roll)
current_stats.append(stat)
# If this set of stats is better than the current best, replace it
if sum(current_stats) > sum(best_stats):
best_stats = current_stats
# Sort the best stats from highest to lowest
if attempts == 1:
best_stats.sort(reverse=True)
print(best_stats)
print("Integrity metal awarded, have fun! ╰(*°▽°*)╯")
else:
best_stats.sort(reverse=True)
print("After", attempts, "attempts here is your ideal specimen.")
print(f"Best Stats {best_stats}")
print("But make sure to tell your friends you got them on your first attempt and have fun! ☜(゚ヮ゚☜)")
The dream is for me to replace the app I’ve been using my phone. It works very well but there are a few quality-of-life things I’d like to change.
- The notes/information Section is very organized. For example the features section it has a list of all your different abilities. Some of them are passive and some of them have limited uses per day. There’s no way to mark down the you use one of your abilities and have it reset the next day for example. There’s a similar problem with inventory items such as ammo and other single use items.
- The app doesn’t assist the player in selecting spells based on their class choice.
- Give quality descriptions of abilities, races, classes, spells etc.
One feature I’m extremely excited about is adding a feature that would help the user automatically create a character based on what class they chose by allocating their stats for them using certain criteria. At the moment it only allocates stats based on your class choice. But I think it would be interesting to also ask the user questions about what they want their character to be able to do and makes recommendations based off of that. Excited pick up this project again hope I can finally finish this.