April 2018
Beginner
714 pages
18h 21m
English
Our first script will simply select a random move:
{
"step": function(current) {
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
return {
x: current.pos().x + getRandomInt(-1, 2),
y: current.pos().y + getRandomInt(-1, 2),
}
}
}
Of course, a more intelligent strategy can beat this script. You can find a more advanced script in the code bundle. First, when it sees an enemy entity nearby, it always goes for the kill. If there is no such enemy, it tries to move away from the closest ally, attempting to fill the whole board. This script will easily wipe out the randomly moving enemy:
Of course, there is always room for improvement. Try to think of a better strategy ...
Read now
Unlock full access