🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Figuring out economic problems

Started by
36 comments, last by leopardpm 12 years, 1 month ago

I would assume Dave has some good ideas around how to implement this in a video game.

Certainly... but I read more books on economics, psychology, and math than I do on games. *shrug*


In the real world price dynamics emerge because people are agreeing on prices before anything actually changes hands. In other words, oil is sold before it's even pumped from the ground. When you are told that 'the price of oil is $xxx a barrel' what you're getting is an estimate based on contractual agreements for a future delivery. Think of it as an auction for something that might not actually exist. :)


In terms of a video game: If you have shop keepers, you might want to keep a global commodities index running, and have the shop keeper essentially act as a broker that gets him/her a premium (a function of the index price * volatility/risk * profit expectation). If you assigned production of certain regions of the world, and adjust output/cost based on how much combat (or other type of events) occures in those areas then you provide a way for player dynamics to indirectly affect global prices.

That's a great point. People in the real world bitch about how gas prices at the pump increase immediately when the price of oil increases. "But you didn't pay that much for this gasoline! How come you won't sell it at the price you paid for it?" The simple answer is, "because I need to be able to afford to buy more to replace it."

Therefore, in the shopkeeper example, you should not use of what the shopkeeper paid for it. You need to calculate what he would have to pay for it if he wanted to replace his supply. Doing it the other way punishes him for buying a huge inventory when the price is low... which is economics rule #1 (#2 being "sell high").

However, there is a reason to keep track of what the shopkeeper paid... and that is that he may not want to sell at a certain price. For example, if he has an inventory of A, and the price of A drops below what he paid (in cost, effort, etc.) he may find it beneficial to sit on his inventory and hope the price goes back up. Why sell at a loss? (Of course, then you get into a classic situation where the price continues to drop and he must decide to cut his losses by selling... but that's why economics is so much fun!)


Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Advertisement
yes, it is a common misconception of the average person to assume that prices are 'determined' by costs, where actually it is backwards: prices determine costs. The reason a particular apple is priced at $1 is NOT because it costs $0.50 to pay the laborer to pick it and the owner wants to make a profit, but rather the laborer is paid $0.50 BECAUSE the apple is only worth $1 on the market. And, really, its not 'prices' as if they are set, its 'valuations'.

Which brings us back around to, what I see as a major flaw in my method for choosing which task to attempt in order to satisfy a need: If I base the calculations on 'labor type and time', then I have set into the system an economically fraudulent assumption - Marx's Labor Theory of Value. and it would definitely be the ruin of all the world over, or at least have a world of 'ants' instead of simulating people to some capacity....

I am also toying with the idea of not forcing a monetary system and seeing if one springs forth - but the ability to 'spring forth' involves an awareness that I don't think I can code into these agents. But, maybe if I focus on just commodity valuations: ie 10 fish = 2 ore, 20 wheat = 10 fish, 10 wheat = 1 ore, etc then perhaps a certain commodity will spring up as being 'the easiest' in each locality as a money base (fish=money in fish town, ore=money in ore town... or perhaps it ends up being reversed where ore=money in fish town and fish=money in ore town because the units are more valuable respectively in those particular locals. I think I will push such dreaming off until I get to that bridge, and keep focusing on the individual details, the small tasks, and see what happens...

I have been researching this idea for over a year, and my travels have taken me to economic simulators that economists have tried to create... but they almost always use a top-down approach, central planned, without even thinking about it.... they are trying to derive 'formulas' which model human behavior instead of focusing on the individual differences between human actors in an economic setting. I think their approach is a fool's errand. You can't calculate a person's ever-changing desire. Though I guess that is exactly what I am trying to do too!!! LOL!

we shall see.
LOL! I just experienced my first 'emergent' behavior - not really, but it was 'fun':

I had been playing around with my sim (as it were) and started adding the rudimentary bits for 'digging' (I am thinking that to get 'ore' one needs to do a bit of actual excavation to get to it), but figured that since I hadn't put in the hooks yet to garner anything useful to the agents (they don't know what ore is yet so have no reason in their thinking to dig for it) then I wouldn't see any effect. Well, after playing the sim a few times (its fun to watch), I noticed every once and awhile a dude would start digging like crazy! I was like, "WTF!" . After clicking on him and trying to figure out the 'error' of my ways... it turns out that I had forgotten that I put 'gardening' in as one of the things that agents can 'like to do' when they are 'relaxing' - the clue I had was that all the 'diggers' were on the LAZY side of their personality traits - (I am trying to incorporate the Disutility of Labor into the agents so that they will, if nothing too pressing is needed, choose to do something they each consider 'fun' - reading, gardening, napping, playing games (hopefully they will go to the local tavern and play some 'virtual chess' or gambling games at some point)), etc. Well, one of the things about 'gardening' was they would 'like' dirt... and the action of digging produces... dirt! Very fun, the thought of these little dudes digging around their world for pleasure because they liked 'dirt'!

