Final results available
Introduction
After my previous KOTH with heavy themes (fantasy war, worldwide pandemic...), I'm back with a new lighthearted game. This time, you are facing off in a "board game-like" situation. A pile of upside down coins is placed at the center of a really big table, and you are determined to get your share of the loot!
Glossary
Coins: Tokens that can either be flipped or unflipped.
Unflipped: Coins placed on the table with their value pointing down. This is the default state of the coins.
Flipped: Coins placed on the table with their value pointing up.
Local: Refers to your pile of coins.
Global: Refers to the pile of coins at the center.
Principle
At the start of the game, each player starts with 0 points and 0 coins (flipped or unflipped). The game is turn-based. During their turn, players can take up to 3 actions interacting either with the pile of coins at the center of the table, their own pile of coins or with other players.
Play order is defined randomly at the start of the game. The order of the players in the argument list represents the turn order, and it goes from left to right in that list. "Next" and "Previous" refer respectively to "on the right in that list" and "on the left in that list" with a loop if you're the last of either side.
The game lasts for 50 rounds or until there are 0 coins at the center at the end of a player turn (meaning that you will finish your 3 actions even if the pile is empty after your first action, and you can put back coins to let the game continue). The starting number of global coins is defined randomly with this formula:
(2 ^ nb_players) + (nb_players * 10) - random(1 + (nb_players ^ 2))`
Each action will get you points (or make you lose some) and at the end of the game, each coin you have will be added to your points (-1 for unflipped, +2 for flipped). The player with the highest score wins.
The controller provides you with input via command arguments, and your program has to output via stdout.
Syntax
Input
Each time your program is called, it will receive arguments in this format:
Round;YourPlayerId;Coins;PlayerId_Points_Flipped_Unflipped;PlayerId_Points_Flipped_Unflipped;...
Rounds are 1-indexed.
Example input
6;2;52;1_20_3_12;0_-2_0_1;2_12_1_0
Here, you see it is the 6th round and you are player 2. There are 52 coins in the central pile. You have 12 points, 1 flipped coin and 0 unflipped coin. Points can be negative.
Output
You have to output three characters (no space, no separator), which each correspond to one action you'll take this turn. The order of the characters determine the order of the actions. You can output the same actions multiple times. In case there is not enough coins to complete your action, it will use the maximum of available coins and count points only for the coins used.
N
: Do Nothing
1
: Take 1 coin from the central pile [Effects: +1 local unflipped / -1 point / -1 global unflipped]
2
: Take 2 coins from the central pile [Effects: +2 local unflipped / -2 points / -2 global unflipped]
3
: Take 3 coins from the central pile [Effects: +3 local unflipped / -3 points / -3 global unflipped]
A
: Put back 1 coin from your pile [Effects: -1 local unflipped / +1 point / +1 global unflipped]
B
: Put back 2 coins from your pile [Effects: -2 local unflipped / +2 points / +2 global unflipped]
C
: Put back 3 coins from your pile [Effects: -3 local unflipped / +3 points / +3 global unflipped]
X
: Remove 1 coin from your pile [Effects: -1 local unflipped / 0 point]
Y
: Remove 2 coins from your pile [Effects: -2 local unflipped / 0 point]
Z
: Remove 3 coins from your pile [Effects: -3 local unflipped / 0 point]
R
: Rotate coins to previous player [Effects: -1 point per unflipped received, +2 points per flipped received / applies to all players]
T
: Rotate coins to next player [Effects: -1 point per unflipped received, +2 points per flipped received / applies to all players]
F
: Flip 1 coin [Effects: -1 local unflipped / +1 local flipped / +2 point]
U
: Unflip 1 coin [Effects: +1 local unflipped / -1 local flipped / -2 point]
Example output
2FF
: Takes two coins and flips two coin, scoring -2 + 2 + 2 = 2 points
If your output is incorrect, controller will assume NNN
.
Controller
You can find the controller on GitHub. It also contains two samplebots, written in Java.
To make it run, check out the project and open it in your Java IDE. The entry point in the main
method of the class Game
. Java 8 required.
To add bots, first you need either the compiled version for Java (.class files) or the sources for interpreted languages. Place them in the root folder of the project. Then, create a new Java class in the players
package (you can take example on the already existing bots). This class must implement Player
to override the method String getCmd()
. The String returned is the shell command to run your bots. You can for example make a Ruby bot work with this command : return "C:\Ruby\bin\ruby.exe MyBot.rb";
. Finally, add the bot in the players array at the top of the Game
class.
Rules
- Bots should not be written to beat or support specific other bots.
- Writing to files is allowed. Please write to"yoursubmissionname.txt", the folder will be emptied before a game starts. Other external resources are disallowed.
- Your submission has 1 second to respond.
- Provide commands to compile and run your submissions.
Supported Languages
I'll try and support every language, but it needs to be available online for free. Please provide instructions for installation if you're not using a "mainstream" language.
As of right now, I can run : Java 6-7-8, PHP, Ruby, Perl, Python 2-3, Lua, R, node.js, Haskell, Kotlin, C++ 11.
Final results
These are the results of 100 games (points are added up) :
1. BirdInTheHand: 1017790
2. Balance: 851428
3. SecondBest: 802316
4. Crook: 739080
5. Jim: 723440
6. Flipper: 613290
7. Wheeler: 585516
8. Oracle: 574916
9. SimpleBot: 543665
10. TraderBot: 538160
11. EgoisticalBot: 529567
12. RememberMe: 497513
13. PassiveBot: 494441
14. TheJanitor: 474069
15. GreedyRotation: 447057
16. Devil: 79212
17. Saboteur: 62240
Individual results of the games are available here : http://pasted.co/63f1e924 (with starting coins and number of rounds per game).
A bounty of 50 reputations is awarded to the winner : Bird In The Hand by Martin Büttner.
Thank you all for your participation, see you next KOTH~