Donnerstag, 18. November 2010

Combat Damage in Season 2

The combat damage in ZeroX has been quite high. Until now the combat damage has been divided inversely proportional to the population size, both agents suffered the same combat damage.
With season 2 this will change in favor of the bigger adversary. The combat damage for the smaller will remain the same. But the damage for the bigger will also be inversely proportional to the population sizes. Let's compare the two algorithms with a seek and destroy sequence with:

  Season 1 Season 2
step   Agent 1 Agent 2 Agent 1 Agent 2
1 population 1000 1500 1000 1500
combat damage 600 600 600 400
2 population 400 900 400 1100
combat damage 276 276 293 107
3 population 124 624 106 993
combat damage 103 103 96 11
4 population 21 521 10 982
combat damage 20 20 10 1
5 population 1 501 0 981

As in season 1 both adversary were classified excat the same, therefore they suffered the same damage. The bigger one could never take advantage of his population superiority. This will now be considered.

Mittwoch, 10. November 2010

Secure your steps, how to disengage from a move action

Update: This feature has been removed in with the beginning of the 3rd season. Instead use look_at for agents in level Clone War.

In Zero X the simulation and all agents are running continuously. That's one big difference to other programming games, that usually are round based. The consequence is, that in the time between an agent inspects his environment with a look_around and the action he takes, with a move_to for example, the environment can change.
For example a field is free, when he makes the look_around, but has been occupied in the meanwhile by another agent, when he moves. This would result in a unintended attack against this other agent.

Although this case is rare, as a look_around and a move_to are very close. But this time gape can grow bigger as the analysis of the environment takes more time. In general agents have to deal with this kind of insecurity about their perception. This one of the many challenges in this game.

But in order to handle better this kind of insecurity, starting with season 2, move_to can now take a block.
move_to(x,y) {|target| ... }
The argument passed to the block is another view of the target field at the exact time of the movement. This gives the agent the chance to check the preconditions of his action. If they are not fulfilled anymore, he can now disengage from the move action.

move_to(x,y) do |target|
  unless target.has_no_population?
     disengage 'field is not free anymore!'
  end
end
Disengage can take a message, that will then be displayed in your reports. The action is canceled and the agent remains on his starting field. But disengage comes not for free. A move_to would cost 6 action points, disengage from this action still costs 3 action points.

Disengage can only be used within an action block like the one in move_to.

Donnerstag, 26. August 2010

The End of Season 1

The 10th tournament ended actually with two winners, Bulldog and Rincewind. Both made 6.8 points, Bulldog is only ranked first, because he has a better overall ranking.

After 10 tournaments, it's time to look back. The first tournament began with 9 agents, by now the agents have doubled. They not only have become more, no they also have become better. FireLion the winner of the first two tournaments, looked in the beginning very promising, but in the meanwhile has been displaced to the 10th rank. Others have come with a better strategy.

After total 46 games, the ranking list can grouped in three parts:
There's the 5plus group, agents that have an average of more than 5 points. Means they don't only survive in most of the games, the also achieve better ranks. WoodElf, Bulldog, Gruyere, Oreiller, Mild Gruyere and Rincewind are in this group.
The second group are agents that survive sometimes, they have an average of 3 to 4 points. And then there's the last group that have less than 3 points, meaning they don't survive very often.

But remember this tournaments are not only about winning or loosing, in fact I don't see any loosing in contributing an agent. It's about to figure out which strategy works better then another.

After 10 tournaments we make a break and end the first season. We will continue the tournaments in October, the exact date will be announced.

Congratulations to everybody and see you soon for the second season!

Samstag, 31. Juli 2010

Attacked Events

In Zero X some events are directly reported to the agents. They can read them, during their think method with next_event or iterate over them with each_event. The event will be removed as soon as it has been read.
event = next_event
event.class    # => AttackedEvent
event.attacker # => '003' agent code name
event.damage   # => 132
If an agent is attacked by another agent, the victim receives an attacked event. The event includes the code name of the attacker and the damage suffered.

Here an example with an iterator:
each_event do |event|
  if event.instance_of? AttackedEvent
    puts "attacked by #{event.attacker} and suffered #{event.damage}"
  end
end
In your tests you can fire the attacked event by using has_been_attacked_by. The method takes the codename of the attacker and an optional damage parameter.
it "should behave different if it has been attacked" do
  @agent.has_been_attacked_by '003'
  @agent.think
  ...
end
The new test methods are available with SDK Version 0.9.7.
Download the new SDK V0.9.7

See the documentation.

Donnerstag, 22. Juli 2010

Bulldog wins 9th tournament

