Moje zdjęcie
Software Craftsman's Blog by Marcin Pieciukiewicz
Java and Scala development

Tuesday, April 9, 2013

Scalatron Bot Mars imporved to reach 7.5 million energy points in benchmark!

Hi, after playing a little more with Scalatron I've improved my bot in few areas:

Minibots count - now my bot can spawn more mini bots and also my mini bots can spawn other mini bots so they have much more collective force
GoHome influence decreased, until the end of game - mini bots are not so eager to capture master bot, but when game is near to end that force is getting much more important, so master bot could collect minibots energy
Master bot Hunger decreased and Explorer increased - because there are a lot of mini bots in the game, the master bot don't have to look for the food, much more important is to wander with a high pace to collect spawned mini bots

And the results are great. My bot reached about 7.5 million energy point in a benchmark, with 8 million in best round:

Benchmark average 20 rounds score:


Maximum score:


Of course you can find updated source code on github's ScalaBotMars project.

Wednesday, April 3, 2013

Bot for Scalatron – great way to practice Scala

Recently I was pointed to project Scalatron which is a programming game, where bots are fighting in simple arena. The main goal is to capture as many energy points as possible, or at least more than your opponents.


Your goal, as a developer is to write a function in Scala programming language that controls your Bot. In brief your function will be called by the Scalatron server with passed parameters such as the map of area that is visible to your bot. And your function should return a commands that will be passed to your bot. This is very simple mechanism that allows you to control your bot in easy way.

I consider the Scalatron project to be very enjoyable way to learn or practice the Scala language and trying to develop some interesting decisions algorithms.

Scalatron Bot Mars to score 1 000 000 energy points!

My idea to write a Scalatron bot was to equip it with a number of competitive senses and passions. One, to force bot to look after food, other to fear of the enemies and even a sense to fear of small rooms. Here are the list of those senses:

Hunger – looks after eatable beasts and plants
Fear – tries to run away from opponents bots and hostile beasts
Explorer – tries not to stay in one place for too long
CabinFever – tries to avoid small rooms with, in some possibilities, no easy exit

Those senses are used to calculate preferences for direction that bot should move. Most important characteristic of them is that they are exponentially decaying when the distance from interesting object is growing. That way bot will react mostly for the objects that are nearest to him.

Also, to be more efficient, my bot will simultaneously spawn child bots that might have one of two roles (that might be switched during lifetime of spawned bot):

Missile – to track down enemy bots or hostile beasts and blow up when they are near
Hunter – to capture eatable beasts and plants

Those bots, especially those in hunter role have additional senses besides those introduced earlier:

Loner – to avoid being in the same area with other friendly bots
GoHome – to get back to my master bot to be absorbed by it

Those are to summarise main ideas that I have come up with, that allowed me to develop a Mars bot that achieved more than 1 000 000 points in standard scalatron benchmark.

I you are interested in more details how I've implemented that bot, you can find my bot’s source code on github's ScalaBotMars project.