I am new at game development and am now facing the problem for a market price algorithm in a turn based game. What I try to achieve:
- the market starts with fixed bidding and asking prices for one piece of goods. To keep it simple the minimum value is 1, the maximum 20
- if the user buys/sells the same goods in too large quantities in a certain amount of turns, the prices should rise/drop; simple supply and demand logic. The maximum amount of a goods per transaction is 100
- if the user doesn't trade that good for a few turns, it should adjust the price in the other direction
- there are certain type of goods that can be "easily" produced by the player and are thus sold and some that are harder to get by and are usually bought.
- the market can sell each good infinitely and would also buy everything, so it has no stock to take into account.
What I tried and didn't work:
- if the accumulated quantity of bought/sold good reaches 500 (I use negative values for buying) the price rises or drops by 1 respectively
- to factor the turns into it, I thought I just reduce the accumulated value by 10 each turn and then adjust the price if it reaches 0 again. This has one big flaw, as you can easily cheat by just selling a small amount, wait a few turns and the price will rise; repeat until the price reaches the maximum of 20.
Any simple ideas on how to fix this?
ps. I hope this is an appropriate question to ask here