Samstag, 2. Juni 2012

Starting 3rd Zero X Season

On July 7 2012 we start the 3rd Zero-X season. This will be the first season with
the new level "Clone War". The best agents of the 2nd season will be among the first participants.
For now this are Virgina, Say Cheese, Scorpion King and Unexist.

But don't worry as soon as you accomplish the first level "Greenfields", you get
immediately access to the next level. The conditions are still the same:
You need to participate in a least 5 tournaments and win 40 points.

Looking forward to see the first winners.

Mittwoch, 18. Januar 2012

Extended Actions in Level Clone War

In my last post I described the new introduced action split. This time I want to continue and show you two other actions, that have been extended for the new level Clone War.

Let's start with the look_around action. In level Greenfields this action gives back a view with radius 1. In level Clone War you can now pass the radius as parameter. The view with radius 2 is shown on right.
As it is a circular view, the corners are missing. For those fields you will get back nil instead of a field.

The action costs are dependent of the view radius. A view with radius 2 will cost 5 action points. The one with radius 1 still costs 2 action points and with radius 0 you will get back your own position for 0.2 action points.

new_population = old_population.split(field)
population.look_around(0) # equal to look_at(0,0)  
population.look_around    # radius 1  
population.look_around(2) # radius 2  

You can also get a single field with look_at and pass the field you want to see as parameter. But you have to make sure this field is within radius 1.

new_population = old_population.split(field)

Also the move_to action has some small changes. The action costs for vertical and horizontal direction remain 6 action points, while moving diagonally now costs 8.5 AP.

For more information see the documentation.

Montag, 31. Oktober 2011

YAML in Ruby 1.9

The other day I downloaded the production database from Zero-X to my local machine to run some tests.
Everything looked fine until I got to the game reports page, which looked wired, especially the agent views. It seemed that every empty field was occupied by an agent "00".

After digging deeper I identified the error in wrong loaded YAML records. Instead of loading a nil I got Syck::PrivateType. A null with only one ! was correctly loaded, but the data from production system had two !, which were loaded differently.

YAML.load ":a: !null"     # => {:a=>nil}
YAML.load ":a: !!null"    # => {:a=>#<Syck::PrivateType:0x000001024e6b98 ,="" @type_id="null" @value="">}

YAML::ENGINE.yamler  #=> "syck"

I tried the same tests on the production system, that runs Ubuntu 10.10 I get the following output:

YAML.load ":a: !null"     # => {:a=>nil}
YAML.load ":a: !!null"    # => {:a=>nil}

YAML::ENGINE.yamler  #=> "psych"

And voilà all data are loaded correctly! The difference is an other YAML Engine, on Mac OS X Snow Leopard Syck is used, while on Ubuntu Psych.
Some investigations later I got the answer. With Ruby 1.9.2 the standard library Syck was replaced with Psych, which depends on the libyaml library. But here it comes, only if it's found when Ruby is compiled. It still uses Sych as a fallback.

So in order to have the same behavior on my local and production system, I had first to install libyaml using ports and then recompile my Ruby.

sudo port install libyaml
rvm install ruby-1.9.2 --with-libyaml-dir=/opt/local/

You could also use homebrew, that has also the advantage that you don't have to specify the path to libyaml. Homebrew installs to /usr/local, which is checked by the install script.

brew install libyaml
rvm install ruby-1.9.2

Starting irb I still had to change to psych explicitly.

YAML::ENGINE.yamler = "psych"

Rails 3 changes automatically to psych if available.

One day later I found out, that I also could install Psych as Gem instead of recompiling Ruby.

gem install psych


Some other days later, I began a new Rails project and I encountered the following conflict with psych:
../psych.bundle: warning: already initialized constant ANY
../psych.bundle: warning: already initialized constant UTF8
../psych.bundle: warning: already initialized constant UTF16LE

If you have psych 1.2.2 installed, than uninstall it again. Psych 1.2.3 should avoid the double laoding.
see here

Samstag, 1. Oktober 2011

Announcing Level Clone War

The second level for the programming game Zero-X is ready. I'm proud to announce the 2nd level Clone War.

The first level Greenfields introduced basic sensors and actions and showed how to control a single population. With Clone War these sensors and actions will be extended. But we also have a new action, now it is possible to split a population.

Split does two things, first it splits the population into two equal sized populations and then moves the new created population to a field of your choice. Split looks the same as move_to it takes a field or position as parameter for the new population.

