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

Mittwoch, 18. Januar 2012

Extended Actions in Level Clone War

In my last post I described the new introduced action split. This time I want to continue and show you two other actions, that have been extended for the new level Clone War.

Let's start with the look_around action. In level Greenfields this action gives back a view with radius 1. In level Clone War you can now pass the radius as parameter. The view with radius 2 is shown on right.
As it is a circular view, the corners are missing. For those fields you will get back nil instead of a field.

The action costs are dependent of the view radius. A view with radius 2 will cost 5 action points. The one with radius 1 still costs 2 action points and with radius 0 you will get back your own position for 0.2 action points.

new_population = old_population.split(field)
population.look_around(0) # equal to look_at(0,0)  
population.look_around    # radius 1  
population.look_around(2) # radius 2  

You can also get a single field with look_at and pass the field you want to see as parameter. But you have to make sure this field is within radius 1.

new_population = old_population.split(field)
population.look_at(1,0)  
population.look_at(field)

Also the move_to action has some small changes. The action costs for vertical and horizontal direction remain 6 action points, while moving diagonally now costs 8.5 AP.

For more information see the documentation.

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.

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.