Economy is flourishing in the great Kingdom of Pipysigea [pee-pee-see-gee-ah]
, since the bandits have been driven away by the King's army.
Especially, many people have decided to make trade their... trade, and have become merchants. You were one of them.
You used most of your life's savings to purchase a good wagon and some animals of your choice. (Note: it can't be dragons. Sorry.)
Unfortunately, you have just moved to Pipysigea from far away, attracted by the promises of wealth and security,
so you don't really know much about the Kingdom: you have just bought a map, so you know the names of the cities
and where they are, but you don't really know how long it's going to take to travel from one city to another.
So what is your goal? Being a merchant, you'll want to travel from city to city to get an idea of what good they want to buy
and what goods they sell.
There will be a total of X kinds of goods in the Kingdom, and each city will be looking to buy 3 kinds and will
be selling 3 kinds of goods. You will need to find out whether their prices are good for you:
for example, the city of Puzzleon might be selling iron for 4 coins per unit and buying bread for 1 coin per unit,
and the city of Stackapor might be selling wool for 2 coins per unit and buying iron for 5 coins per unit: in this case,
it would be profitable to buy iron from Puzzleon and then travel to Stackapor to sell it.
But beware: trade is ever-changing, and prices are going to change based on what you and other merchants do.
If you keep selling iron in Stackapor over and over, their need for it will soon start lowering, and
so will the price they offer for that good. Similarily, if you buy a lot of iron from Puzzleon, the quantity at their disposal
will lower and the amount of coins they want for it will start getting higher, until they run out of iron and stop selling it.
Beware, also, of taxes! The arch-enemy of any merchant. Every seven days (= turns) you are going to be taxed,
based on your current wealth, which is measured by actual coins and amount of goods in your wagon.
After all, his majesty King Golfus II deserves compensation for ridding the Kingdom of bandits and letting it prosper. And also for having
established free market, of course.
During your travels, you will eventually encounter fellow (or rival, depending on your attitude) merchants,
with whom you can trade just like you can with cities. You can decide to keep walking or to stop and trade.
Every time this happens, you can tell them 1 good you are willing to buy (or none) and the price you offer,
and the same with 1 good you are willing to sell.
The other merchant will do the same. Then, you can respond by accepting or declining both of their proposals or just one.
They will do the same with your proposals. Once all this is done with, you can resume your travel.
You lose if you go bankrupt: that happens when the time comes to pay taxes and you don't have enough coins.
You automatically win if all other merchants have gone bankrupt.
The game ends after XXX turns, and the winner will be the merchant with the most coins.
Rules
Antitrust Law: a merchant cannot be made specifically to support another merchant. (To help ensure this, merchants can never know the name of the merchant they are trading with)
Fair Trade: a merchant cannot be made specifically to harm the trade of another merchant.
Fair Code: King Golfus II is the one and only ruler, and a merchant may not interfere with the law (also known as "The Controller")
Technicalities
You will be provided with a list of randomly generated cities (e.g. 10 to 15) with their coordinates on the map (a simple cartesian plan with X and Y values).
The terrain is assumed to be pretty much the same overall, so travel times are based only on distance (initially I thought about giving specific travel costs - e.g. difficulty of road, maybe mountainous or muddy or whatever - to each "link", unbeknownst to the merchant, but felt like it would have complicated things too much. If you think it would be a nice addition, feel free to say it in the comments!)
Every city has a randomly generated list of 3 items to sell and 3 items to buy. The quantity they have available of each item they sell is also randomly generated, as well as the prices of all 6 kinds.
Obviously, if a city sells iron they won't also be looking to buy it.
Each merchant can only be in one of these three positions:
in a city
on the way from one city to another
midway between two cities, stopped to trade with another merchant
The game proceeds in rounds, which are made of each player's turn. Every round, the turn order is changed
(To be decided: poorest players first or randomly generated?)
In their turn, each player can do one of these things:
trade with the city, if they are in a city
trade with a merchant, if they have encountered a merchant on the road
resume travelling to the other city, if they have encountered a merchant
start travelling to another city
If, in the previous turn, the player started travelling to another city, at the start of this turn he'll either
be notified that they have encountered a merchant, and can decide whether to trade or keep walking
be notified that they have reached the other city, and receive the information about it (its name and its trade prices)
If the player encounters a merchant and decides to keep travelling instead of trading, they will reach the city they were travelling
to and will still be able to act (= trade with the city or move again)
If, instead, the player trades with the merchant, their turn is considered over and will be able to move again on their next turn (note: since they will be midway between two cities, they will have the chance to decide which of the two to travel to, in case they want to change their previous "travel decision")
Taxation happens at the start of the player's turn, if it is the taxation round (= once every 7 rounds)
Note: the player can't "talk" to the other merchant unless they both
stop to trade, so if the player decides to keep travelling they won't
know the other merchant's prices. (I'm not sure about this rule, so
please give me feedback :) would it be more sensible to know the other
merchant's prices before having to decide whether to stop?)
Code
I haven't started coding the controller yet, but I was thinking about using Node.js (since javascript is my favourite language, and I don't have tools to use Java and would prefer to avoid having to install stuff) so that bots can be submitted in the form of node modules (either written in javascript or with a javascript wrapper like most low-level node modules)
Note that your bot will be able to save data into a .txt file.
Please give me feedback if you want to suggest a different approach. :)