- Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
- Git repo: https://github.com/ajfaraday/easter_bunny_hunt
The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs.
Unfortunately, there's a team of 4 children who aren't content to collect chocolate eggs, they want to capture the Easter Bunny™.
The game starts with 4 kids, one in each corner of the garden.
The kids can take 1 step each turn, in one of the 4 cardinal directions (North, South, East or West). When they've each taken a step (or decided not to), the bunny will take a move.
The kids can only see the Easter Bunny or it's eggs when they are 5 steps away or nearer.
Kids visibility (yellow) and movement options (green):
The bunny can hop up to 2 spaces away on both axes (describing a 5 x 5 square he can hop to).
The Easter Bunny™ can only see the kids when they are 5 steps away or nearer.
Bunny's visibility (yellow) and movement options (green)
Neither kids nor the Easter Bunny™ can leave the garden.
The game ends when:
- The Easter Bunny™️ drops his last egg.
- The kids catch the bunny.
- The game reaches turn 1000.
The Goals:
- The Easter Bunny™ wants to give the children as many Easter Eggs as possible while evading capture.
- The kids want to collect as many eggs as possible, AND catch the Easter Bunny™.
This means that:
- The Easter Bunny™ will ONLY score points if it evades capture by dropping it's last egg, or by finishing the time limit.
- The team of kids will ONLY score points if they capture the Easter Bunny™.
- In either case the points scored is the number of eggs the kids have picked up.
The challenge is to write behaviour for the Easter Bunny™ or for the team of kids. Your code will be run against all of the other kind of entry.
Config
You can edit conig.js to change two things about the run:
match_limit
will allow you to end the game when you decide (competition will use 1,000 turns)turn_time
(ms) will set the interval when the game is rendering.
As the kids:
(See instructions for the bunny below)
Your goal is to collect as many eggs as you can, and then catch the Easter Bunny™.
Your code will take the form of an array of 4 JS functions, which will each control a kid starting in these positions (in this order):
- North West (0, 0)
- North East (0, 48)
- South East (48, 48)
- South West (48, 0)
If you're watching a match, these are represented by the numbers 1 to 4.
The functions should each have this fingerprint:
function(api) {
}
api is your function's interface to the game (see below).
The Kid API
The api object presents these four movement functions:
api.north()
api.east()
api.south()
api.west()
If any of these are called during your function, the kid will take one step in that direction (or the last called of these four directions). If none of these are called during your function, the kid will stand still.
It also provides information about the state of the game with these methods:
api.my_storage()
- an object you can use to store data and functions for just this kid.api.shared_storage()
- an object you can use to store data and functions for the whole team.api.turn()
- Returns a number of turns taken in this game so far.api.bunny()
- Returns an object of bunny-related info if the bunny can be seen{ x: 24, y: 24, eggs_left: 100 }
api.kids()
tells you where all the kids are[ {x: 0, y: 0, me: true}. ... ]
api.eggs()
tells you where the eggs are that your child can currently see:{ x: 25, y: 25, age: 10 }
Age is the number of turns since the bunny dropped the egg.
Kid Template
Teams.push(
{
name: 'template',
shared_storage: {},
functions: [
function(api) {
// NW kid
},
function(api) {
// NE kid
},
function(api) {
// SE kid
},
function(api) {
// SW kid
}
]
}
);
name
must be a single-word identifier, if you want to run just a single entry.shared_storage
sets the initial state ofapi.shared_storage
, it can be used to set data and functions for your team.- The array
functions
is the behaviour of the 4 kids chasing the bunny.
How to participate
You will need nodejs installed.
Change my_entry to your own team name.
git clone https://github.com/AJFaraday/easter_bunny_hunt.git
npm install terser -g
cd easter_bunny_hunt
cp team_template.js teams/my_entry.js
- (Write your team code)
script/run.sh my_entry basic
to watch a game. The first entry is the name of your team, the second is the name of an entry in bunnies/.script/run.sh
to run all matches and see all results (if you import more entries)
When you're happy with the result, copy it in to an answer like so:
# Team: my_entry - 10 points
Any description you want to add goes here
Teams.push(
{
name: 'template',
shared_storage: {},
functions: [
function(api) {
// NW kid
},
function(api) {
// NE kid
},
function(api) {
// SE kid
},
function(api) {
// SW kid
}
]
}
);
Then have a try at writing an entry for the Easter Bunny™.
As the Bunny
Your goal is to give away as many easter eggs as you can and, crucially, to evade capture.
The bunny starts at the centre of the garden, at coordinates 24, 24.
Your code takes the form of a function with this finger print which runs once a turn, after the children have moved.
function(api) {
}
The Bunny API
The api object provides this method to tell the bunny how to move:
api.hop(x, y)
The two arguments tell the bunny where to hop to relative to it's current position:
- They can have values from -2 through to 2.
- If
x
is positive, it will hop east, negative, it'll hop west. - If
y
is positive, it will hop south, negative, it'll hop north. - If the values provided are out of range, it will force it to 2 or -2.
- Each time the bunny hops, it leaves behind an Easter egg.
It also provides this functions to give you storage between turns:
api.storage()
- Returns an object you can use to store variables.And these functions to give you information about the game:
api.turn()
- Returns the turn number the game is currently at.api.eggs()
- Returns the positions of all Easter eggs in the garden.{ x: 25, y: 25, age: 10 }
api.bunny()
- Provides information on the current state of the bunny{ x: 24, y: 24, eggs_left: 100 }
api.kids()
- Provides information on all the kids the bunny can currently see.{ x: 0, y: 0 }
Bunny Template
Bunnies.push(
{
name: 'template',
storage: {},
function: function(api) {
}
}
);
name
is the name of your bunny behaviour. Keep it to 1 word (underscores allowed).storage
is the current state of your storage object, available via the api.function
is the function which will be run every turn to control the bunny.
How to participate
You will need nodejs installed.
Change my_entry to your own bunny name.
git clone https://github.com/AJFaraday/easter_bunny_hunt.git
npm install terser -g
cd easter_bunny_hunt
cp bunny_template.js bunnies/my_entry.js
- (Write your team code)
script/run.sh get_egg my_entry
to watch a game. The first argument is the name of a team in teams/, the second is the name your bunny.script/run.sh
to run all matches and see all results (if you import more entries)
When you're happy with the result, copy it in to an answer like so:
# Bunny: my_entry - 10 points
Any description you want to add goes here
Bunnies.push(
{
name: 'template',
storage: {},
function: function(api) {
}
}
);
Then have a try at writing an entry for a team of kids.