new_population = old_population.split(field)
new_population = old_population.split(-1, 0)
new_population = old_population.split(x: 1, y: 1)

As we may have multiple populations now, you need to specify the population you want to apply the action:

population_b.move_to 1, 1

As you can see the new introduced action changes quite a lot. In the next blog post I will describe how some well-known actions have been extended.

For more details see the documentation.

Dienstag, 6. September 2011

Winner of 2nd Season Greenfields

Wood Elf strikes again! The winner of the 1st Zero X season is also the winner of 2nd season.

In the 2nd season disengage was introduced and the combat damage, was changed in the favor of the attacker and therefore rewarded a more aggressive behaviour. But little has changed here as a look at the ranking list shows.

As announced at the beginning of this season: you will need an agent with at least an average of 4.0 EPS and 5 tournaments to get to next level "Clone War". Here are the top five agents, who achieved that goal:

6.62 Wood Elf
6.08 Mild Gruyere
6.08 Bulldog
5.66 Rincewind
4.24 Gruyere

The usual suspects at the top, let's have a look at the agents that have won more than one tournament:

1st places
3 Rincewind
2 Wood Elf
2 Bulldog
2 Oreiller

At first glance it looks surprising that Oreiller didn't made it for the next level with two 1st places. But taking a closer look we can see, that it didn't perform very well between the 2nd and 6th tournament. I'm sure he will join soon as well as Tentacle Cat, both are only a few points away.

In the next few blog posts I want to take a closer look at all the new features of the new level Clone War and introduce them step by step.

Sonntag, 29. Mai 2011

Using Ruby 1.9.2 and Bundler with Zero-X

In the last few months I was working on bringing Zero-X to Rails 3. The new agent SDK reflects this changes in using now bundler.
In addition to the Rails migration, I ported Zero-X to Ruby 1.9.2. The next tournament on the 25. June 2011 will be the first running fully on 1.9.2. So make sure you're testing your agents in the future against 1.9.2.

For those not familiar with bundler and how to install Ruby 1.9.2, here some steps to get you started:
First we need Ruby 1.9.2. The easiest way to install it is by using RVM (Ruby Version Manager). You can get it by issuing this command in your shell:
bash < <(curl -s
Next we need the agent SDK, which you can download form the Zero-X website.

Unpack the SDK and change to that directory. You will now be asked to examine the .rvmrc file. This file tells RVM to use a specific Ruby Version within this directory. In our case the file contains:
rvm use 1.9.2
After controlling the file, type "yes". Now RVM is looking for Ruby 1.9.2 and if it doesn't exists, it will prompt you a warning and the instruction how to install it.
rvm install 1.9.2

Next we need bundler. As we installed RVM for the current user, we don't need to use sudo to install gems.
gem install bundler
Bundler can now install all necessary gems and check their dependcies.
You are set and ready to go:
bundle exec rake
bundle exec autotest

Montag, 17. Januar 2011

Installing Io on my Mac

Currently I'm reading Seven Languages in Seven Weeks by Bruce Tate. The frist new language to learn is Io, a prototype based language. So I installed it on my Mac running Snow Leopard.
These instructions are not by an expert, but just describes the way it worked for me. If you have any suggestions or improvements feel free to add a comment.

The easiest way to install Io is by using Homebrew.
brew install io
If you want the lastest version from github you can alternatively install Io by hand.

First we need CMake, a cross platform make tool. Download the OS X version and install it.

Update: If you want to use the Socket Addon, you must also install libevent.
sudo port install libevent
or use a the corresponding command if you want to install it with Homebrew.

Then we need the lastest version of Io from github. Unpack it and change to that directory, then issue the following commands:
mkdir build && cd build
cmake ..
sudo make install
This will install libraries to /usr/local/lib and add the commands to /usr/local/bin: io and io_static. Then we're ready to test Io's VM with:
io ../libs/iovm/tests/correctness/
If you get an error like this:
dyld: Library not loaded: libbasekit.dylib
  Referenced from: /usr/local/bin/io
  Reason: image not found
Trace/BPT trap
Then we have to show the linker the way to the libraries:
I added these two lines to my .profile.

After that you should be ready to get started.
Io 20090105
Io> "Hello Io" print
Hello Io==> Hello Io

Update: After playing around with Io, I wanted to try out the Socket Addon. But I got this error:
Io> Socket

  Exception: Object does not respond to 'Socket'
  Object Socket                        Command Line 1
The missing libevent library was the cause for this error. Io doesn't complain about it, when compiling, but just skips the addon.