WIP - Simple ai playing soccer against each other

I’m currently letting the bots play for a few hours to see if anything crazy happens or they get stuck.

Once in awhile popping in to adjust some values.

Figure I’d update this with what’s going on.

Bot conditions and inner workings

  • Closest to goal of all ai and players = keep true
  • Closest to ball of all ai and players = attack
  • If attack and keep is true go attack.
  • Ai Distance to player or ai < 500 and > distance to ball = aggressive (boost)
  • Ai Distance to ball < 2000 and ball forward direction is facing ai = shielding
  • Ai Distance to ball > 3000 and is walking, try to dash.
  • Try and hit ball at net if net is in 45 degree angle of players rotation.
  • Hit ball straight if own net is not inside 45 degree angle of rotation, and opponents net is within 75 degree angle.
  • If inside keep box always try and hit ball if ball is not in 45 degree angle of own goal.

Ai director (per team)

The ai director is a script that is basically getting 5 positions based on balls position.

  • Keep position. Range from the center of goal out to the ball. This is set to a vector value for any bot as keep will be walking to stand at.
  • Defensive zone a and b. These are offset from the center trackin out to ball overlapping to the middle of defensive zone up to approximately center of field. The director is determining from these two locations a primary defensive vector for bot to goto if they are defender based on which on is closest to ball.
  • Offensive zone a and b, works the same as defensive zone except it instead chooses the furthest from the ball as ideal location so the offense spreads out.
  • The director also tracks ball and decides if it’s in defensive or offensive mode based on if the ball is closer to the enemy director or itself. Currently using 50/50 but looking to see how making defensive mode be 70% of the field since defensive position is up to half the field already.

The balls influence directly on ai.

  • Ball is constantly drawing a line from each goal to itself to put a vector opposite itself to have a location ai tries to get To in order to be in an ideal location to place the ball between itself and opponent net to better shoot directly at the goal.

Overall

  • Ai is checking what mode it should be in based on the conditions, one bot will always likely be in attack mode going directly to the vector the ball is giving for optimal shooting angle.

  • If closest to goal and not also closest to ball he will go to the keeper location to defend.

  • Ai that is neither keep or attacker will be looking to goto the defensive position or offense position based on the directors choose of offensive or defensive mode.

Progress

  • Currently I’m only working with bots choosing locations and hitting the ball without any delay shield or dashing.

  • Next to implement is dash to see how this effects the bots efforts to be in position quicker.

Final note

  • The ai is bein designed around gibball mode which is strictly twin stick shooter controls in 3rd person.

  • This is for likely 1v1-3v3 or single player mode not using a dedicated server for casual play.

  • Gibball mode is a lot simpler as you cannot catch or lock passes. You simply shield or hit the ball in the direction leaving the game mechanics to hit the ball up or down based on its location in comparison to player. Ie: if the ball is below you. Your player will already be aiming downward and upward if the ball is above you. (To a clamped angle). While you cannot catch looking to incorporate shield catching with magnet and shield. Goal is to create a controller based fun mode to offset ultraball mode.

Video of stream, bots vs bots.


Http://www.ultraballgame.com