This week I began ideating and working on a coordinated AI system for the opponent team to make the game more dynamic. The coordinator's objective is to set its players up to try blocking opponent passing lanes and get the ball from the opposition.
How I went about this conceptually is quite similar to how I made teammate AI work:-
We have an array of all players on the team .
We have an array of all the opponent positions (whether or not they have been accurately updated).
Use the array of players to scan their respective surroundings and updating the opponent positions array based on any opponents found within the player's viewcone.
Use the opponent position data with respect to the player to carry out offensive/defensive repositioning.
If you look at some of the previous week's work, you may be able to understand how I do the teammate AI repositioning in order to open themselves up for passes. The first pass I made this week at defensive repositioning involved trying to negate/nullify these offensive moves as much as possible by moving the defensive team's players into the passing lane of the opponent closest to them and their anchor position in order to try and win back the ball.
Defensive logic that moves a player to cover off the opponent closest to them such that they can no longer receive a pass from the ball carrier.
As you may have noticed, this functionality is also a form of repositioning and is done with respect to each player's respective anchor positions, similar to offensive repositioning. Defensively, players only reposition if the destination required to cut off a passing lane is within 300 units from their anchor positions or less than 100 units away from the player themselves. What this means is that players don't drift too far away from their positions, however if there is a high chance of winning the ball (<100 unit distance), they fully commit to sticking with their marked player. We also run a check to see if no other defensive player is within 80 units of the opposition player that is to be marked, in order to prevent 2 players from marking one opponent, simply as this wouldn't usually happen.
Video demonstrating the new opponent AI system which can move to positions where it is capable of winning the ball back.
This was a very rough prototype of how a really aggressive/heavy pressing opponent AI would function, but it is quite easy to bypass this defense through quicker passing and simply dribbling through. So the next week will involve having one of the players try to aggress and win the ball back from the ball carrier and making man-marking a little less aggressive, especially so high up the pitch, as this opens up more spaces in behind which teammate AI will find and run into.
Comments