Sunday, October 03, 2004

DO YOUR MATHS HOMEWORK
At school I was pretty good at maths, but I kinda lost it over the years and forgot a lot of what I learned. Thats what happens when you go into music and carpentry instead of IT...
Anyway, its coming back to haunt me now. I am re-writing the code for the 'neural effects' that power the simulation in democracy. Basically each effect has a host, a target and some relationship between the two.
So there is an effect between MiddleIncome Voters and Income Tax. As tax goes up, their happiness goes down etc.
It's defining enough flexibility into that equation that is my problem.
I guess most people would parse real equations so you could do this:

MiddleIncome = 0.25 - sqrt(IncomeTax)*(1/IncomeTax *0.8)

or whatever... (thats gibberish)

The thing is, I want to
a) Keep it simple so you dont need a maths degree to tweak the values and
b) Not make it a nightmare to code.

At the moment I have a simple linear system where

MiddleIncome = 0.5 + (IncomeTax * -0.12)

which works just fine. I just altered it so I can have a 'localised' effect within a range of values, so the effect only kicks in if Incometax > n or <>
This helps, but I really need the option to switch between linear and exponential or logarithmic stuff.
The thing is, even using terms like exponential and logarithmic now just depresses me, as I'm crap at maths, and I didn't get into games coding to solve maths problems anyway. Yet another reason to be a designer and not a coder I guess...