Rule engine for Monkey Music Challenge.
Monkey Music Challenge is an AI- and pathfinding programming competition, where monkeys battle it out in a virtual 2D-djungle over who can collect the most songs, albums and playlists.
Your mission is to write a program to control a monkey. You win by scoring the most points. Read on to find out more...
Your the game takes place in a virtual 2D-world, looking something like this:
Your program reads this 2D-world from a JSON object, which in the above case would look like this:
{
"layout": [
["album", "wall", "playlist", "wall", "album"],
["empty", "song", "song", "song", "empty"],
["empty", "empty", "user", "empty", "empty"],
["empty", "wall", "playlist", "wall", "empty"],
["empty", "monkey", "song", "monkey", "empty"]
],
"remainingTurns": 10,
"isGameOver": false,
"score": 0,
"position": [4, 1],
"inventory": [],
"inventorySize": 3,
"buffs": {}
}
The game is turn based. At the start of every turn, your program receives a new JSON object with the current state of the 2D-world.
At the end of every turn, your program sends a JSON command telling your monkey what to do next. The computation time during each turn is limited, use it wisely.
You control your monkey by sending one of three different commands: move
, for
moving around the level use
, for using items in your inventory and idle
for
doing nothing at all.
The following are valid move commands:
{"command": "move", "direction": "left"}
{"command": "move", "direction": "right"}
{"command": "move", "direction": "up"}
{"command": "move", "direction": "down"}
The move
command both moves your monkey around the world, and lets it
interact with its surroundings.
For example, in this scenario:
{
"layout": [["monkey", "empty"]],
"position": [0, 0]
}
issuing the command:
{"command": "move", "direction": "right"}
would result in your monkey moving one step to the right, as such:
{
"layout": [["empty", "monkey"]],
"position": [0, 1]
}
Your monkey can pick up items by moving to them.
For example, in this scenario:
{
"layout": [["monkey", "song"]],
"position": [0, 0],
"inventory": []
}
issuing the command:
{"command": "move", "direction": "right"}
would result in your monkey picking up the song
to its right, as such.
{
"layout": [["monkey", "empty"]],
"position": [0, 0],
"inventory": ["song"]
}
Note that when picking up an item, your monkey
remains at its current
position.
Items can only be picked up while your monkey's inventory is smaller than the
inventorySize
specified in the game state. If the inventory is full, you will not be able to move to an item.
You score points by collecting song
s, album
s and playlist
s. Your monkey
must first pick them up, then carry them in its inventory to the nearest
user
. The user
will reward your monkey
for any collected music with points.
The user
rewards the following points for different music items:
song
: 1 pointalbum
: 2 pointsplaylist
: 4 points
For example, in this scenario:
{
"layout": [["monkey", "user"]],
"position": [0, 0],
"inventory": ["song", "album", "playlist"],
"score": 0
}
issuing the command:
{"command": "move", "direction": "right"}
would result in your monkey trading in all currently carried music items for points, as such:
{
"layout": [["monkey", "user"]],
"position": [0, 0],
"inventory": [],
"score": 7
}
If another monkey
is in your way, you can tackle it! A tackled monkey will be
unable to do anything else for the remainder of the turn, and you also have a
50% chance of stealing something from your opponent's inventory. Watch out for
thieves!
For example, in this scenario, where your opponent's monkey stands at position [0, 2]
:
{
"layout": [["monkey", "monkey", "empty"]],
"position": [0, 0],
"inventory": []
}
issuing the command:
{"command": "move", "direction": "right"}
would (if you get to move before your opponent) result in your monkey tackling its opponent, and also (possibly) stealing one of its items, as such:
{
"layout": [["empty", "monkey", "monkey"]],
"position": [0, 1],
"inventory": ["album"]
}
You and your opponent might try to tackle each other during the same turn. The
monkey
that gets to move first is decided by random chance, but if your
program replied faster than your opponent's program, your monkey
will have a
(slightly) greater chance of moving first!
The world is full of open-door
s and closed-door
s. They are controlled
through interacting with lever
s.
For example, in the following scenario:
{
"layout": [["open-door", "lever"],
["closed-door", "monkey"]],
"position": [1, 1]
}
issuing the command
{"command": "move", "direction": "up"}
Would open all the closed-door
s and close all the open-door
s:
{
"layout": [["closed-door", "lever"],
["open-door", "monkey"]],
"position": [1, 1]
}
Tunnels connect different parts of the world with each other.
Every tunnel
has a number, such as tunnel-1
, tunnel-2
etc. There are
always two of every tunnel on every level, and my moving inside a tunnel, your
monkey will pop up at the other end.
For example, in the following scenario:
{
"layout": [["tunnel-1", "monkey", "wall", "user"],
["wall", "empty", "tunnel-1", "song"]],
"position": [0, 1]
}
issuing the command:
{"command": "move", "direction": "left"}
would give the following outcome:
{
"layout": [["tunnel-1", "empty", "wall", "user"],
["wall", "empty", "monkey", "song"]],
"position": [1, 2]
}
Note that your monkey cannot move into a tunnel if the exit is blocked by another monkey.
With the use
command, your monkey can consume an item in its inventory.
There are 2 different types of items: banana
s and trap
s.
Bananas give a positive speedy
buff to your monkey.
For example, in the following scenario:
{
"layout": [["monkey", "empty", "song"]],
"position": [0, 0],
"inventory": ["banana"],
"buffs": {}
}
issuing the command:
{"command": "use", "item": "banana"}
would give the following outcome:
{
"layout": [["monkey", "empty", "song"]],
"position": [0, 0],
"inventory": [],
"buffs": {"speedy": 6}
}
By eating a banana
, your monkey will obtain a speedy
buff for the 6
upcoming turns.
While your monkey is speedy
, you can make multiple moves per turn by sending
move
commands with an array of several directions, like this:
{"command": "move", "directions": ["left", "up"]}
which in the above scenario, would result in the following outcome:
{
"layout": [["empty", "monkey", "empty"]],
"position": [0, 0],
"inventory": ["song"],
"buffs": {"speedy": 5}
}
As we can see, the monkey
made two moves, and the duration of the speedy
buff was decreased by one turn.
A maximum of 2 moves per turn is allowed while speedy
. Remember to use the
"directions"
argument instead of the singular "direction"
!
Traps are offensive items, that mess up the lives of your opponents.
Traps are initially not armed, they can be picked up by your monkey
, as such:
{
"layout": [["monkey", "trap", "monkey"]],
"position": [0, 0],
"inventory": []
}
{"command": "move", "direction": "right"}
{
"layout": [["monkey", "empty", "monkey"]],
"position": [0, 0],
"inventory": ["trap"]
}
You must then choose a strategic location to set your trap.. choose wisely!
{"command": "move", "direction": "right"}
{"command": "use", "item": "trap"}
{"command": "move", "direction": "left"}
{
"layout": [["monkey", "empty", "monkey"]],
"position": [0, 0],
"inventory": []
}
As we can see, armed traps are invisible to all players, but don't worry, you can't fall victim to your own traps!
When your opponent move
s to the same position as your trap, they will be
stunned for 6 turns, also losing an item from its inventory. Moahaha!!
For the situtations where you need to remain still and plot evil plans, the idle
command is just what you need:
{"command": "idle"}
Copyright © 2014 Oscar Söderlund and Anton Lindgren.
Distributed under the MIT License.
Monkey designed by Patrik Göthe.
Overworld sprites by Buch.
Custom sprites by Johan Brook.