Posts mit dem Label agent werden angezeigt. Alle Posts anzeigen
Posts mit dem Label agent werden angezeigt. Alle Posts anzeigen

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.

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, 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, 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.

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!