## Monday, September 5, 2011

### Virtua Subbuteo Computer AI

In the next few paragraphs, I am gonna attempt to explain what the computer is thinking when he plays against ... YOU! It is subject to evolve as new versions come out but I will make every effort to keep track of the changes.

# Blocking Strategy

That's the easy part. First, the computer sorts the red players (your players) with respect to increasing distance to the ball. For each red player to block, the computer considers a blocking location between the red player and the ball. It then must figure out which of its own players (the blue players) should actually make the block. The blue players are sorted with respect to increasing distance to the blocking location. The first blue player that has a clear path to the destination location is selected and flicked by the computer. In other words, the computer tries to block the red player that's closest to the ball. If it can't, the computer goes to the next one, etc.

The level of play you chose at the beginning determines how accurate the block is gonna be. The level of play affects the speed at which the blue player is gonna be flicked, not its direction. At the highest level, the block will land right in between the red player and the ball because the computed correct speed (flick power) is not modified.

# Attacking Strategy

## Ball is not in the shooting zone

The computer will attempt to advance the ball towards a location right past the shooting the line and dead center width-wise (if not possible, somewhere closer to the current ball location). The computer cycles through all its players (blue players) until there's one that has a clear path to the ball and can hit the ball to the desired location. If the ball can not be hit to the desired location, the computer considers having the blue player hitting the ball to the left and to the right until the ball can be moved the desired distance, if not to the desired location. If the computer cannot find a player to flick, it will say that it is giving up and you will gain possession of the ball.

As you can read, the computer kinda tries to advance along the center of the pitch. In the future, I might try to have him advance more along the sidelines.

At present, the difficulty level has not been integrated into the computer ball advancing algorithm. Maybe in future versions.

## Ball is in the shooting zone

When the ball is in the shooting zone, the computer figures out where the ball should end up for a goal to be scored (between goalie and either post). It then cycles through its players (the blue players) until it finds one that has a clear path to the ball, preference being given to the player that is best aligned with the ball and target location. Needless to say that, if the ball is in the shooting zone, there is a blue player with a clear path to the ball and there is a clear path between the ball and the goal, it's very likely a goal will be scored.

At present, the difficulty level has not been integrated into the computer shooting algorithm. Maybe in future versions.