Traders for life
In this game, each bot will own a factory that accepts
N products, and can produce
M of a different product, denoted by
#,Input->#,Output. There are 3 products
C and three types of factories,
C->A. Each factory of the same type will input the same number of products, and outputs the same number of products. Each both will be assigned a factory type, which can be queried (as described below) Producing
A->B->C->A will increase the total amount of
Example: Bot 1's factory is
5A->2B, and starts with 500A. Bot 2's factory is
3B->7C and starts with 300B. Bot 3's factory is
5C->6A and starts with 500C.
You start with
$1000, and your goal is to increase that money. Each turn you will produce, buy, and then sell in that order.
To produce you will pass in the number of inputs. If you pass in more inputs than you currently have in inventory, then you will only produce what you have in inventory. If the amount input isn't divisible, then a remainder of your input will remain which couldn't be produced.
To sell, you will pass the type you want to sell, the price, and the max amount you will sell. To buy, you will pass the type you want to buy, the max you will pay for it, and the max amount you will buy. The buyer with the highest max price will then be paired up with the seller with the highest price that is under the buyer's price. The buyer will then buy as many products as possible at the seller's price. If the seller reaches his maximum of products to sell, then the buyer will continue to buy from the next seller. If the buyer reaches his maximum of products to buy, then the seller will continue to sell his product to the buyer with the next highest maximum price.
All products and dollar amounts are integers (there are no cents or partial products).
There will be 3 copies of each bot, each assigned to a different factory. These bots cannot communicate with each other or with any other bot.
The player with the most money across all of their bots after 500 rounds wins.
Any language can be used, and input/output will come through STDIO. If you wanted to produce 34 of your product, buy 10 of product A at the price $5 and sell 20 of product
B at the price of $6, then you would pass in
P,34 B,A,10,5 S,B,20,6.
At any time you can pass in:
I to query your inventory, which will return something like
5A 10B 8C
M to query the amount of money you have
T to query your history of trades. It will be a space delimited list of trades. Each trade will look like like
B,1275,A,49,90 (You bought from player #1275 49 of product
A at the price of $90) or
S,385,B,29,30 (You sold to player #385 29 of product
B at the price of $30).
R to query the number of rounds left
F to query your factory type. It will return something like