Your geologist buddy nearly kicked down your office door as he burst in, eyes wide in excitement, and asked you to come with him to a site he just discovered. On the way he explains that he thinks he literally just struck gold. Only problem is, it's buried deep underground in a cavern with a very unstable roof. It's too dangerous to go spelunking, so he wants you to program one of his cave exploring robots to collect as much gold as it can before he pulls it back up. He also mentions that he's probed the cavern and found some wildlife that could be harmful to the robots, and also that he'd dropped some equipment down there that might still be useable. Each robot is equipped with two arms and a range of sensors. When you arrive at the scene, he tells you he's planning on recruiting more coders, and whoever does the best job will be rewarded.
Now, down to the nitty-gritty. The sensors pass information to your program as ASCII characters. Here's a list of what each character means and descriptions for anything the bot might encounter in the cave:
Code Name/Description
Y Your bot
You do things
@ Other bots
They do other things
- Ground
This doesn't do things
C Centipede
These will bite you and leave a poison effect
The bite will cost 1 health
The poison effect will last for 3 turns, costing 2 health each turn
B Bats
If bats end up in the same space you are, your bot runs in a random direction during its turn rather than what you told it to do
L Lion (because reasons)
Lions deal heavy damage, 10 health, each time they attack
F Food
Eating this will give you 5 health
Can only be used once
W Water
Drinking this will cure poison effects early
Can only be used once
R Revealer
This will increase the range of your visibility to an 11x11 grid
The extra range will only be 75% correct, but the original range won't be effected
K Knife
You do twice as much damage to other bots if you have a knife
G Gold
The whole reason you're doing this in the first place
N Nurse Nina
She mend you good
Restores your health by 10 while you occupy the same space as her
} Boulder
You can't walk over boulders, and neither can anything else
P Pit
If you fall in a pit, you will be stuck for 3 turns
The size of the cavern grows based on how many bots are participating. It starts as a 30x30, and it gets an extra 10x10 for every bot. So 2 bots will explore a 50x50 cavern.
Bots start with 20 health, but they don't have a maximum limit on health.
Input:
You'll receive input through STDIN in the following format:
20,5,10,1,0,True,False <-health, number gold pieces, number of turns your bot has lasted, number of until the poison wears off, number of turns until you are no longer stuck in a pit, if you have a revealer, if you have a knife
-----
-G}--
--Y-L
-C---
---B-
The first line contains information about your bot, and the rest is the grid that your bot can see. If your bot is against one of the 4 walls of the cavern, you will get a grid that looks more like this (in the case of being all the way to the West):
---
}--
Y--
---
---
The cavern does not wrap around, and neither does your vision. The walls of the cavern are not marked, the only indication your bot receives that it is nearing a wall is its view being diminished. With the Revealer, you might get something like this:
--------C--
LW--------B
---K-N-----
--------BR-
-F---------
--B--Y---@N
-W@---F----
------K-F--
----@-}----
R@---G}--}-
--------G-R
Output:
You get two moves per turn, which you output in the following format:
MNNANW <- Moves are groups of 3 characters representing the action and the direction
Possible actions are the following:
M Move - Move your bot in the specified direction
A Attack - Attack the square in the specified direction
H Hold - Do nothing
Possible directions are the following:
NN - North (up)
NE - Northeast (up-right)
EE - East (right)
SE - Southeast (down-right)
SS - South
SW - Southwest
WW - West
NW - Northwest
The moves are applied from left to right.
Turns:
Turns progress in the following fashion:
Poison effects are applied to any player who has been poisoned
Non-bots move and attack
2a. Lions, Centipedes, and Bats move randomly
2b. Lions and Centipedes will attack everything that is directly adjacent to it (including diagonally)
2c. The bat effect will only be applied to a bot if it is on the same space as the bat
2d. Nurse Nina will stay in a location for 3 turns, and then jump to a random location.
Bots move
3a. If your bot gives invalid output, it won't move
3b. Your bot will try to get as close to the space designated by the output as possible (see the note at the bottom for more detail)
3c. One attack to a Centipede, Lion, or Bat will kill it
3d. Attacking another bot without a knife will do 5 damage, and 10 with a knife
Rules:
Stick to common languages that can be run on OS X or Linux.
You can optionally write up to and not exceeding 1kb data to a file
Scoring:
Bots will only be in the cavern until only one remains, or until 50 turns have gone by, whichever comes first. Your bot will be judged on the sum of the number of gold coins it collected and how many turns it lasted.
Controller code can be downloaded for testing here (make a folder called "bots" in the same directory that you download it to, and put your bot inside "bots") You'll need NumPy to run it. Feel free to dig through it, but you'll have to excuse the mess...
Here's some code for a random bot:
#!/usr/bin/python
import random as r
a = ['M','A','H']
d = ['NN','NE','EE','SE','SS','SW','WW','NW']
print(a[r.randint(0,2)]+d[r.randint(0,7)]+a[r.randint(0,2)]+d[r.randint(0,7)])
****Your bot will always move in the general direction your output specifies, but if it is obstructed by a rock or a wall, the exact direction depends on the circumstance. For instance, if your bot is against a wall like so:
---
}--
Y--
---
---
and your output is
MNWMSW
your bot will move one space down. It couldn't move North or West, so that move had no effect. It could move South (and did) but couldn't move West. However, if your bot tried to move Northeast, it would go directly to that space (diagonal movement is diagonal, not procedural)
Leaderboard
These are the average scores of 4 games.
The bot of Survival: 54.75
Coward: 52.25
Pufferfish: 50.00
Randombot: 50.00
Indiana Jones: 47.50
TheoremBot: 46.50