Simple Soccer

I will explain some modifications that I made to the application Simple Soccer.  This application is based on Chapter 4 of “Programming Game AI By Example”. Thanks Mat Buckland for your excellent book.

Simple Soccer

This application is based in the creation of agents capable of play soccer. You can see the default application in the following video:

Supporting attacker is always alone.

As you can see, when a player is in the SupportAttacker state, nobody pursues him. So his partner can pass the ball to him easily.

We must choose an opponent to pursue him. For that we create a new state called MarkSupportingOpponent. When a player is in this state, he will interpose between the ball and the opponent. The header file is the following:

MarkSupportingOpponent.h

In the enter function, the player activates the Interpose steering behavior.

In the exit function, the player deactivates the Interpose steering behavior.

If the player is the closest to the supporting attacker, then he updates his target, i.e, the supporting attacker’s position. Else, he changes to the ReturnHomeRegion state, i.e., he returns to his default region.

MarkSupportingOpponent.cpp

You can see the behavior in the following video (Note how the supporting attacker isn’t alone)

But an important question is: What player must we choose? We will choose the closest opponent, that isn’t chasing the ball in that moment. For that, we implemented the isClosestTeamMemberToSupportingOpponent function in the Field Player class. We didn’t implement this function at Goalkeeper class, because the goalkeeper must not pursue the supporting attacker.

The function definition is the following:

isClosestTeamMemberToSupportingOpponent and ClosestPlayerToSupportingOpponent

Keep the ball and wait the supporting player to reach his position.

When the attacker goes to the opponent goal he will make a pass to the supporting player when he reaches his position or he will shoot if he finds a hole in the defense. But what happens if the supporting player is far from his position and the attacker doesn’t find a good shot? Then the attacker will go directly to the goalkeeper or to the end of the field. We must improve this behavior!.  You can see this situation at 0:48 of the first video.

To improve this, if the attacker is closer to the end of field than the supporting player to his final position, then the attacker must protect the ball from the closest opponent player.  If the two players are face to face, then the attacker must give back. You can see the code in this link, you must understand basic algebra( vectors and dot products).

You can see the behavior in the following video. (The blue attacker player covers the ball until he can pass the ball to his partner)

Advertisement

~ by Nicolas Bertoa on October 28, 2009.

 
Follow

Get every new post delivered to your Inbox.