In English Man!
I’m really not a particularly good programmer. I really like programming—or scripting as it were—but my strength is in how I apply it, not my deft code juggling, nor my mathematical prowess. In fact, my brain often locks up when trying to figure out even fairly simple problems, such as how to write a dice probability calculator, and in the long run it often keeps me from actually coding simply because I know how long it takes me to suss out how to do the more ‘complex’ stuff.
But dammit, I like figuring out stuff I can’t figure out, and I found a trick which helps me keep eyes on the ball. I write down what I need to do beforehand, like so:
Create a multi-dimensional array keeping track of skill level vs. results. First array is skill level, under which each element has an array of potential results, which in turn holds the count of how many times the result is likely to be seen.
For each skill level, iterate for each set of dice the possible outcomes, then increment the array element of the highest die.
Calculate the percentiles, draw a chart and watch the cash roll in.
Pretty straight-forward stuff when it’s written out in English. And yeah, multi-dimensional arrays, even two dimensional ones like this one, really break my balls. But when I have it written down, it goes down a lot smoother.
If I run into a problem I can’t quite figure out, I do the exact same thing again, and more often than not, it does the trick. Another ‘trick’, is to keep in mind in your writing, the structure of the code that comes after and keep the sentence and paragraph structures so that it essentially reads like a really high-level version of the final code.
What’s your secret?