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