开发者

I would like to create stock-market on my RPG game. Any ideas on formulas?

I have no idea what formulas I should use开发者_如何学C to create stock-market for my players that they could play it. I use php+mysql. Maybe you can throw any good ideas? I'll be grateful.


The simplest (but not necessarily the best) way of implementing fluctuation in stock prices is by using a random walk, since it has been hypothesised that stock prices can be modelled using such a process. See http://en.wikipedia.org/wiki/Random_walk_hypothesis

So, dp = rand(-1,1) * p * dt where p is the stock price and dt is the time elapsed (probably in days).


Assuming this is multiplayer, in addition to random walk, some consideration of supply and demand can be taken into account. If more shares are bought than sold of a particular stock over a period, its value should go up slightly, and vice-versa. This will increase volatility and perhaps make this portion of the game more exciting.


If you're allowing buying and selling between players (and assuming you've already created the storage part), you just need to expose four methods and let the players define the economy:

Bid (stock, price) 
Offer (stock, price)   
Buy (stock, price)    
Sell (stock, price)

If the stocks already exist in your game, then you just need to let the players define what they want for theirs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