The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game. If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program.
Price refers to the how much people are trading the stock for, while Value refers to the amount the stock is worth at the end of the game.
Each player starts with 1000 of each stock, and 0 relative net worth. Each stock has a secret value, and your score at the end of the game is (stockValue for each ownedStock) + netWorth
. Your net worth can be negative. In an N-player game, there are N stocks.
Steps:
The game follows the following steps:
- You are given the secret value of a single stock.
- You make an offer to sell X of Y stock for $Z
- All players are given the offers, and each may choose one to accept
- All players are informed of accepted offers
- Go back to step 2
Each of the steps are given in detail below:
void secretValue(int stockType, int value)
:- The value you learn is not revealed to any other player.
- The value is between
0
and1000
- Low values are more like to occur than high values (squared uniform distribution)
Offer makeOffer(List<Stock> currentStock)
- You can return
null
to make no offer.
- You can return
Offer acceptOffer(List<Offer> offers)
- You can return
null
to accept none of them - If there are no available offers, this will not be called
- If you accept, your net worth goes down by $Z (can go negative) and receive X of Y stock. The opposite occurs with the seller.
- If you accept an offer, the exchange will occur immediately, and the offer will be removed so additional players cannot accept it.
- You can return
void acceptedOffers(List<Offer> offers)
- Includes your accepted offers as well
Static variables or writing to files is not allowed. (No persistent data from game to game) Non-serious contenders are allowed.
Interfaces:
public final class Stock {
public Stock(int stockType, int amount);
public int getType();
public int getAmount();
public Stock minus(Stock other);
public Stock plus(Stock other);
public Stock minus(int amount);
public Stock plus(int amount);
public Stock setAmount(int amount);
}
public class Offer {
public Offer(Stock offer, int payment);
public Stock getOffer();
public int getPayment();
}
Non-Java submissions:
- All calls consist of two lines: The first line is the function being called:
SecretValue
,MakeOffer
,AcceptOffer
,AcceptedOffers
,SetRandom
, and the second line containing the actual data. - Stocks are formatted with a
:
delimiter:stockType:stockAmount
. - Offers are formatted with a
@
delimiter:offer@price
- Lists are formatted with a
;
delimiter SecretValue
is formatted with a:
delimiter:stockType:value
RandomSeed
is used to make your submission deterministic. If your submission uses randomness, please use the integer value passed as the seed!- All function calls need a response. If the response is
null
orvoid
, return an empty string. - Please include a
command.txt
that gives the command line arguments to run your submission
Scoring
Games consisting of 1000 turns will be run multiple times. Players will be scored according to the ELO system, and paired with players of similar skill levels. The player with the highest final ELO score wins! (I've modified the system so that each game, ELO scores are updated for each player pairing)
The controller includes an autodownloader, so please start your submission with a header: Name, Language
. If your submission is not in Java, each code block should start with the name of the file. (excluding the command file, which should be the first block in your post)
Running
There are 2 ways to run this project:
Download the source code, compile and run. You can find the source on Github. Run
git clone --recursive https://github.com/nathanmerrill/StockExchange.git
Download the JAR executable. Submissions should be placed in your current working directory in the
/submissions
folder. You can download just the JAR, just the submissions, or both
Pass in run
to run the project (default option), or pass in download
to download all submissions so far from this question.
Scoreboard
1. 1308.1220497323848 Cheater
2. 1242.0333695640356 InsideTrader
3. 1158.3662658295411 UncleScrooge
4. 1113.8344000358493 BlackMarket
5. 1051.8370015258993 DartMonkey
6. 983.0545446731494 WarGamer
7. 939.457423938002 Spammer
8. 901.4372529538886 DumbBot
9. 859.0519326039137 ShutUpAndTakeMyMoney
10. 852.9448222849587 VincentKasuga
11. 718.2112067329083 Profiteer