oh well, the episode points to a few different things I learned - as more and more game objects and possible actions are introduced, the complexity becomes exponential... alot more probability for interesting behavior... and alot more possibility for 'strange' unnatural behavior (judged by standard human perspective, not from the perspective of the agents themselves!).

Yeah! AI is Fun!
BTW - has anyone else been amazed at the AI used in the game Dwarf Fortress? That is one of my 'examples' as far as trying to get agents to do interesting and yet 'natural' things that kinda make sense from an outsiders perspective.
sorry about the multiple posts...

DaveMark, I just ordered your book (mainly because I went ahead and just finished reading the first chapter available on Amazon, and secondly, I read an interaction between you and another somewhere else in this forum and I appreciated the advice you gave (understanding their particular programming/AI ability: novice) and how you dealt with an adversarial poster that considered your advice 'wrong' - which it wasn't.

Now I gotta wait 5 days for the book to get here...

meanwhile, are there any other books you might recommend? What about Steve Rabin "AI Wisdom" et al?

sorry about the multiple posts...

DaveMark, I just ordered your book (mainly because I went ahead and just finished reading the first chapter available on Amazon, and secondly, I read an interaction between you and another somewhere else in this forum and I appreciated the advice you gave (understanding their particular programming/AI ability: novice) and how you dealt with an adversarial poster that considered your advice 'wrong' - which it wasn't.

Thank you for the order and the compliment. I hope the book helps.

Now I gotta wait 5 days for the book to get here...
That part I can't help with. :-(

meanwhile, are there any other books you might recommend? What about Steve Rabin "AI Wisdom" et al?

See the pinned topic on this forum. Note that the AI Wisdom books are a collection of articles between 10-18 pages from various authors. (Full disclosure, I wrote for #4.) Therefore, it isn't as good a foundation but more tips and tricks. Same with the Gems books (I wrote for #8).


Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"


'LorenzoGatti' said:
Of course there might be different available jobs; hunting and cooking one rabbit might be less unpleasant than 4 hours of rabbit hunting, but more unpleasant than a 2% quota of a quick $1000 armed robbery.

Remember to include the potential for success and failure – and the ramifications of each. For example, what is the risk-reward ratio of the armed robbery? If the penalty is negligible, then give it a shot. If the penalty far outweighs the gain, then pause. But what is the potential for getting caught? If the penalty is death, but you have a 0.001% of getting caught, it doesn't matter. Fun with math, folks!

I'm of course referring to expected value, which in the case of rabbit hunting can be easily modeled as a random variable (time needed to catch one rabbit) or two (time needed to find a rabbit, and time needed to kill it) but in the case of a robbery requires a rather complex weighted tree of outcomes and random variables (successful completion, losing the loot to run away, being caught, kinds of penalty if caught, loot obtained if not caught, amount of fine if fined, length of vacation if jailed, choice of prison if jailed...).

Omae Wa Mou Shindeiru

It’s an interesting project and one I’ve toyed with myself a few times.

One factor you can include in your decision making is the value people put on their time. This is normally affected by a person’s earning potential, circumstances, and other values but generally we all have an internal figure which says how much our time is worth.

Take the following scenario.

An agent has 3 ways to get to work. 1) Walking costs nothing but takes 2 hours. 2) Taking the bus costs $2 takes 40 minutes and only leaves at set times. Or 3) take a taxi which costs $12 and takes 10 minutes.

The option to take in the case would be based on the agent’s current funds and the value they put on their time.

An agent who has a value of $10 an hour will pick option 2 but if the agent has a value of $100 an hour they will go for option 3.

The same would apply to your scenario of fishing, picking berries, and buying from the market, but in that case you’d also want to adjust the result by the agent’s likes. I’d probably make likes and dislikes magnifiers in this case. If an agent likes fish(x2) and hates berries (x4) then he more or less has to be standing next to the berry bush and starving before they would choose them over going fishing.

Then of course there is whole other level magnitude you can look at once you everything working and that’s the interplay between short term goals and long term plans. For instance in my getting to work example how would the short term goal change if you wanted to consider the long term plan of thinking of buying a car?


