I'm experimenting with a simulation.
A person agent has an income amount and needs to decide how to best allocate their money when buying goods.
I have each good type as a sprite. They have Type, Cost and Priority variables.
Each sprite has 4 instances with different variables, representing 4 choices of the same good type.
The first always has a Cost of 0, and Type "none" and priority 1, to represent the option that a person agent doesn't want, or can't afford to buy any of that good.
The other instances are given different Priority values indicating how much the person prioritises or desires spending on that good, and different Cost values.
The idea is that these values, income, cost, priority, change through out the simulation and so people change their buying habits to maximise their spending to get the best mix of goods for their money.
The way i have it set up is;
//First i dismiss any goods that are already more expensive than the persons income.
all goods cost > person income then set boolean too_expesive true.
//now check each possible combination of goods and find the combination with the highest combined Priority and lowest Cost.
if boolean too_expesive = false
for each good A
if boolean too_expesive = false
for each good B
good A cost + good B cost <= persons income
if boolean too_expesive = false
for each good C
good A cost + good B cost + good C cost <= persons income
---- Set total cost = good A cost + good B cost + good C cost
---- Set total priority = good A priority * good B priority * good C priority
if total cost <= persons income
if total priority => best total priority
---- Set best total priority = total priority
---- Set chosen good A uid = good A uid
---- Set chosen good B uid = good B uid
---- Set chosen good C uid = good C uid
This method works well, but the more goods you add the more exponential the calculations become, example;
each good has 4 options times the number of goods types so with 3 good types that 4 x 4 x 4 = 64 combinations. 4 goods is 256, 5 goods 1024, 6 good types 4096 etc.
Now if you have lots of agents as well the whole things becomes too processor intensive.
Is there any other method or a better way of doing it that accomplishes the same thing?
Thanks!