Monday, July 18, 2011

Host your own Roborumble server

There are several reasons why you might want to run your own Roborumble server. Maybe you would like to run small local contest at your school or workplace. Or maybe you are testing your new shiny robot. Or may you want to collect some battle data, like myself.

The current Roborumble server is created and maintained by Darkcanuck. Luckily he shares the RumbleServer sources via subversion. It is implemented in PHP and MySQL.

Because I'm not PHP+MySQL expert, easiest solution for me was to download ready-made LAMP virtual machine and configure it.
I know you are busy ;-), so I published my virtual appliance, you could just start using it. You can download it and run it in VMWare Player. Password is robocode, you should change it as soon. Or you could follow the guide below.

Configure server

Once you have LAMP stack up and running you need few things:
Install subversion client
Get PHP sources
Configure RumbleServer
Turn on URL rewriting mod in Apache
Configure MySQL database and grant permissions

The appliance has could be configured from web admin. You can access it on https://192.168.1.12/ where 192.168.1.12 is the IP address assigned to the virtual machine by your DHCP server. I will use 192.168.1.12 which was assigned to me in rest of the article.


Webmin->Global configuration
  ->Configure Apache Modules->rewrite: switch ON

MyPhpAdmin
  Create database->roborumble   Import script schema/schema.sql
  Priviledges->add new user->
    name->rumbleuser
    pass->rumblepass
    Database for user->None
    Global privileges->Select+Update+Insert+Delete

On root shell do something like this
apt-get install subversion
cd /var/www/
mkdir rumble
cd rumble
svn co http://darkcanuck.net/svn/rumbleserver/trunk/ .
chmod g+w templates_c/
chown :www-data templates_c/
cat > participants.txt
[paste participants.txt file and press Ctrl-D]
cd config
cp config.php-sample config.php


Participants

Are defined as list of robots and their .jar files. Big competition is driven by this file. We could simplify our own list like this. We host the file on the appliance in folder /var/www/. So create you own shortlist and update it there. Note there are starting and ending tags.
----
<pre>
jk.mega.DrussGT 2.0.4,http://www.minifly.rchomepage.com/robocode/jk.mega.DrussGT_2.0.4.jar
voidious.Diamond 1.5.34b,http://www.dijitari.com/void/robocode/voidious.Diamond_1.5.34b.jar
</pre>
----


Configure client

Download and install Robocode 1.7.3
Edit c:\robocode\roborumble\roborumble.txt

  PARTICIPANTSURL=http://192.168.1.12/participants.txt
  UPDATEBOTSURL=http://192.168.1.12/rumble/RemoveOldParticipant
  RESULTSURL=http://192.168.1.12/rumble/UploadedResults
  RATINGS.URL=http://192.168.1.12/rumble/RatingsFile
  ITERATE=YES

start c:\robocode\roborumble.bat

Purge data

If you need to purge the data from the roborumble database and start from scratch just delete rows using MyPhpAdmin.
delete from battle_results;
delete from game_pairings;
delete from bot_data;
delete from participants;
delete from upload_stats;
delete from upload_users;


Oh, and once you are done with your local competition, don't forget to redirect back to official RoboRumble server and contribute your CPU power!


Download turnkey-roborumble.2011-07-18.zip.torrent

Thursday, July 7, 2011

HowTo: Pass build property from TeamCity into Freemaker email notification template

There is no magic, once you know it. My use-case was to prefix build number with configurable text before sending an email. The text was represented as TeamCity property system.tc.branch.number in my case.

TeamCity email templates are implemented with Freemaker. The TeamCity exposes all build properties as hash table on SBuild.getBuildOwnParameters().

In the template the instance of SBuild is accessible under build variable. Freemaker allows calling bean properties, in our case it would be build.buildOwnParameters, map lookup thru square-bracket syntax [] and literals are enclosed in apostrophes.

#${build.buildOwnParameters['system.tc.branch.number']}.${build.buildNumber}