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.

Franjo Kluz, nikako da umre!

Spoiler alert – možete samo kliknuti ovdje https://www.binarni.net/projects/franjo/2.0/.

Na projektu Franjo Kluz sam počeo raditi prije 10 godina (negdje 2008.). Tada, isto kao i sada, nisam imao nikakve ideje što bi to trebalo biti (a nije da nisam imao ideja!).

Sve je krenulo kad sam odlučio napraviti Web based igricu sa aviončićima. Canvas je tad bio furka. Drugi svjetski rat i lokalna priča sa Franjom Kluzom mi je djelovala dosta simpatično. Kao mali sam obožavao “Partizansku eskadrilu” a kao stariji sam otkrio tko je bio Bekim Fehmiu i Hans Reiter u “Salon Kitty” od Tinte Brassa. Rekoh, bit će to dosta simpatično. Složio sam neki algoritam za generiranje terena, sklepao neku grafiku (pretežno pokrao grafiku i malo modificirao) i napravio aviončić koji se može kretati gore-dolje te bacati bombe. Naravno, prva misija se zvala “Stukas im Visier”.

Pažnja me držala dobre 2-3 minorne verzije (čak sam složio i neki osnovni web site) i onda sam nakon dosta pauze odlučio to sve prebaciti na telefon. Jer, zašto da ne! To je bilo neke 2011. godine. “Hej vazduhoplovci” kako svira u pozadini i aviončić koji ide s lijeva na desno. Zar treba i spominjati da je sve stalo na tome?

Četiri godine kasnije (2015.) sam nakon work overloada i godina neodlaženja uzeo 1-2 tjedna godišnjeg sa idejom da dovršim Franju. Zabrijao sam, to će biti moja duhovna obnova koja mi je falila. Trebao sam svaki dan izbaciti video i neki kratki blog što sam tog dana napravio. Završio sam sa jednim blog postom i 2 videa na Facebooku. I to je nešto.

Rekoh si tada – nemaš puno vremena pa si uzmi neke realnije ciljeve. Znao sam da sam loš s grafikom pa sam se odlučio za nešto jednostavniju grafiku tipa Luftrausers. Odlučio sam iskoristiti PixiJS. Nitko više ne piše svoje game engine, pa čak ne i za JavaScript (za Rust još uvijek možda ima smisla) ! Zabrijao sam da bi bilo dobro da igrica bude malo više casual tipa – 1 button ili maksimalno 2 button game. Aviončić cijelo vrijeme automatski pada, jednim buttonom ga dižemo gore a drugim eventualno napucavamo Švabe.

Dodao sam intro priču sa dosta nekih referenci (Kiklop, Ko to tamo peva, …). Generalna ideja je bila da se krene sa nacističkim napadom na Kraljevinu Jugoslaviju te da se igrač seli kroz različite stvarne bitke koje su se dešavale. Pače, čak sam istraživao i koji modeli aviona su se koristili u napadu. Treba biti autentičan, zar ne! Tu se desila i prva promjena aviončića – Potez XXV je odjednom postao Rogožarski IK-3!

Onda sam dobio druge ideje. Franjo je prvo bio u kraljevskom zrakoplovstvu, nakon toga je bio u NDH dok nije prebjegao u partizane. To mi je djelovalo kao zanimljiva ideja da krenem sa napadom na Beograd, prebacim se na Franju u NDH (vozi avion i upucava srbizme koji lete na njega; srbizmi kao riječi koje su bile zabranjene u NDH) i završi sa Franjom u partizanima.

Priča sa Franjom mi je dodatno bila zanimljiva jer mi je netko ispričao tračeve kako je Franjo pobjegao u partizane jer je mutio za zapovjednikovom ženom te odglumio svoju smrt jer je upao u kartaške dugove! Nije li ovo priča koja se može samo poželiti!

Deborah Hustić je uvrstila “igricu” na Radioninu izložbu “Gaming playground”. Kažem “igrica” jer i nije bilo nečega za igrati u toj fazi.

