Montag, 15. März 2010

Release 0.9.4

I updated Zero X to the current version 0.9.4. This release fixes some bugs and adds some new features. Most of them are all behind the scenes, but some of them you might will note.
The Agent SDK has been revised, as the fixture generator did not create the data, we would expect from the view. This issue has been fixed now, fixtures and view, get by a look_around, are now the same.
In the report active and passive attacks are now distinct by two different colors. When an agent attacked another, the event is marked yellow, while when he was attacked it is marked red. Also you now see a push event, as a consequence of an attack, which tells you where the agent was pushed.

Download the new SDK V.0.9.4

Montag, 8. März 2010

Don't Move

In certain situations it's the best action for an agent to take no action. Don't move just stay where you are.
And sometimes it comes handy when an agent can even move to nil, which has exactly that effect no movement.
move_to nil
move_to 0,0
But until now move_to costed in any case action costs and saved move reports. Now we changed that behavior if nil is passed. It will now take no action costs and will not save a move report anymore.

Update
move_to 0,0 also takes no action costs or saves reports.

Tungmar submitted a patch to check, if your agent has moved or not. In your tests you can now use:
@agent.think
@agent.should_not have_moved

The Documentation has been updated and a new SDK (0.9.3) is available.

Montag, 1. März 2010

Releasing Zero X

I'm pleased to announce, that I released the beta version of Zero X yesterday.
Zero X is a programming game, that let's you create an agent program, that will then compete with others agents in different tournaments.
The first test tournament will take place this month, the exact date will be announced in this blog.

If you are interested in artificial intelligence, artificial life, robotics or cybernetic systems then check it out!

www.zero-x.net


Freitag, 26. Februar 2010

How to initialize your agent

Since last week the first beta testers could access the stage environment of Zero X. I received some first feedbacks and could already fullfill one of the wishes.

In order to have a proper place to initialize the agent, a first callback method has been introduced. Right after the agent has been started after_start is called once.
module Demo

  class Example < Tournament::Agent

    def after_start
      # initialize
    end

    def think
     # called periodically
    end

  end

end
after_start is called just after the thread for the agent has been forked and one step before the think loop. Here's a simplificated code snippet from the game class, to see how it's implemented:
Thread.fork do
   agent.after_start
   begin
      agent.think
   end until stopped?
end
In your test cases the agent should now be created again before each test, as create_agent also calls after_start.
before :all do
  load_field_fixtures 'greenfields'
end
  
before :each do
  @agent = create_agent Demo::TheGood
end
There's also a test helper method create_agent_without_start, if you need to set test expectations before calling after_start.

Thanks to Tungmar for his feedback!

Samstag, 20. Februar 2010

Avoid Ruby 1.8.7 p248 and p249 with ActiveSupport

Yesterday I updated the stage environment of Zero X to ruby 1.8.7, but after that I suddenly couldn't login anymore. The problem was a Segmentation fault in Marshal.load used by ActiveSupport:

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/multibyte/unicode_database.rb:37: [BUG] Segmentation fault

ruby 1.8.7 (2010-01-10 patchlevel 249) [powerpc-darwin8.11.0]

As described in the ticket the error occurs only in patchlevel 248 and 249. So I had to go back to p174 and now everything runs smoothly again.

Sonntag, 7. Februar 2010

Codename Zero X

Zero X is a new programming game, written in ruby and made to write in ruby. The first level is based on the greenfield scenario described in an early (german) post.
The players can code agents, which then will be uploaded to participate to the tournaments.
I hope to release a first beta version still this month, until then I leave you with a first screenshot showing the ranking page:

Donnerstag, 24. September 2009

Migration auf Ruby 1.9.1

In den letzten Tagen habe ich mein Simulation Projekt auf Ruby 1.9 migriert. Leider verlief die Migration nicht ganz so einfach, wie ich mir das vorgestellt hatte. Teilweise muss nämlich eine exakte Version eines Gems installiert werden, ansonsten hagelt es Fehlermeldungen.
Um Ruby 1.8 und 1.9 parallel auf meinem Mac betreiben zu können, habe ich RVM installiert. Dies installiert alle zusätzlichen Ruby Versionen im Home-Verzeichnis unter .rvm. Zudem werden auch alle command line Befehle wie etwa 'rails' oder 'cucumber' separat gehandhabt. Unter RVM ist allerdings zu beachten, dass alle so hinzugefügten Gems nicht mit sudo installiert werden. Zudem musste ich eine frühere Version von Ruby 1.9, die ich noch unter /usr/local hatte, zuerst wegputzen.

Ich will hier nicht alle Leerläufe beschreiben, deshalb hier gleich die hoffentlich richtig Anleitung:

Um auf Ruby 1.9 zu wechseln:
rvm install 1.9
rvm use ruby 1.9
Darauf installiert RVM automatisch die aktuelle 1.9 Version.

Danach wenden wir uns gleich Rails selber zu. Die neuste Version 2.3.4 ist leider nicht lauffähig unter Ruby 1.9. Wenn auf die Session zugegriffen wird, erhaltet man folgenden Fehler:
undefined method `^' for "c":String (NoMethodError)
Deshalb muss auf 2.3.3 zurückgegriffen werden:
gem install -v='2.3.3' rails
Mein Projekt nutzt Cucumber und RSpec als Testframeworks. Hier können zwar die neusten Versionen installiert werden, jedoch muss auch Test-Unit mit der Version 1.2.3 und zwar exakt diese mitinstalliert werden:
gem install cucumber rspec rspec-rails webrat
gem install -v="1.2.3" test-unit
Als nächstes meldete Nokogiri, das von Webrat genutzt wird, einen Konflikt:
dyld: lazy symbol binding failed: Symbol not found: _rb_intern2
  Referenced from: /Users/adm/.rvm/gems/ruby/1.9.1/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.bundle
  Expected in: flat namespace

dyld: Symbol not found: _rb_intern2
  Referenced from: /Users/adm/.rvm/gems/ruby/1.9.1/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.bundle
  Expected in: flat namespace

Trace/BPT trap
Um diesen Konflikt zu lösen musste ich über Ports meine libxml Bibliothek aktualisieren und Nokogiri nochmals installieren:
sudo port install libxml2
sudo port install libxslt

gem install nokogiri
Danach startete mein Projekt endlich unter Ruby 1.9 auf. Meine eignen Konflikte mit 1.9 konnte ich dank meinen Testsuits innerhalb einer halben Stunde lösen. Gute Tests sind wirklich Gold wert.