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: