When you have something that you want to sell or something you want to buy there's basically two options: to use money or to trade it with another item. This happens in real life and also in games where you have a trading system in place (an open market).
My question is: is there an optimal algorithm capable of receiving all of the available deals on the market and returning the best, optimal sequence of trades to get to item x that minimizes the overall cost?
I'll give you an example: Lets say that on the market we have this two tables, one for the people that want to trade/sell something, and one for the people that want to buy something:
Sellers:
Item I Have | Items I Want | (or) Price I Want |
---|---|---|
Item A | - | 140 |
Item A | - | 160 |
Item B | - | 50 |
Item C | Item A + Item B | 220 |
Item D | Item C | 240 |
Item E | Item A + Item D | 360 |
Item X | Item E | 360 |
Buyers:
Item I Want | Price I'll Pay |
---|---|
Item A | 150 |
Item B | 70 |
It has to take into consideration some of the following scenarios:
- Get to Item x only using money;
- Get to Item x using money and trades;
- Get to Item x using only trades;
- Consider several small trades before getting the final trade;
- The market is dynamic and the prices are not really "fixed". Meaning that some sellers/buyers are definitely buying/selling at prices bellow or up the average. The algorithm should thrive on this "misplaced" deals.
I don't know if I was able to make myself clear. I have a background in engineering and programming, and tried to find something that would tackle this problem but couldn't find much. I imagine that there's something to do with Greedy Algorithms, but I honestly don't know it there's something already proven to be good for this problem or if neural networks could do something for me here.
I know that this problem isn't trivial at all. In fact, there's a lot of people that make a living buying/selling items for profit like that. But they rely mostly on their knowhow and mining of opportunities that appear on the market.
I initially thought that I could transform this problem into a "traveling salesman" type of problem, where the cities are the items, and the distance between the cities is the price, and I would use some of the already established algorithms for this problem on it. But I don't know if it will work (if someone else already tried it).