Bulldog won the 9th tournament with 8.0 points. He won 2 games, made one second place and a third place.
Wood Elf, the high flyer of the last tournament, made this time only 4.6 points and was placed at rank 6, still holding the first rank in the total ranking.
Newcomer Mild Gruyere won 1 game and is placed 4th in the tournament ranking.

I'm still experimenting with the runtime velocity of the simulation. This time the simulation run even slower, the action cost to time unit ratio was 1/15. Like this the resource reached their maximum at the end of each game. I think will keep the action costs in this range for the next tournament.
class Agency < Tournament::Agency
  level 'Greenfields'
  agents_per_game 22
  games_per_agent 1
  game_duration 300 # sec
  time_unit 45 # sec
  action_cost_time_unit_ratio 1.0 / 15.0
  build_options 'Greenfields::World' => { :size => 8 },
                'Greenfields::Resource' => { :size => 4000..16000 },
                'Greenfields::Population' => { :size => 40..160 }
end
Ranking of the 9th tournament.

Montag, 5. Juli 2010

High-Flyer

Incredible! Wood Elf makes the perfect tournament with 10 points! This means she won all 5 games in the tournament. Having a look at the rankings of Wood Elf, we see that, in the 4 tournaments she participated, she won 3 of them and made a second place in the other. This is clear an outstanding performance.
She now leads the overall ranking with 7.85 points, leaving the second placed Gruyere with 5.69 points behind.

The world size for this tournament has now been increased by one to eight. And the simulation run even slower, one time unit now took 30 seconds.
Here the whole configuration for the last tournament:
module Greenfields

  class Agency < Tournament::Agency
    level 'Greenfields'
    agents_per_game 22
    games_per_agent 5
    game_duration 1800 # sec
    time_unit 30 # sec
    action_cost_time_unit_ratio 1.0 / 10.0
    build_options 'Greenfields::World' => { :size => 8 },
                  'Greenfields::Resource' => { :size => 4000..16000 },
                  'Greenfields::Population' => { :size => 40..160 }
  end

end

Ranking of the 8th tournament.

Sonntag, 20. Juni 2010

The 5th and 6th Tournament

For the last two tournaments there were 5 games each and 16 agents, who participated.
We had an amazing newcomer "Wood Elf", who left with 7.8 EPS all other behind. In the 5th tournament Wood Elf won 2 games, made a second and a third place. But she also takes the first place in the overall ranking. FireLion falls back to the third place.

In the 6th tournament, Gruyere strikes for the second time. One game won, 3 times a second place and one third place, gives him excellent 8 EPS. Gruyere takes now the second place in the overall ranking. Will he become number one in the tournaments to come or can Wood Elf defend her position?

As in the last post announced the simulation runned slower for the last two tournaments. The action cost to time unit ratio has been set to 1/4. Also the world size has been increased and has now a size of 7. Here the complete configuration for the last tournament:
module Greenfields

  class Agency < Tournament::Agency
    level 'Greenfields'
    agents_per_game 16
    games_per_agent 5
    game_duration 1800 # sec
    time_unit 12 # sec
    action_cost_time_unit_ratio 1.0 / 4.0
    build_options 'Greenfields::World' => { :size => 7 },
                  'Greenfields::Resource' => { :size => 4000..16000 },
                  'Greenfields::Population' => { :size => 40..160 }

  end

end
Checkout the the ranking.

Dienstag, 25. Mai 2010

Decoupling action costs from time units

The first tournaments showed, that the resources grow too fast. Fields with no population reach soon the maximum of their capacity and when an agent fights another agent, it can recover from the combat damage in no time.
As SayCheese pointed out, at the time the game is stopped, the winner is more or less random, as all survived populations are more or less at their maximum. Actually there's no real fight for the best remaining resources.

To bring some more challenge in the game, the simulation should run a little bit slower, while the agents still have the same time for their actions. Therefor the action costs will be decoupled from the time units in the simulation. Action costs are now a fraction of a time unit. A look_around doesn't take 2 time units anymore, but 2 action costs.
For the next tournament an action cost will be a quarter of a time unit. Means the simulation will run 4 times slower until now. In consequence the resources and the populations will grow 4 times slower.

Dienstag, 11. Mai 2010

Surprise in the 4th tournament

The 4th tournament comes with a surprising winner: The Good, a demo agent.

How could a random agent win this tournament? Does this prove, that the whole tournament is just a random game, doesn't it?! I don't think so!
Rather I think, that we reached a turning point.

