Mathematical Modeling for Strategy Game Resources

Started by
4 comments, last by 8anOS 16 years, 9 months ago
Hello Everyone. Right, i am off to creating a proof of concept little game and i am in need of some mathematical models for the "evolution" (in time) of specific resources in a game. For example, imagine that this is a stock market game. I would need a model that accepts time (and perhaps the values of other stocks, without the user knowing which) and it would return the value of that one stock. Similar scenarios exist in other cases where the users gameplay must respond to changes set by the computer. Before i go forward and implement whatever comes out of my head i thought i might ask if there is anything already available. Since i have not done anything similar before, i am lacking the relevant terminology so my google queries return very general results. I took a look at one game that has this kind of concept in it's heart, the game was Dopewars, but unfortunately, prices there are selected at random at each time step. So this means that the outcome of the game depends only on each transaction (buy or sell according to the values on offer at THAT time in the game) and not on previous transactions. In other words....after some time you are getting bored because nothing exciting happens that responds to your way of playing. I am guessing something like a set of coupled equations.....Anyway....Is there anything like this with a proper name available out there? :-) Looking forward to hearing from you
Advertisement
I've played some online horse betting, and, each horse has an initial odd, then as people start betting, the odds change depending on who's bettings on who, so the more bets the horse has, the lower the payout is.

I dont know if thats how the stock market works, but I thought it was a cool concept
It is not clear what you are trying to model. If you are trying to model prices of resources, then it is probably easiest to just set the prices using a random walk. You can do something much more sophisticated by simulating an entire economy, and prices are just part of the simulation state. You could do something in between.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Hello

@ligh: Yeah that's one of the interactions i am looking for.

@JohnBolton:
Yes, it is prices of resources, i thought i made this clear. Anyway, I am not sure if a random walk is the best thing. What i had in mind was to model each price as a sinusoid of different amplitude (price) and phase (in the order of days).

Along with the sinusoid i would add some noise to model the risk of buying such a share. So far things are manageable. The problem starts when you try to model the interactions....Something like what ligh is saying for example. When a lot of users buy a specific resource it's price should go lower and lower. Maybe the sinusoid approach is too simplistic for this...I don't know...that's why i am asking :-).......

Ultimately, i may go for a "filtered" random walk if nothing else works out. :-/

//You can do something much more sophisticated by simulating an entire economy, and prices are just part of the simulation state.

Any references towards such work?
An interesting problem..

Let's see, there is the factor of supply and demand.

If you were to base the price of something based only on this, the equation would be price = intrinsic value * scarcity, where instrinsic value is some value that you give that is a fundamental value of the object and scarcity is how rare it is.

But that is an oversimplifcation. Supply and demand comes from sellers and buyers trying to maximize profit or utility. The buyer will try to buy the most at the lowest price, while the seller will try to sell the most quantity at the highest price. As the seller increases his price, less people will want to buy his stuff but he will be able to sell them at a higher price. As he lowers his price people will want to buy more, so even though the profit per unit sold is less, the number of units sold increases. There is also the effect of other sellers of the same goods, which creates a competition because people will want to buy from the one that offers the product for less.

Here's an algorithm I thought of how to try to get the most profit for a seller:

Loop 1:
> If Total Profit increased from last time:
> > Increase Price Again
> > Do Loop 1 Again
> Otherwise if Total Profit decrease from last time:
> > Decrease the Price
> > Switch to Loop #2

Loop 2:
> If Total Profit increased from last time:
> > Decrease Price Again
> > Do Loop 2 again
> Otherwise if Total Profit decreased from last time:
> > Increase the Price
> > Switch to loop 1

When it comes to stock there are different types of value associated with it.

Here is a good guide to stock markets: http://money.howstuffworks.com/stock.htm


There is the asset value / book value: If you have a restaurant, you can sell the building, the equipment and everything else. This is the asset value / book value.

The restaurant also has value based on how much money it generates over time.

And there is the stock price.


To calculate the asset value / book value, you sum up the prices of all the business's property.

The amount of income the company generates depends on supply on demand like I detailed above. There is also the static cost that doesn't change of having to hire workers to operate the business.

The stock price is also a matter of trying to maximize profits also. The seller of the stock wants to sell the stock at the highest price, while the buyer wants to get the most at the lowest price that will have the greatest rate of return for him (income).


I hope that helped.
Hello

Thanks for your reply polyfrag.

I appreciate the post, very informative and detailed.
Initially i had incorporated the Supply/demand ratio as the coefficient for the amplitude of the sinusoid i am discussing above but i quickly realised that the stock fluctuation is the result of the ratio and not by assuming that there WILL be some fluctuation present, no matter what.

The loops you are providing touch upon AI a bit (Maybe these could drive the virtual players behaviour) and i was more looking for something like a formula...But i mean if that's what it takes, that's what it takes. Also, the terminology was great, i found out that some parameters (such as the asset value) would make the gameplay a bit more interesting.

After the sinusoids (and before i read the latest posts :-) ) i was looking at coupled state equations. These are relatively simple and also give me the ability to control the coupling between two values. So one stock value fluctuating can affect another which happens in reality.

In this approach, the transactions are modelled as impulses, the impulses pass through an integrator. The integration is proportional to the current price of the stock. So in the output you get a time series that goes up and down depending on whether it had many transactions or not. Now, each stock is such an integrator but there is also some "leak" introduced from one stock to another....So when one goes up it can be driving other(s) up or pushing them down. A bit like if the oil price is fluctuating you can see other prices co-varying as well...

Maybe i can fit supply and demand in this........i just hope i am not going too far on this aspect :-)

Many thanks again

This topic is closed to new replies.

Advertisement