UPDATE: The gist-files are updated (including new submissions) as the Controller.java did not catch Exceptions (only errors). It does now catch errors and exceptions and also prints them.
This challenge consists of two threads, this is the catcher thread, the cat thread can be found here.
The controller can be downloaded here.
This is an asymmetrical KOTH: Each submission is either a cat or a catcher. There are games between each pair of each a cat and a catcher. The cats and the catchers have separate rankings.
Catcher
There is a cat on a hexagonal grid. Your task is to catch it as fast as possible. Every turn, you can place a water bucket on one grid cell in order to prevent the cat from being able to go there. But the cat is not (perhaps) that dumb, and whenever you place a bucket, the cat will move to another grid cell. Since the grid is hexagonal, the cat can go in 6 different directions. Your goal is to surround the cat with water buckets, the faster the better.
Cat
You know the catcher wants to catch you by placing water buckets around you. Of course you try to evade, but as you are a lazy cat (as cats are) you exactly take one step at the time. This means you cannot stay on the same place you, but you have to move to one of the six surrounding spots. Whenever you see that the catcher placed a new water bucket you go to another cell. Of course you try to evade as long as possible.
Grid
The grid is hexagonal, but as we do not have hexagonal data structures, we take a 11 x 11
square 2d array and mimic the hexagonal 'behavior' that the cat can only move in 6 directions:
The topology is toroidal, that means if you step on a cell 'outside' of the array, you will just be transferred to the corresponding cell on the other side of the array.
Game
The cat starts out at given position in the grid. The catcher can do the first move, then the cat and its catcher alternate moves until the cat is caught. The number of steps is the score for that game. The cat tries to get a score as great as possible, the catcher tries to get a score as low as possible. The average sum over all the games you participated in will be the score of your submission. There are two separate rankings, one for the cat, one for the catchers.
Controller
The given controller is written in Java. As a catcher or a cat you each have to each complete implement a Java class (there are already some primitive examples) and place it in the players
package (and update the list of cats/catchers in the Controller class), but you also may write additional functions within that class. The controller comes with each two working examples of simple cats/catcher classes.
The field is a 11 x 11
2D- int
array that stores the values of the current states of the cells. If a cell is empty, it has value 0
, if there is a cat it has value -1
and if there is a bucket there is a 1
.
There are a few given functions you can use: isValidMove()
/isValidPosition()
are for checking whether your move (cat) / position (catcher) is valid.
Each time it is your turn, your function takeTurn()
is called. The argument contains the a copy of the current grid an has methods like read(i,j)
for reading the cell at (i,j)
, as well as isValidMove()/ isValidPosition()
that checks the validity of your answer. This also manages the wrapping over of the toroidal topology, that means even if the grid is only 11 x 11, you still can access the cell (-5,13).
The method should return a int
array of two elements, which represent possible moves. For the cats these are {-1,1},{0,1},{-1,0},{1,0},{0,-1},{1,-1}
which represent the relative position of where the cat wants to go, and the catchers return the absolute coordinates of where they want to place a bucket {i,j}
.
If your method produces an invalid move, your submission will be disqualified. The move is considered as invalid, if at your destination is already a bucket or the move is not allowed / destination already occupied (as a cat), or if there is already a bucket/cat (as a catcher). You can check that before hand with the given functions.
Your submission should work reasonably fast. If your method takes longer than 200ms for each step it will also be disqualified. (Preferably much less...)
The programs are allowed to store information between the steps.
Submissions
- You can make as many submissions as you want.
- Please do not significantly alter submissions you've already submitted.
- Please each submissions in a new answer.
- Each submission should preferably have it's unique name.
- The submission should consist of the code of your class as well as a description that tells us how your submission works.
- You can write the line
<!-- language: lang-java -->
before your source code in order to get automatic syntax highlighting.
Scoring
All cats will compete against all catchers the same number of times. I'll try to update the current scores frequently, the winners will be determined when the activity has decreased.
This challenge is inspired by this old flash game
Thanks @PhiNotPi for testing and giving some constructive feedback.
Current Scores (100 Games per pairing)
Name (Catcher) | Score | Rank | Author |
---|---|---|---|
RandCatcher | 191674 | 8 | flawr |
StupidFill | 214246 | 9 | flawr |
Achilles | 76820 | 6 | The E |
Agamemnon | 74844 | 5 | The E |
CloseCatcher | 54920 | 4 | randomra |
ForwordCatcher | 94246 | 7 | MegaTom |
Dijkstra | 46500 | 2 | TheNumberOne |
HexCatcher | 48832 | 3 | randomra |
ChoiceCatcher | 43828 | 1 | randomra |
Name (Cat) | Score | Rank | Author |
---|---|---|---|
RandCat | 77928 | 7 | flawr |
StupidRightCat | 81794 | 6 | flawr |
SpiralCat | 93868 | 5 | CoolGuy |
StraightCat | 82452 | 9 | CoolGuy |
FreeCat | 106304 | 3 | randomra |
RabidCat | 77770 | 8 | cain |
Dijkstra's Cat | 114670 | 1 | TheNumberOne |
MaxCat | 97768 | 4 | Manu |
ChoiceCat | 113356 | 2 | randomra |
PRINT_STEPS = true
, more detailed settings in the fileMyFrame.java
). Then I recorded this with LICEcap and edited it with GIMP. If you have further questions just ask! \$\endgroup\$