You are an enterprising dot who wants to increase the land under its control. This is quite simple - travel outside your current land and loop back into your land and everything in that loop is now owned by you. But there is a catch. If some other dot somehow finds your loop and crosses it, you die.
If you haven't already tried it, go to Splix.io and try a game. Use the arrow keys to control your movement.
GIF
Credit: http://splix.io/
Specifics
All players start at random positions on a 200x200 board. (I reserve the right to change this :). You will have a certain amount of moves to amass the greatest number of points possible. Points are tallied by:
- The number of players you have killed times 300
- The amount of land you own at the end of the round
This brings up the point that others can steal your land. If they start a loop that intersects some of your land, they can claim it. If you die during the round, you lose all points for that round.
Each round has a randomly selected group of players (max 5 unique players) (subject to change). Every player participates in an equal number of rounds. Your bot's final score is determined by its average per-game score. Each game consists of 2000 turns (also subject to change). All bots make their moves at the same time.
Death Cases
Head Butt
Both players die when they head butt each other. This is still true even when both players are at the edge of their space.
However, when only one of the players is in his land, the other player dies.
Line Cross
In this case, only the purple player dies.
You can't cross your own line.
Exiting the board
If a player attempts to exit the board, he will die and lose all points.
Capturing area
A player will capture area when he has a trail and he enters his own land again.
Red fills in between the two red lines. The only case where a player does not fill in is when another player is inside the loop. To be clear, this only applies when the other player himself is in the loop, not just land owned by him. A player can capture land from another person. If a player cannot fill in the area surrounded by his trail, the trail is converted directly to normal land. If the player inside another players land loop dies, the area in that loop is filled. Every time a player dies, the board is reexamined for an area that can be filled in.
Controller details
The controller is here. It is very similar to the original game, but small changes have been made to make this a better fit for KotH and for technical reasons. It is built with @NathanMerrill's KotHComm library, and with substantial help from @NathanMerrill as well. Please let me know of any bugs you find in the controller in the chat room. To be consistent with KotHComm, I have used Eclipse collections throughout the controller, but bots can be written using only the Java Collections library.
Everything is packaged in an uberjar on the github releases page. To use it, download it and attach it to your project so you can use it for auto-compleat (instructions for IntelliJ, Eclipse). To test your submissions, you run the jar with java -jar SplixKoTH-all.jar -d path\to\submissions\folder
. Ensure that path\to\submissions\folder
has a subfoler named java
, and to place all your files there. Do not use package names in your bots (although it may be possible with KotHComm, it's just a bit more trouble). To see all options, use --help
. To load all the bots, use --question-id 126815
.
Writing a bot
To start writing a bot, you must extend SplixPlayer
.
Direction makeMove(ReadOnlyGame game, ReadOnlyBoard board)
- This is where you decide which move you want your bot to make. Must not return null.
HiddenPlayer getThisHidden()
- Get the
HiddenPlayer
version ofthis
. Useful for comparing your bot to the board.
- Get the
enum Direction
- Values
East
(x = 1; y = 0)West
(x = -1; y = 0)North
(x = 0; y = 1)South
(x = 0; y = -1)
Direction leftTurn()
- Get the
Direction
that you would get if you made a left turn.
- Get the
Direction RightTurn()
- Get the
Direction
that you would get if you made a right turn.
- Get the
ReadOnlyBoard
This is the class where you access the board. You can either get a local view (20x20) of the board with the player positions shown, or a global view (the entire board) with only the information of who owns and claims positions on the board. This is also where you get your position.
SquareRegion getBounds()
- Retrieve the size of the board.
MutableMap<com.nmerrill.kothcomm.game.maps.Point2D,ReadOnlySplixPoint> getGlobal()
- Get a global map of the board.
MutableMap<com.nmerrill.kothcomm.game.maps.Point2D,ReadOnlySplixPoint> getView()
- Same as
getGlobal()
, except that it is limited to a 20x20 area around your player, and that it shows player positions.
- Same as
Point2D getPosition(SplixPlayer me)
- Get the position of your player. Use as
board.getPosition(this)
.
- Get the position of your player. Use as
Point2D getSelfPosition(ReadOnlyBoard)
- Get your position on the board. Usage:
Point2D mypos = getSelfPosition(board)
- Get your position on the board. Usage:
ReadOnlyGame
ReadOnlyGame
only provides access to the number of turns left in the game through int getRemainingIterations()
.
ReadOnlySplixPoint
HiddenPlayer getClaimer()
- Get the
HiddenPlayer
version of who is claiming a point - claiming = a trail.
- Get the
HiddenPlayer getOwner()
- Get who owns a point.
HiddenPlayer getWhosOnSpot()
- If the player is positioned on this point, return the hidden version of it. Only works in
getLocal()
.
- If the player is positioned on this point, return the hidden version of it. Only works in
Point2D
Unlike the other classes here, Point2D
is contained in the KotHComm library. com.nmerrill.kothcomm.game.maps.Point2D
Point2D(int x, int y)
int getX()
int getY()
Point2D moveX(int x)
Point2D moveY(int y)
Point2D wrapX(int maxX)
- Wrap the
x
value to be within the range ofmaxX
.
- Wrap the
Point2D wrapY(int maxY)
- Wrap the
y
value to be within the range ofmaxY
.
- Wrap the
int cartesianDistance(Point2D other)
- This translates to how many turns it would take for a player to move from point a to point b.
Clojure support
The Clojure compiler is bundled with the SplixKoTH-all.jar
, so you can use Clojure for your bot! Refer to my random_bot
to see how to use it.
Debugging a bot
The controller comes with a debugger to help test strategies. To start it, run the jar with the --gui
option.
To attach the debugger to your jar, follow these instructions for IntelliJ, or these instructions for Eclipse (Eclipse version untested).
If you are using a debugger with your code, you can use this to help visualize what your bot is seeing. Set a breakpoint at the beginning of makeMove
on your bot, and ensure that it only pauses the current thread. Next, click the start button on the UI and step through your code.
Now, to put it all together:
Running bots
To run your bots with others, you need to run the jar on the releases page. Here is a list of flags:
--iterations
(-i
) <=int
(default500
)- Specify the number of games to run.
--test-bot
(-t
) <=String
- Run only the games that the bot is included in.
--directory
(-d
) <= Path- The directory to run submissions from. Use this to run your bots. Ensure that your bots are a in a subfolder of the path named
java
.
- The directory to run submissions from. Use this to run your bots. Ensure that your bots are a in a subfolder of the path named
--question-id
(-q
) <=int
(only use126815
)- Download and compile the other submissions from the site.
--random-seed
(-r
) <=int
(defaults to a random number)- Give a seed to the runner so that bots that use random can have results reproduced.
--gui
(-g
)- Run the debugger ui instead of running a tournament. Best used with
--test-bot
.
- Run the debugger ui instead of running a tournament. Best used with
--multi-thread
(-m
) <=boolean
(defaulttrue
)- Run a tournoment in multi-thread mode. This enables a faster result if your computer has multiple cores.
--thread-count
(-c
) <=int
(default4
)- Number of threads to run if multi-thread is allowed.
--help
(-h
)- Print a help message similar to this.
To run all the submissions on this page, use java -jar SplixKoTH-all.jar -q 126815
.
Formatting your post
To ensure that the controller can download all the bots, you should follow this format.
[BotName], Java // this is a header
// any explanation you want
[BotName].java // filename, in the codeblock
[code]
Also, do not use a package declaration.
Scoreboard
+------+--------------+-----------+
| Rank | Name | Score |
+------+--------------+-----------+
| 1 | ImNotACoward | 8940444.0 |
| 2 | TrapBot | 257328.0 |
| 3 | HunterBot | 218382.0 |
+------+--------------+-----------+
Please let me know if any portion of the rules are unclear, or if you find any errors in the controller in the chat room.