Background
The game of Morra is a simple game. In the "original" version, several players simultaneously throw out a number 0-5 with their hands while guessing the total sum of everyone's hands. The version I'll use here has been modified to increase the potential for non-trivial strategy, and it is described below:
- There are two players.
- Like in rock-paper-scissors, the players move simultaneously.
- Each turn, each player chooses a number 0-5 and also guesses their opponents choice of 0-5. This means that two numbers are output each turn. To clarify, both numbers output should be in the range 0-5, inclusive.
- If you guess your opponent's choice correctly but your opponent did not guess correctly, you win a certain number of points equal to the sum of the two numbers played. For example, if the numbers played were 3 and 5, a correct guess would be worth 8 points.
- If both or neither players guess correctly, no points are awarded.
- The person with the most points after 1000 rounds wins that game.
The Tournament
The tournament will be done in a round-robin style and will be run by creating each possible pairing of contestant. For each victory, the contestant gains 2 victory points. Each tie results in 1 victory point. No victory points are gained for a loss.
Intuitively, the winner of the tournament shall be the contestant with the most victory points against others.
How to Enter
There will be two methods of submitting bots to compete. The first, and much preferred method, is to implement a Java interface supplied by the controller. The second method is to write an independent program.
Let's cover the Java method first. The interface you will need to implement is Player
and it defines two methods: public String getName()
identifies your bot, and public int[] getMove(String[] args)
takes args
as an array of six strings, mychoices myguesses myscore opponentchoices opponentguesses opponentscore
. An example is the following:
042 045 0 324 432 6
This means that I chose 0 on the first round and guessed that my opponent was going to throw a 0. My opponent threw a 3 and guessed I would throw a 4. In the third round, my opponent made the correct guess that I would throw a 2, meaning that he gains 2+4=6 points.
Your method will return an array of two integers, which are your choice and guess, respectively. An example is {4,2}
for a choice of 4 and a guess of 2.
Here is an example of a complete Java bot written as a method. If you want, your submission only has to include what's going in the getMove
method.
import java.util.Random;
/**
* A simple example Morra bot to get you started.
*/
public class ExampleBot implements Player
{
public String getName()
{
return "ExampleBot";
}
public int[] getMove(String [] args)
{
//easiest way I know to break down to create a move history
//(just contains their throw history)
char[] theirThrowsC = args[3].toCharArray();
int[] theirThrows = new int[theirThrowsC.length];
for(int i = 0; i < theirThrowsC.length; i++)
{
theirThrows[i] = Integer.parseInt(Character.toString(theirThrowsC[i]));
}
//get my score
int myScore = Integer.parseInt(args[2]);
Random r = new Random();
int guess = r.nextInt(6);
if(theirThrows.length > 0)
{
guess = theirThrows[theirThrows.length-1];
}
//throws a random number, guesses what they threw last
return new int[] {r.nextInt(6),guess};
}
public static int otherMethod(int example) //you can write additional static methods
{
return 0;
}
}
As an Independent Program
I am currently limited in my support of additional languages. Besides Java, I can accept programs written in Python 3.4, Perl 5, or Ruby 2.1.5. If there is a language that several people seem to want, I'll do my best to add it.
The input to your program will be arguments on the command line. It could look like this:
perl awesomebot.plx 042 045 0 324 432 6
The output of your program should be your choice followed by your guess, each followed by whitespace.
Please include in your answer the exact command needed to run it. Keep in mind that I'm running Windows 8.1.
Extra Rules
Saving State and Timeouts
Your program will be allowed to create one text file in the local directory, where you can store information. This information will kept throughout the tournament but deleted afterwards. Give the file a name I can identify.
There is a time limit of 500 milliseconds for your code to respond. Failure to respond in the time limit (or giving an invalid move) will result in forfeiture of that particular match. Java submissions currently have a passive timeout (which I may upgrade to active), whereas non-Java submissions have an active timeout where their process is terminated after 500 milliseconds.
More submission rules
- You are allowed multiple submissions, as long as they abide by the rules and don't tag-team.
- Each entry must be unique. You can't make an exact copy of another bot's logic in a different language.
- The bots cannot interact with each other (to form a team of any sort).
- You can't use the logic of the other bots inside of your bot to, say, identify your competitor and predict its actions. You can, of course, try to determine the strategy of your opponent.
- Don't attempt to mess with the controller, other contestants, or my computer. Don't connect to external information sources.
The Controller
The current version of the controller is found here. It is written in Java 8. The "Tournament" file is the main controller, which also contains the list of competitors (if you want to host your own competitions).
Leaderboard
I haven't really been able to update the leaderboard very often. I am rather busy this weekend. By "rather busy" I mean no access to a computer from 6:30 AM to 9:30 PM. Here are the scores after 5 runs. The "Echo" bot kept forfeiting for some reason (might be my fault, I haven't investigated yet).
170 - Quinn and Valor
158 - Historian
142 - DeltaMax
140 - MorraCowbell
132 - Extrapolator
115 - Rainbolt
102 - Popularity
100 - Interpolator
83 - CounterBot
80 - Basilisk
76 - Erratica
65 - Trendy
63 - Scholar
62 - RandomGuesser
60 - KingFisher
59 - NullifierBot
55 - EvolvedBot
48 - Confused
Credit
Many thanks to Rainbolt and Peter Taylor for their help with the controller.