'IADaveMark' said:

'LorenzoGatti' said:
Of course there might be different available jobs; hunting and cooking one rabbit might be less unpleasant than 4 hours of rabbit hunting, but more unpleasant than a 2% quota of a quick $1000 armed robbery.

Remember to include the potential for success and failure – and the ramifications of each. For example, what is the risk-reward ratio of the armed robbery? If the penalty is negligible, then give it a shot. If the penalty far outweighs the gain, then pause. But what is the potential for getting caught? If the penalty is death, but you have a 0.001% of getting caught, it doesn't matter. Fun with math, folks!

I'm of course referring to expected value, which in the case of rabbit hunting can be easily modeled as a random variable (time needed to catch one rabbit) or two (time needed to find a rabbit, and time needed to kill it) but in the case of a robbery requires a rather complex weighted tree of outcomes and random variables (successful completion, losing the loot to run away, being caught, kinds of penalty if caught, loot obtained if not caught, amount of fine if fined, length of vacation if jailed, choice of prison if jailed…).


When I have looked at this aspect with my limited knowledge of AI, my first instinct was apply the following formula:

(1) quick estimate based on known factors (distance to goal, amount of time to work it, distance back, etc). Remember, the 'goal' might be 'Build a shelter', of which one part will be gather the necessary resources - BUT not just gather them, also transport them to the desired location of where the shelter is to be built. So need to include the 'distance back' figure.

(2) Check a 'memory' table (don't know how to do this efficiently yet - need to learn) of previous attempts of achieving each part of the goal.

the #2 (check memory) was an attempt to estimate tasks which had a random time component and random 'danger' component - for instance: hunting rabbits! If agent goes out hunting rabbits, and spends x time looking (its variable), then y time actually trying to kill the thing, then another z time traveling back home... then next time he can use the previous total time as a weighted average for a better guestimate. This method will also allow for agents to factor into a decision if a task is too dangerous or not. In my thoughts, I wanted to accomplish two things here: (1) be able to predict an outcome roughly if never attempted, (2) to better predict an outcome if done before, and have this prediction change when outside influences affect the task (for instance, the first 10 times he goes out to hunt rabbits, it takes a running average of 100 turns, but, he (and possibly others) have now decimated the local rabbit population and it takes longer and longer to find rabbits to hunt - or, dangerous entities have moved into the area and rabbit hunting becomes more risky as time wears on): so each agent needs to have a way to constantly adjust their predictions to reflect a dynamic environment and the actions of other agents (and non-agents: players!)

An agent who has a value of $10 an hour will pick option 2 but if the agent has a value of $100 an hour they will go for option 3.

The same would apply to your scenario of fishing, picking berries, and buying from the market, but in that case you’d also want to adjust the result by the agent’s likes. I’d probably make likes and dislikes magnifiers in this case. If an agent likes fish(x2) and hates berries (x4) then he more or less has to be standing next to the berry bush and starving before they would choose them over going fishing.
the 'time value' thing is relatiely easy to calculate EXCEPT for determining the 'unit' of value to use (this is, in essence, the money unit) - I can randomly choose a unit of any commodity (berries, ore, wood, chairs, sandals, etc) but need to figure out a way to actually make a choice between using one type of unit vs another based on logical agent rational - the same determination for what commodity to use for money: (1) needs not to depreciate over time (2) easily divisible (3) easy to transport and carry (4) recognized as valuable by others (5) and I forgot the 5th quality of money that humans have looked for in the past.... How do I program an agent to weigh these abstract qualities of each type of commodity (potential money)? Don't know yet - its a problem that may just need to be solved by brute force (ie: introduce GOLD and force all agents to calculate in those terrms)
That is true and it’ll depend on what you are trying to achieve whether you want money to exist as entity in of itself or design your sim to have an emergent monetary system.



Then again rather then a commodity based economic system you could always have a labour based one. An agent only has 1440 minutes of “work” available each day how much a unit of work is worthy would very from agent to agent, and would influence their decisions. But again you’d need mechanism of evaluating the results of a task against the cost of doing that task in terms of that agents own work value. This would require some kind of community knowledge and an assessment system.



So that you can evaluate cases such as you have a fisherman and lumberjack. If the fisherman needs wood is it better for him to spend an hour gathering the wood himself or spend and hour fishing and then trade some fish to the lumberjack for the wood.











This topic is closed to new replies.

Advertisement