function play(state){ // Your code here // // 'state' contains the objects that you currently see: // state.bots - array of your bots // state.wrenches - array of wrenches on the ground // state.castles - castles that you can occupy (there are 3 total) // state.others - bots from other players // // You can do: // var bot = state.bots[0]; // get your first bot // bot.moveTo(state.wrenches[0]); // move 1 towards something (diagonal OK) // bot.collect(); // collect a wrench on the ground (maximum 5 wrenches per bot) // bot.build(); // spend 2 wrenches to build another bot (maximum 256 bots) // bot.attack(other); // remove 1 wrench from another bot (so wrenches are really your health points) // only one action at a time; // // Your goal is to occupy as many castles as possible, // you occupy a castle when you have at least 1 bot in it // you cannot enter a castle where there are other players bot in // the computer is playing against you in solo mode // // There is a more complete documentation at the top of the page // Happy coding! }
Line break

In the arena, you play against other human players. Your goal is still to find the castles, invade them and occupy them as long as possible

Everyone plays on the same map

Overview of the game mechanics

The rules of the game are the same as in solo training mode. (Click here to go back to the training mode)

Your code runs in your browser, and the game engine runs on machinegame's servers. At each turn, the server is going to send you the state (via WebSocket). The javacript on your browser will compile and execute your code, and return your actions to the server, which will execute them.

Speed matters

The server will keep track of how long each player took to play (network included) and execute all actions of the fastest players first. This represents an enormous advantage, as playing first means you collect resources first, attack first, etc.

Taking the example of 2 bots with 1 wrench of health left attacking each other, the first player to play will kill its opponent, and when the second player goes to attack, the bot is already gone.

Also the server will wait 500.0ms for the code of all players to finish executing. If your code takes longer to execute and return the actions, it will be ignored.

Your code runs in your browser

Your code is not sent to machinegame's servers at all. It is compiled and run on a WebWorker in your browser. The speed of execution of your code is entirely dependent on your machine

Castles

There are 2 castles per players, so if 30 players are in the arena at the same time, 30 castles are on the map. If a player is killed, 2 castles are removed

A few notes

As the state is regenerated for each turn, you cannot store properties on bots directly, so doing bot.task = 'EXPLORING' will be lost for the next turn.

As the WebWorker is reused between turns, you can however store global state in the webworker, so doing var global = {} outside of your function play(){} will create a global variable that will persist between plays.

The WebWorker is recreated each time you compile, so you'll lose global variables at that point.

If you have any question or comment, feel free to email us at play@machinegame.com