Nekih godinu dana kasnije odlučio sam staviti i leteće patke, Švabe i metke… Red je ipak da to igrica ima.

Onda sam negdje 2017. otkrio Defold – 2D engine u Lui te si rekoh – idealno za napraviti mobilnu verziju Franje. Pogledah malo dokumentaciju od Defolda i što se može s tim napraviti. Napravio sam ovo – https://www.binarni.net/projects/franjo/defold/. To je to, nema više od toga. Ako ikad skužim što želim napraviti možda nečeg više i bude.

Što je od svega ostalo? Postoji zadnja playable verzija na ovom linku (JavaScript HTML5 – https://www.binarni.net/projects/franjo/2.0/.

Najveći problem je oduvijek bio oko gameplaya. Nemam nikakve ideje kakva bi ovo trebala biti igrica. 2 button casual gdje letiš, skupljaš i lagano se zabavljaš sa šaljivim komentarima Josipa Broza koji te potiče da ideš dalje? Možda opaka pucačina kao Luftrausers gdje imaš potpunu slobodu kretanja? Tko zna… to mi osobno ne djeluje zanimljivo. Nisam siguran da ću ja osobno ikad shvatiti ali više sam nego zainteresiran za feedback. Što ti dragi čitaoče misliš da bi Franjo trebao biti? Nemoj se sramiti!

Sve postove o Franju možete pronaći na ovom linku – https://www.binarni.net/tag/franjo/.

Dorade na zmiji

Napokon sam napravio nekoliko dorada na 404 stranici za http://kur.ac/ site.

Za početak, sve je malo usporeno. Igrači su se bunili da nisu u stanju pogoditi tabletu jer im je sve prebrzo. Dodan je zvuk koji daje 8bit ugođaj. Tableta je plave boje sada. Ne znam kako mi to do sada nije palo na pamet?!

Najveća promjena je da se sada treba obraćati pažnju i na testise. Moguće je dodirnuti zid i pogoditi tabletu s njima. Mašala! Treba viditi koliko će, obzirom da je igrica sporija, ovo olakšati igranje.

Igricu možete isprobati na ovom linku.

Remember the sabbath day

remember_the_sabbath

I made a small Python script for checking how many Git commits have been done during the weekend days. It is a simple idea. Only mark the days when commits have been done. Don’t think too much about number of commits or how many changes have been done. It is up to us to interpret the graph, but you apply it on a project which has been going on for a very long time you can kind of read some things out of it.

Look at the picture above. Graph in the top left corner is from a commercial project. Clearly, nobody cares about it over the weekend. Percentage of activity is around 20%, which means that work has been spread proportionally.

Graph in the bottom right corner is from Django repository. More or less this is how all big Open Source projects look like with lot of participants. Work evenly spread over the entire week.

You can find out more here:
https://github.com/aerkalov/sabbath

Importer 3000!

importer3000

Importer 3000 is here! What is it? It could be the most important moment in the history of Booktype! It could be, but in reality it is just a basic upload form I did for testing new ebook library.

importer_basic

And yes, it could easily look like this but would anyone believe me I have spend more then 5 minutes on this task? Can that simple form explain why am I so excited about new ebook library? Probably not and that is why we have Google fonts and shiny colors! If you are trying to present couple of months of research and work you have spend on backend code, try to use them. It can not hurt.

github

 

Booktype developer’s review: The Django Circus comes to

Original post is here:
https://www.sourcefabric.org/en/community/blog/1878/Booktype-developer%27s-review-The-Django-Circus-comes-to-town!.htm

If I only knew how awesome the Django community is, I would have started attending DjangoCons way earlier. This year the European DjangoCon was held in Warsaw from the 15th to the 19th of May and believe it or not, it was in a Circus tent! It was organised by members of the local Django community and they have really raised the bar for the next DjangoCon in France. Because Django is a central programming language for Booktype I decided to go and check the action from this community of developers and aside from learning a lot of cool new tricks I also had an amazing time!

Fun in the sun

The first three days of the conference were organised at the horse track, next to a weirdly big fountain and an old swimming pool. There was only one track at the time and that proved to be more than enough. The tent was open to the outside providing good airflow and easy access to the lectures. It was outfitted with power, WiFI, projectors, tables for those who can not escape their work and even a refrigerator filled with cold water and drinks. During the day people could easily grab coffee, fruit, sandwiches, homemade energy bars, ice-cream and popcorn in the smaller tent. The organisers provided us with hammocks, deckchairs, bean bags, blankets, frisbees, badminton rackets and many other toys. Many times it just felt like we were at a music festival and not a developers conference.

Django experts visit the festival

But it was not just about the food and frisbee. The event was packed with interesting people and projects, and this is what conferences are all about, meeting new people. Russell Keith-Magee (President of the Django Software Foundation), Andrew Godwin (Django and South), Tom Christie (Django REST Framework), Kenneth Reitz (Requests and Python Software Foundation), Steve Holden (Python Software Foundation), Zed Shaw and Aymeric Augustin (Django) were all present, just to name a few.

You could feel the spirit of open source and the Django community at the festival. Everyone was more than friendly and very approachable. I guess all the stories about how the Django and Python have one of the friendliest communities are true after all! The best place to see this was during the last two days of the conference. The coding sprint was organised at the Gamma Factory and the first day it was attended by more than 200 people. Instead of junk food the organisers provided us with more healthier meals. But enough about the food. Members of the Core Django team and developers who have already contributed to Django were more than helpful and patient with the newbies and people who just wanted to help with coding, documentation, testing or sometimes just organising old tickets in the system.

It was a very positive and enriching experience. I encourage you to think about participating at DjangoCon next year or just visit one of the local Django/Python gatherings in your country. You will not know how stimulating it can be until you try it!

As they say, a picture tells a thousand words! Check out the video from the festival.

E-Book Web Reader ~ Rheya ~

info

I had a small coding sprint over the weekend. It would probably be better if I played Minecraft entire weekend but somehow i couldn’t stay still until I put my thoughts into code….

The code is not really representative, I just wanted to check the feeling of using this new Web interface for the books. I have two not fully functional interfaces: desktop and mobile one. I am aware it does not work on Android (the footer), the inner frame do not resize as they should and some buttons do not work. Like I said… just a proof of concept for now. But a proof of concept which has support for keyboard shortcuts and you can change color/text theme. What more do you need?!

mobile_font

But when it is finished… ohhhhh when it is finished! It will work in offline mode, it will support bookmarks, sharing, annotations and many many more things. It can read epub2/epub3 books for now but I will integrate it with Booktype online books when I get some free time.

You can check the code here:
* https://github.com/aerkalov/ebook-web-reader/wiki

Demo books:
* https://www.binarni.net/projects/rheya/metropolis/ (Desktop version)
* https://www.binarni.net/projects/rheya/the-binary-chronicles/ (Desktop version)
* https://www.binarni.net/projects/rheya/metropolis/mobile.html (iPad version)
* https://www.binarni.net/projects/rheya/the-binary-chronicles/mobile.html (iPad version)

Soooo…. what do you think? Would this be a good interface for online/offline books?

Booktype-scrolls: Ubuntu installation

First in a series of screencasts – How to use Booktype-scrolls script to install Booktype on Ubuntu.

Script is smart enough to figure out what needs to be installed on Ubuntu, Debian, CentOS or Mac OS X. You will be informed about every step and nothing will be installed on the system without your confirmation or knowledge. At the moment script works with Sqlite and builtin Python server. That will be changed in next version but for now this is more then enough if you had problems installing it for yourself. You can read more about the script in my previous post – https://www.binarni.net/2012/07/booktype-easy-install/.

For more information check out official installation docs – https://wiki.sourcefabric.org/display/Booktype/Installing.