9
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
How much health does each bot have? And what does the edge of the cavern look like? – Conor O'Brien – 2015-10-23T23:29:49.930
They start with 20 and can collect as much as they want. Added this info above – The Beanstalk – 2015-10-23T23:32:00.593
The edges of the cavern aren't marked, your program will only get the bits that you could potentially walk on. – The Beanstalk – 2015-10-23T23:42:47.273
Do you really not know your health? – pppery – 2015-10-24T13:28:18.453
Could you input the length and width of the bot's vision? – LegionMammal978 – 2015-10-24T18:00:45.500
I meant to add health, the post and code has been updated. I don't think the length and width of the bot's vision is necessary – The Beanstalk – 2015-10-24T19:00:14.777
What would happen with
MNEHNN
on-----\n---}-\n--Y--\n-----\n-----
? Would the bot go north or east? Also, isN
orY
displayed when you're on a Nurse? – LegionMammal978 – 2015-10-29T00:18:22.943@LegionMammal978 The bot would go north in that case -- the bot will always try to move N/S before E/W. If you're on the same place as Nurse, then your bot's
Y
will overwrite her 'N', but she'll still heal your bot. – The Beanstalk – 2015-10-29T21:44:41.707I found a few bugs in the controller. 1: Nurse Nina doesn't work. 2: If a bot attacks the same lion (or centipede or bat) in both its moves, an error occurs. – pppery – 2015-10-29T22:09:15.250
Fixed Nurse Nina, but I can't replicate the 2nd problem. I changed the code a little anyway, but what's the error you're getting? – The Beanstalk – 2015-10-29T22:59:49.720
I was getting
ValueError: list.remove(x): x not in list
, but the changes you made probably fixed it. Bots that attack the same occupied space with both their moves should trigger this. – pppery – 2015-10-30T00:24:48.023Found another bug: If a bot is killed by inexact count (so its health goes into the negative numbers), it still appears in other bots' vision. (But doesn't take any turns) – pppery – 2015-10-30T00:37:09.760
Fixed, thanks for bug hunting @ppperry – The Beanstalk – 2015-10-30T16:09:15.353
Found another controller bug: If a bot with a revealer wanders sufficiently close the the edge of the cavern that his normal view is limited, the controller crashes. – pppery – 2015-10-30T18:39:41.663
I've been working on that issue and updated my code this morning, have you re-downloaded the controller code since then? – The Beanstalk – 2015-10-30T18:54:23.350
@TheBeanstalk I did not redownload it. You seem to have fixed that bug. – pppery – 2015-10-30T19:10:45.987