In this 4th tournament 14 agents participated, most of them optimised to go for the best resource. As everyone wants the best resource, the only question remains, who gets it first. However all too often two or more agents saw the same field, that seemed to be free, and so they decided to move there. Leading in an unintentional attack against another agent, who had the same idea, but was a little bit faster moving.
This effect was aggravated by the fact, that the small 6x6 matrix was quite crowded with 14 agents. More than a third of the fields were occupied.

While everyone stumbled over each other, The Good just walked to a random free field, which was with the utmost probability better than the one he came from, but not necessarily the one with the best resources. Like this he could grow without being bothered by anybody.

Though The Good could not convince. He achieved only 5.75 points, meaning in 3 games he got only the minimum of 5 points and 8 points for a second place. As comparison Fire Lion and Gruyere won theire past tournaments with 9 points!

But for all that, we can learn a thing from this tournament. If the matrix gets too crowded, going only for the best resource may not necessarily be the best strategy, the second best may be better.

Dienstag, 27. April 2010

Gruyere wins 3rd tournament

The 3rd tournament brings a new winner. Gruyere wins 3 of 4 games and is placed 3rd in the fourth one. Last time Gruyere made only 3.25 points, this time excellent 9.

The newcomer of this tournament is Rincewind. He wins one game, one 2nd place one 3rd place. He achieved the 2nd place in the tournament and takes the 3rd place in the total ranking.

What happened to Fire Lion? In this tournament he dies in 2 games, and gets only 5 points in the other two games. Still he can defend his first place in the total ranking. But the question is now, for how long?

In this tournament a new thread scheduler came into operation. Now all agent threads are synchronized before they can execute an action like look around or move. Like this some raceconditions, that happend last time, could be avoided.

See the tournament Ranking

Dienstag, 13. April 2010

Fire Lion wins again

Fire Lion wins also the second tournament and keeps the lead. One first place, a second place and two third places out of 4 games.
But we have also two impressive newcomers, Dirty Harry on the second place and Appenzeller on the third place. Each of them have won a game. Tentacle Cat last time on the second place, is now placed fourth, even if it also won one game.

In this second tournament we had now 12 agents. The parameters were the same as in the last tournament, expect that the world size has been increased to 6.

See the tournament rankings

Montag, 12. April 2010

Zero X Präsentation

Am Mittwoch 14. April 2010 werde ich die Gelgenheit haben Zero X der Ruby on Rails Usergroup Schweiz vorstellen zu können.

Zero X ist ein Ruby Programming Game. Wie in solchen Games üblich, spielen die User nicht direkt gegeneinander. Stattdessen programmiert jeder Spieler ein Agenten Progamm, das dann gegen die anderen Agenten antritt. Die Agent in Zero X sind in eine simulierte Welt eingebettet, die kleine ökologische Systeme abbilden. Ziel ist es, dass die eigenen Agenten in diesem System überleben oder gar die anderen übertrumpfen können,

Freue mich jetzt schon auf spannende Diskussionen...

Mehr Infos unter www.zero-x.net

Montag, 29. März 2010

And the winner is ...

We had 9 agents in this first tournament, each participated to 4 games. A game took 30 min or 360 time units.

Fire Lion won 2 games and was placed second in the other two games. He clearly gains the lead! Congratulations!
See the entire ranking list here.

Here the setup parameters for the tournament:
module Greenfields

  class Agency < Tournament::Agency
    level 'Greenfields'
    agents_per_game 12
    games_per_agent 4
    game_duration 1800 # sec
    time_unit 5.0  # sec
    build_options 'Greenfields::World' => { :size => 5 },
                  'Greenfields::Resource' => { :size => 4000..16000 },
                  'Greenfields::Population' => { :size => 40..160 }
  end

end
The resources and the populations had the following properties:
resource :capacity => 100000, :birth_rate => 0.15, :death_rate => 0.05
population :birth_rate => 0.2, :death_rate => 0.05, :hunting_rate => 0.05, :needed_food => 2.0

What are your observations for this first tournament?

Samstag, 27. März 2010

First Tournament

The frist agents have gathered for the first tournament. And we are curious to see the very first winner on:


29. March 2010



See it on Zero X.

Donnerstag, 25. März 2010

Free Actions

Release 0.9.5 introduces two new actions. Both are free, means, they don't take any actions costs.

First with info you can now store messages during your agents think method. Later you can analyse them in the reports of the game reviews. All messages saved this way are private. Only the owner of the agent can see them.
info 'my secret debug info'
Second is time. Time simply returns the time units elapsed since the game has been started.
time # => time_units in floats
This is the last release before the first tournament will take place.

The documentation and the SDK have been updated.

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: