N
N
nikremy2021-08-14 01:27:30
Algorithms
nikremy, 2021-08-14 01:27:30

How to create a formula for the exchange rate of your own fictitious currency?

I am creating my own small project, a game, it already has one stable currency. The bottom line is that I want to add a second currency, floating, regulated by a certain formula embedded in the script. That is, users will perform certain operations with the currency, buy, sell it, and depending on this, guided by the formula, the rate will automatically change. It turns out that the exchange rate should be regulated by the ratio of supply and demand. I read a lot about changes in the exchange rate, exchanges, trading, rummaged through everything on the Internet, but so far I have not found anything and I have no idea what such a formula could look like. The project being created is multi-user, so the rate will be the same for all players and will depend on each action of the players with the currency. Can anyone suggest the basic principles of such an algorithm,

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2021-08-14
@nikremy

The simplest is to simply allow players to buy and sell currency X at any price for currency Y.
This will be supply and demand regulation.
If you still need to fix the rate according to the game rules, then you can calculate the sum of the currency of all players. And just match them up.
So if X currencies are 1000 units in the game world, and Y currencies are 2000 units,
then the rate will be: 1 unit. X = 2 units Y.
That is, it turns out that the currency X is rarer, therefore more expensive. And then the course is determined by the ratio. Here is the formula.
You can add all sorts of tricks. For example, if you pour 100,000 X into the game, then the rate changes not abruptly, but smoothly, and not necessarily linearly.
Also, the rate may be subject to small jumps from some game events, announcements.
Of course, the usefulness of the currency itself (what can be bought with it) is determined subjectively by the players. So if some currency is conditionally useless, then the exchange rate, in theory, should be different. Well, what did you want when regulating the game rules? If you want fully market relations, then the solution in the first paragraph is to give the players complete freedom to choose their own course.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question