Jump to content

  • Log In with Google      Sign In   
  • Create Account

Soccer AI


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Freeky   Members   -  Reputation: 195

Like
0Likes
Like

Posted 16 July 2014 - 05:09 PM

Hi,
 
I want to make a retro-ish soccer game. I want to keep it as simple as possible. I thought about basing it on 'Exciting Soccer' (video) or 'Nintendo World Cup' (video).
 
The only problem is making the AI. The ideal scenerio would be that I can first make the game AI only (so it basically plays itself) and later add an option for the user to take control of one player.
 
I'm not aiming for a super intelligent AI, but rather for a 'kind of interesting to watch' AI. 
 
I am aware of the book 'Programming AI by Example' wich has a whole chapter on this topic. And I don't own the book, but I have seen videos of the result and I'm not really impressed. If you look at this video you might understand what I mean. It seems like only the players closest to the ball are doing anything. Also note what players 4 and 7 are doing at 0:14. 

 

I find the AI of Exciting Soccer way more interesting, although it's actually very stupid. I just like how all the players are moving along with the ball and the game.

 

So my question is: Does anybody have any advice on how to make this? How do I make a fun-to-watch game of (seven a side) soccer where all players in the team seem to be playing together?

 

Many thanks!

 

Freek



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 32041

Like
4Likes
Like

Posted 16 July 2014 - 05:33 PM

If you've never implemented 'boids'/'flocking' before, I would start there. This is just a simple combination of 3 simple behavioral rules, from which the group behavior of a flock or birds emerges. If you add a rule that says "move toward the ball" it will probably produce 8yr old soccer players laugh.png

From the basics of flocking, you can continue to add more behaviors, and use a priority system so some override others.
e.g. One behavior might say "if you are close to an opposition player, try to stand between him and the ball", but another behavior might say "If a team mate has said they are passing to you, run in a direction sub that you will intercept the ball". You would want the latter behavior to override the first -- once you receive a message saying "I'm passing to you", that second behavior should kick in, and it should be so high priority that the player no longer attempts to block opposing player, he only runs into position to receive the pass.

From enough simple behaviors and messages between players, some decent soccer play could emerge.


Then, as a completely different task, I would make an AI for the team itself (the coach/manager if you like). This would contain a database of plays/formations/positions - where the players should be in different situations. A soccer fan/expert would create this database from their knowledge of the game. You might have to make a "formation editor" tool so that you can create this database of knowledge.
Then periodically during the match (once a second, or whenever an event occurs like a change of possession), the "team AI" looks at the current position of every player plus the ball and picks an appropriate formation / position for each player.

The player AI then will have a behavior telling it to try and go to the position that the team AI wants it to be in, as well as fulfil all it's other behaviors, such as following the ball, staying onside, moving toward the goal, etc. The priority of each behaviour can change dynamically depending on what's going on. Blocking a player is low priority if no one is near you, but gets higher if someone is right next to you. Moving to your position is low priority if you're already there, or within 1m of it, but becomes a higher priority if you're 50m away from where the 'team AI' wants you to be. 


Edited by Hodgman, 16 July 2014 - 06:01 PM.


#3 jefferytitan   Crossbones+   -  Reputation: 2247

Like
2Likes
Like

Posted 16 July 2014 - 05:50 PM

I like Hodgman's answer, but I also feel like there should be a level somewhere in the middle regarding clear paths. If a player doesn't have a good shot at goal, I would suggest keeping an eye on how many team members they could kick it to, and how many opposition members are nearby. That way they can make a decent judgement of when to pass the ball.

 

At the higher end I would suggest individual team member preferences and abilities, so they have some flavour. So some of them are offense/defense oriented, some focus on assists, some do long kicks, etc.



#4 Freeky   Members   -  Reputation: 195

Like
0Likes
Like

Posted 16 July 2014 - 06:47 PM

Thanks for your reply!

 

I have heard about flocking before, but never thought that it could be usefull for something like this. I will definately have a look at it.

 

The formation database system would be the most complicated part by far, since the players should find a balance between keeping to their formation, and wandering off to mark an opponent, or to get to the ball or wathever. (And of course to keep in more interesting)

 

Passing is indeed also a problem. I think I'm going to do that by looping through all teammates and giving each of them a 'score' for how good it is to pass the ball to them. Then pass to the one with the highest score. I was also thinking about using this system for positioning the players in some ocasions.

 

Player spesific skills and characteristics is something for later. I first want to focus on making some identical players play a game of soccer, then I'll make different players/teams.



#5 jefferytitan   Crossbones+   -  Reputation: 2247

Like
0Likes
Like

Posted 16 July 2014 - 07:31 PM

I think that optimal play (for some metric of optimal) is a good start. But later down the track remember to allow sub-optimal choices, e.g. pass to the second best option, because optimal play is predictable play.



#6 ferrous   Members   -  Reputation: 2147

Like
2Likes
Like

Posted 16 July 2014 - 08:39 PM

