Rat Tenkova

I whipped up this little game for my friend’s kids as a gift, and it was such a blast I decided to give it a proper polish and release it under a free software license! Since I built it on the fly, not expecting anyone else to see the code, it’s a bit messy. I made a few parser and interpreter mistakes early on, but I’ll fix those up later.

In the video kid’s pictures are blurred. Game has audio but I did not record it.

I used Python, Pygame, Pygame GUI, and SLY (Sly Lex Yacc) to build it. To program your tanks, you use a language that’s a bit like C/JavaScript, and your code gets compiled into bytecode. To keep things fair, the interpreter runs one instruction for each tank per cycle. So, writing clever, compact code means your tank can process more information and react faster than others. That way, everyone starts on an even playing field!

Each tank has a small crew: a captain and a driver. They have different views from the tank, so you’ll have to choose which one will scan the area. Once you spot some movement, you can move toward it and fire. Just remember, your gun needs to reload before you can shoot again, so plan your attacks carefully!

You can also tweak parameters on the fly, which lets you try out the same code on different tanks with varied inputs. It’s perfect for all your experimenting!

Here’s a quick peek at the code. First bot behaves in random way:

export initial_speed = 100;

func run() {
rotate(5);
speed(initial_speed);

while(True) {
if(isStuck()) {
angle = random(33, 66);
rotate(angle);
};

random_number = random(0, 10);

if (random_number == 5) {
shoot();
} else {
if (random_number == 2) {
say("Disi sad?!");
} else {
if (random_number == 3) {
rotate(random(0, 360));
};
};
};
};

};

This bot scans area around:

func run() {

speed(100);
rotate(random(0, 180));

while (True) {
for(found in commanderObserve()) {
rotate(found[0]);
shoot();
};

if(isStuck()) {
angle = random(33, 66);
rotate(angle);
};
};
};

The code is full of places where you’re forced to put semicolons, and that’s going to change. My other plan is to create a web application that makes it easy for multiple people to play with each other’s code, organize tournaments, and have a scoreboard. And yes, a WASM player will be used to show the battles.

Will make a new post once I clean up the code and publish first version on GitHub.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.