Something's wrong Something's wrong

We don't want your email. Just bear in mind that if you forget your password, you'll need to create a new account

Something's wrong

yare

Log out username 1500
Game history

Kill all enemy cats to win. With JavaScript.

You control 9 cats via two methods: move() and pew(). The map has barricades (collision obstacles) and pods (areas where you can replenish energy). There is a death_circle that slowly shrinks, forcing cats to engage in a fight.

Energy is the only resource of the game. You attack and defend yourself with it – see details below.

Game map

Apart from cats, there are two other objects on the map. Barricades and Pods:

Variable Type Description
barricades array Array of [x, y] coordinates of the barricade's center. Barricade is an obstacle with a radius 100 units from its center that cats have to walk around.
pods array Array of [x, y] coordinates of the pod's center. Pod is an area of 40x40 unit. Any cat inside this area gets 1 energy per tick.

Game's global variables:

Variable Type Description
memory object Empty object. Use it to store values across ticks.
my_cats array Array of your units (all, even dead ones)
cats object Object containing all cat objects in the game
tick number Current game tick (e.g. 75). 1 tick = 500ms
death_circle number Shrinking circle centered on the map. Cats outside it lose 1 energy per tick. Starts at 1200 radius, shrinks by 2/tick, stops at 50.

Cats are the game's units. These are their properties:

Variable Type Description
id string username + _ + number. E.g. 'jane_7'
position array cat's [x, y] coordinates, e.g. [750, 900]
energy_capacity number 10
energy number current energy (starts at 10)
hp number 1 when alive, 0 when dead
mark string custom label assignable via set_mark()
last_pewed string id of the last pewed target
player_id string username of the owner
sight object show example
my_cats[1].sight = {
  friends: ['jane_2', 'jane_3', 'jane_4'],
  enemies: ['karl_4'],
  friends_pewable: ['jane_2'],
  enemies_pewable: []
}

Cats see other cats within 400 radius. There are 3 friendly and 1 enemy cat within sight range. 1 friendly cat is within pew() distance.

And the available methods:

Method Argument Example
move(target) target is [x, y] array my_cats[0].move([100,100])

Cats move by max. 20 units per tick

pew(target) target is a cat object within 200 units my_cats[0].pew(cats['jane_7'])

Costs 1 energy per tick. When an enemy cat is hit, it loses 2 energy. When a friendly cat is hit, it restores 1 energy.

If there are other enemy cats within 20 units radius of the target, they are hit as well (all lose 2 energy per tick)

shout(message) message max 20 characters my_cats[0].shout('meow')
set_mark(label) label max 60 characters my_cats[0].set_mark('purring')

This is also the order of operations. Cats first move, then pew (within the cycle of one tick)

Code examples

Simple starter code
Attack closest cat
for (let cat of my_cats) {
    if (cat.sight.enemies.length == 0) continue;

    let enemy = cats[cat.sight.enemies[0]];
    cat.move(enemy.position);
    cat.pew(enemy);
}
function distance(a, b) {
    let dx = a[0] - b[0];
    let dy = a[1] - b[1];
    return Math.sqrt(dx * dx + dy * dy);
}

function closest_enemy(cat) {
    let best = null;
    let best_dist = Infinity;
    for (let id of cat.sight.enemies) {
        let d = distance(cat.position, cats[id].position);
        if (d < best_dist) {
            best_dist = d;
            best = cats[id];
        }
    }
    return best;
}

for (let cat of my_cats) {
    let enemy = closest_enemy(cat);
    if (!enemy) continue;

    cat.move(enemy.position);
    cat.pew(enemy);
}

Credits

Author: Vilem Ries

Special thanks: VendanLots of infra work and backend optimization on the 'v1' of Yare that is still in use in this version, jmHelped with optimizations around game logic, swzPython transpiler and other help (Python not ready yet in this version of Yare, but coming soon!) and rozLots of help with testing