You may want to search for the term robocup, it's a tournament that's held, i think every year, that pits different AI soccer teams against each other.  Mostly done by universities.  You might look at some example AIs that you like and use similar strategies.



#7 Stainless   Members   -  Reputation: 1070

Like
5Likes
Like

Posted 17 July 2014 - 02:46 AM

[insert tongue in cheek]

 

And remember you have to add special cases if you want the game to be at all related to soccer.

 

Special animations for players diving through the air like they have just been hit by a 50 cal hollow point round when anyone comes within 10 feet of them.

 

Animations for biting players if they get in the way

 

Animations for yelling at the referee

 

Any physics you apply must have built in an ActingEffectInstance, a special float parameter that can be applied to all forces if there is the slightest chance that doing so will result in a free kick.

 

And finally an OverActingEffectInstance that has to be applied to all bone deformations in the same situation.

 

[remove tongue from cheek]

 

Robocup is a good idea to read up on, but soccer AI is one of those things that the actual AI design is simple, but making it work as a game is much more complex.

 

FIFA and Pro Evo both use a region system.

 

For example if the ball is in your defensive third and not in your possession, all players have a location they should be stod in. As the ball moves through the pitch they move towards predefined points depending on the possesion of the ball.

 

They also use a simple passing system that goes something like

 

 

Player Type         Position        Actions

Defender             own third         pass midfielder, pass defender, kick ball out

Defender             middle third     pass midfielder, pass defender, pass goalkeeper

 

and so on.

 

These are modified by "Pressure" which is the presence of opposition players and player commands (call for a through ball etc)

 

It's essentially very simple, the complexity comes trying to use all these parameters that players have in a way that has an effect on the game without being contrived.


Edited by Stainless, 17 July 2014 - 02:54 AM.


#8 Freeky   Members   -  Reputation: 195

Like
0Likes
Like

Posted 17 July 2014 - 09:23 AM

Thank you.

 

I have been observing many different soccer AI's, including RoboCup. Although I've noticed that RoboCup AI's are way more complex than most (retro) game AI's. For what I'm planning to do, I'd like to keep it as simple as possible.

 

The system I've used in my first prototype is the one I told about earlier. Only a few players on the field are 'active': The ones from each team that are closest to the ball, and a player that is about to receive a pass. For the rest I loop through many positions on the field placed in a grid, and apply points to them based on many different factors.

 

For example some of these factors are:

 - Can I receive a pass from the player with the ball from this position

 - Is this position close to my home position (So that not all players will go to the same position)

 - Can I shoot on goal from here?

 - Are there no opponents to close to this position?

 - Isn't there a teammate already at this position?

 

These are all for the team that has the ball, the defending team of couse has other factors, wich I still need to work on a bit more.

 

A similair strategy is also used to find the best player to pass to.

 

I like how it looks so far, but it still needs a lot of tweaking. I've seen players pass back to the keeper when they could also have shot at goal for example. 

 

The formation database system Hodgman talked about (and wich apparantly is also used in FIFA and PES) would probably be better, but it will be much more complicated and I'd seriously have so study soccer tactics. Also, I like how chaotic my current system is. :)

 

Thanks again, and more tips and suggestions are welcome!



#9 GoCatGo   GDNet+   -  Reputation: 1637

Like
0Likes
Like

Posted 18 July 2014 - 08:39 PM

I'm always impressed with the behaviors I get when implementing any sort of flocking.  While I've never played soccer on a field or on a game, I have created some killer squad-based movement for a combat based game by combining small flocks into a large flock.  I'm sure this idea can be tweaked for the various duties of footballers (I imagine they are defensive and offensive players and whatnot).

 

I created a "base" flock of five agents -- four grunts and a leader.  The grunts flock (averaged direction and speed, tight cohesion) based on the leader's movement.  There are several of these groups with all of the leaders being a separate "flock" that is moving toward a military objective with different cohesion rules.

 

For the player, this created a really aggressively moving group of soldiers advancing on a position.  How you can make this work to emulate soccer, I'm not sure. 

 

Also (this has nothing to do with the OP), since when did Americans start caring about soccer?  240 years of no interest in the World Cup came to a crashing halt this summer.  Everywhere I went had it on the TV.  What gives? 


Indie games are what indie movies were in the early 90s -- half-baked, poorly executed wastes of time that will quickly fall out of fashion.  Now go make Minecraft with wizards and watch the dozen or so remakes of Reservior Dogs.


#10 racarate   Members   -  Reputation: 135

Like
1Likes
Like

Posted 24 August 2014 - 12:30 AM

i've been working on a soccer too, this video looks like it might have some good 1988-era tips:

 

http://www.gdcvault.com/play/1019341/Classic-Game-Postmortem-Kick

 

likewise, i've gotten a good bit out of studying the code from freekick3:

 

http://codeflow.wordpress.com/2012/12/09/the-ai-in-freekick-3/


Edited by racarate, 24 August 2014 - 12:32 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS