27
7
It is a dry summer in the prairie. The four farmers in the area realize that they can corner the market on corn by burning their neighbors crops. But they need a strategy for doing so; that is where you come in.
Your task is to write a bot to tell the farmers what to burn. The goal is to finish the game with the largest area of unburnt land. The playing field is a 32x32 grid. Each cell may be one of the following:
. - Ground
@ - A bot
# - Ash
W - Wet ground
1,2,3,4,5, or 6 - Fire
Fire grows in intensity by 1 each turn. Once it is 3 or higher, it will set cells next to it (horizontally or vertically) on fire. After fire hits 6, it turns into ash.
On each turn, bots receive as STDIN the following: bot starting x, bot starting y, bot current x position, bot current y position, and the board, separated by newlines. An example:
8
22
6
24
................................
................................
................................
.....................1..........
....................1#1.........
...................1#363........
....................16@1........
.....................31.........
................................
.........1.1....................
........15#62...................
........15@2....................
.........32.....................
................................
................................
................................
................................
................................
................................
................................
................................
................................
....4.1.........................
.....1#3........................
.....@3.........................
.....W..........................
................................
................................
................................
................................
................................
................................
(in this instance you are the bot in the bottom left).
You must output three characters, with an optional newline, representing the following:
Move - one of L, R, U, D, or S (stay)
Action - one of B (burn), P (pour water) or X (do nothing)
Direction - one of L, R, U, D or S
- controls which cell you perform the action on
Fire does not affect bots.
Turn order is as follows: All bots move; all bots perform actions; then environmental rules happen.
If you pour water on the ground, it will be wet (W
) for one turn. Fire will not spread to wet ground. If you pour water on wet ground, it will continue to be wet. If you pour water on fire, it turns back to regular ground. You cannot do anything to ash.
Rounds are run with 4 bots at a time. The round ends after 50 turns, or when one bot runs out of unburnt ground, whichever comes first. Your score is calculated as the number of ground or wet ground cells in the 9x9 square centered on where your bot started.
Here is an example bot; it picks all three letters randomly and generally ends up burning down its own fields.
RandomBurner:
#!/usr/bin/env python
import random
print random.choice('LRUDS')+random.choice('BPX')+random.choice('LRUDS')
Rules:
- No filesystem access outside of your own folder.
- You may write to files if you need to store persistent data between turns, but only up to a maximum of 1kb per bot
- You may not overwrite anybody else's bot
- If you output an invalid move, your bot will sit still. If you output an invalid action, your bot will do nothing.
- Please stick to common languages that can be run on a OSX or Linux box.
Controller code can be found here.
Initial results:
Average of 15 rounds:
---------------------
81 Farmer
56 CautiousBot
42 GetOff
41 Visigoth
40 DontBurnMeBro
37 FireFighter
35 Pyro
11 Protector
Update: Added Farmer, CautiousBot, GetOff, FireFighter, and Pyro.
1The board doesn't wrap around at the edges, right? – Zgarb – 2015-10-06T17:10:54.783
1Right. If you try to move past the edge, you just stand still. – Skyler – 2015-10-06T17:19:19.103
I understand Move and Action, but what does Direction do? – recursive – 2015-10-06T17:42:04.310
1@recursive Direction is where you do the action. E.g. if you do SBR, you stay where you are and burn the cell to the right of you. – Skyler – 2015-10-06T17:48:41.567
4I don't understand one detail. What land is mine and what is yours? – kaine – 2015-10-06T18:50:40.280
3Your land is what was inside the 9x9 block area centered on where you started. All bots start the round at least 8 blocks from each other, so there is no overlap. – Skyler – 2015-10-06T18:52:52.183
How do you tell the type of land under the bots? – TheNumberOne – 2015-10-06T19:40:42.210
2It's not provided. If you want to record it somehow, that is an option. Sitting on a fire to hide it is a valid strategy. – Skyler – 2015-10-06T19:49:59.777
If your land is a 9 by 9 square, does the bot you control in the example have less land to start with than the others? – The_Basset_Hound – 2015-10-07T01:20:16.080
1No, because it's centered on your bot; four spaces in each direction. – Skyler – 2015-10-07T01:24:07.317
Whoops, thought you meant 9 in each direction. Thanks. – The_Basset_Hound – 2015-10-07T01:28:32.840
Is a PHP answer acceptable? – Kodos Johnson – 2015-10-07T05:21:39.060
Does fire stop propagating at some point? Or the chain reaction of setting fire to adjacent cells goes on forever? – Ioannes – 2015-10-07T08:52:30.003
1@Andrew, PHP is fine as long as it can be run from the command line. The chain reaction continues until the round ends (unless stopped by water or ash). – Skyler – 2015-10-07T14:42:54.687
I tried running the controller code but I got some weird output. The bot is outputting UBR (move up, burn right). It goes straight down as expected but the fire doesn't spread to the left until it reaches the bottom. I took a quick look at the code but couldn't see what is causing this. Is there a reason for it?
– Kodos Johnson – 2015-10-08T00:39:22.200In the example, shouldn't the current position be (5,24)? – CommonGuy – 2015-10-08T06:20:21.507
1@Andrew Indeed. There was a bug in the controller which I fixed before I ran the last rounds, but forgot to update here - should be fixed now. – Skyler – 2015-10-08T12:34:38.197
@Skyler I'm having a little trouble getting the controller to work, every character is just standing still. Can you clarify how to run it/ what the file structure is? Thank you – thefistopher – 2015-10-08T17:00:45.997
Sure, the file structure is
firefighters.py
andbots/
, with all the bots inbots/
. Run with pythonfirefighters.py bot1name bot2name bot3name bot4name
. – Skyler – 2015-10-08T17:10:51.263Would an answer written in Felix be OK? It runs well on Linux...
– kirbyfan64sos – 2015-10-08T17:31:31.133@kirbyfan64sos Should be fine. I'd just need to update Java on my Linux box, because Protector doesn't run on anything below 1.8. – Skyler – 2015-10-08T18:33:31.627
What is the format of the tournament? – horns – 2015-10-19T19:19:33.343
I am currently running bots in matches of 4, such that every bot is in a match with every other bot at least three times. The total score for a bot is the average of its score over all rounds it played in. – Skyler – 2015-10-19T19:38:55.443
BTW, your controller code has some bugs in the environmental effects section, specifically in managing the spread of fire. Spreading fire can overwrite more intense fires, and sometimes fires just get stuck at 5. I rewrote some of the controller code in python3 for my personal testing, let me know if you'd like it. – horns – 2015-11-04T13:32:57.680
Yes, I would be interested in that. – Skyler – 2015-11-04T14:24:19.893
1link. I changed it to run on python3, be compatible with windows, and added builtin tournament if called with no parameters. – horns – 2015-11-04T19:42:49.073