In the future when Time Travel (abbreviated as TT) will be common, coin tossing will become a serious mind-sport. To prepare for the future we create a competition for programs where time traveling will be really happening from the viewpoints of the entries.
The competition is a round-robin style King of the Hill consisting of coin tossing matches between Java classes.
Rules of the coin tossing match
- There are two players and 100 rounds.
- In every round a coin is tossed and based on the result one of the players scores 1 point. Each player has 50% chance to score a point.
- After the tossing both players have a chance to control the time by pulling levers.
- If you pull a blue lever (revert stopper) no TT is possible to the round the lever was used or any earlier round anymore. TT's attempting to go to these rounds will have no effect.
- If you pull a red lever (reverter) you try to revert the time back to a former round. If succeeded the opponent's memory will be reverted to its memory before the chosen round and the coin toss results starting from the chosen round will also be deleted. The only possible sign for your opponent about the TT will be the number of its unused levers which will not be reverted back.
- Each player has 5 blue and 20 red unused levers at the start of the match. These levers are not affected by TT's.
- If no TT happens at the end of a 100th round the game ends and the player with the higher score wins.
Details
- Rounds have a 1-based indexing (form 1 to 100).
- Before round
x
you are provided the number of available blue and red levers, the coin toss results until turnx
(inclusive) and the memory of your (last)x-1
th round. - Pulling a blue lever in round
x
stops any TT's that have a destination at roundx
or before (it blocks a TT if it happens on that same exact round too). - Reverting to round
x
means that the next round will be roundx
. - If both players choose to revert at the end of a round the time is reverted to the earlier destination which is not blocked. The player(s) who tried to revert to this time will keep their memory.
Technical details
- You should write a Java class implementing the provided Bot interface.
- Add your bot to the project.
- Add an instance of your Bot to the
Bot
in the fileController.java
. - Your class should not keep information between calls. (In most cases having only
final
variables outside of functions satisfies this requirement.) - You can give information to the controller in the
memory
field of your returnedAction
object. This will be given back to you in the next turn if no TT happened. If a TT happens, you will receive the corresponding earlier memory of yours. - You can use the
totalScore()
method of theGame
class to get the score of a history string.
Protocol
At every turn your
takeTurn(...)
method is called with 5 arguments:- the number of unused blue levers
- the number of unused red levers
- the coin tossing history, a string consisting of 1's and 0's marking your wins and losses in the previous rounds. The first character corresponds to the first coin tossing. (In the first round the length of the string will be
1
.) - a string, your stored memory from the previous round
- the 1-based index of this round
At every turn your method returns an
Action
object containingan integer in the
move
field describing your action:0
for no action-1
to pull a blue lever and block TT's going through this round- a positive integer
x
, not larger than the current round, to pull a red lever and try to revert back to roundx
- Invalid integers are treated as
0
.
a string containing your memory from this round which you want to preserve. Note that storing memory is not a crucial part of the challenge. You can make good entries without storing any useful data in the string. At the first round the string will be an empty string.
Your method should take no more time than 10 ms per round on average in a match.
- Regularly failing the time-limit results in disqualification.
Scoring
- Winning a match earns 2 points and a draw earns 1 point for both players. Loss earns no points.
- A bot's score will be the total number of points it collected.
- The number of matches played between each pair of contestants will depend on the number of entries and their speed.
Two simple example bots are posted as answers.
The controller and the first couple Bots are available here.
Test results with bots submitted until November 3.:
Total Scores:
Oldschool: 3163
Random: 5871
RegretBot: 5269
Nostalgia: 8601
Little Ten: 8772
Analyzer: 17746
NoRegretsBot: 5833
Oracle: 15539
Deja Vu: 5491
Bad Loser: 13715
(The controller is based on the Cat catcher challenge's controller. Thanks for @flawr providing it as a base for this one.)
Bonus: a nice 6-minute film based on a similar concept.
If you pull a blue lever (revert stopper) no TT is possible through that round anymore. TT's attempting to go through the round will have no effect.
What is "going through a round"? \$\endgroup\$If you pull a blue lever (revert stopper) no TT is possible to the round the lever was used or any earlier round anymore. TT's attempting to go to these rounds will have no effect.
\$\endgroup\$