It's election time, and your job is to beat your competitor in a head-on rivalry! You are both trying to win over a city of 256 people in a 16x16 grid. Right now, the city hasn't been divided into voting regions yet, but that's where your gerrymandering skills come in! You can also campaign in arbitrary areas of the city to gain support.
The game starts out with each bot having $100 and all 256 voters being neutral (value 0). In the below notation,
<x> refers to the grid space at
0 <= x < 16), and
[x] refers to the block at
0 <= x < 4). The city starts out divided into 16 4x4 voting blocks. Each turn, both players get to perform one move:
C <x0> <y0> <x1> <y1> - campaign in the area bound by
(x0, y0) and
(x1, y1), inclusive, which will make all neutral voters with at least as many of your voters compared to your opponent's voters in their Moore neighborhood (diagonals included) vote for you. This only counts neighbors in your campaigning area; that is, voters at the corners of your campaign area only have three neighbors. Additionally, opponent's voters with at least 4 of your voters in their neighborhood will switch to your side (note that this means that you cannot swing votes in the corners of your campaign area). This costs $1 per square, and if you do not have enough money, your turn will be skipped. Additionally, you must have
0 <= x0 <= x1 < 16 and
0 <= y0 <= y1 < 16; otherwise, your turn will be skipped.
M [x0] [y0] [x1] [y1] - Attempt to merge the voting region containing the block
(x0, y0) with the voting region containing the block
(x1, y1). Note that here,
0 <= x0, x1 < 4 and
0 <= y0, y1 < 4. If the voting regions containing these two blocks touch, then the merge will succeed. This costs $
(max(# blocks in first region, # blocks in second region) - 1) * 25; that is, if you merge a voting region containing 3 4x4 blocks with a voting region containing 2 4x4 blocks, it costs $50. This means that an initial merge of untouched regions is free. If you don't have enough money, or the regions don't touch, or your input is invalid, your turn will be skipped.
U [x] [y] - Attempt to unmerge the voting region containing the block
(x, y). If successful, it will take all blocks in the voting region containing your specified block and separate them all. This costs
$(# of blocks in the region - 1) * 50. If you don't have enough money, or your input doesn't fit
0 <= x, y < 4, your turn will be skipped.
B <x> <y> - Bribe the person at
(x, y) with the amount specified by their bribing cost (initially $5), which raises their bribing cost by $2. This makes them vote for you. If you don't have enough money, your turn will be skipped.
At the end of every other turn (including the end of the first turn), you will gain $50.
Each region will have all of its votes summed up. Then, if at least 50% of voters are not neutral and the number of votes for the two parties is not exactly the same, whichever party has more votes wins that region; otherwise, the region is neutral. The game ends when all regions are non-neutral and one party has strictly more regions than the other party (basically, you can call an election at any time, so as soon as you can win, you call the election and win).
I/O will be done via STDIN/STDOUT to allow (almost) any language to be used. On each turn, your bot will be presented with the following input:
Line 1: the number of regions,
Line 2 to 5: a grid of the voting regions consisting of a 4x4 of capitalized hexadecimal digits. For example, a possible voting region configuration with 11 regions is:
N M, the amount of money you have, and the amount of money your opponent has.
Line 7 to 22: the 16x16 grid consisting of
0 is a neutral voter,
1 is one of your voters, and
2 is an opponent voter.
For example, the starting configuration will be:
You will be given this input with a terminating newline, and you need to output one of the four commands indicated above (if you want to do nothing, then output anything invalid or output a newline, but if you don't output, your bot will be presumed frozen and you will lose).
Unless someone needs otherwise, bots taking more than 2 seconds on a turn are killed and lose.
Your submission must work correctly in under 2 seconds per turn. Your program should block for input and will be run once and will be fed 22 lines of input per move and should give exactly one line of output per move.
Every bot will be run against every other bot. Each round, the simulation will be run twice with each bot getting the first move in one of the simulations. If both bots win exactly one simulation, the tiebreaker goes:
- the bot that wins by a wider margin of regions wins (that is, whichever bot had a higher difference between their regions and the opponent's regions)
- the bot that wins by a wider margin of popular vote wins
- the bot with more popular votes wins
- the bot that took fewer moves to win wins
- failing these, the round is declared a tie
The bots will be run until one of them wins three rounds. If ten rounds have passed and neither bot wins, it is declared a tie, giving each bot half a win.
The bots will be ranked by wins, with earlier submissions winning ties.
- Is this game balanced and strategizable?
- I will probably leave this challenge open for two weeks before declaring a winner; submissions can still be made afterwards but may or may not be graded.
- Any clarifications or specifications needed?