Sign in to follow this  
Andrew Blem

Unity Is the use of path finding algorithms a good idea for dribbling in sport games

Recommended Posts

Well I  have been working on a soccer game for the past few months ("still learning unity 3d. its my first game"). I have recently come across some minimum path finding algorithms in my studies ( Prim's algorithm, Djikstra algorithm, a*, fFyod etc). I have been thinking of adopting one of these algorithm into my game to help in the players navigating around the soccer pitch to reach the opponents goal. This algorithm will be used during player dribbling and the map will be periodically updated or i was thinking the dribbler will create a map  and decide which path to go to minimize resource usage. I know the best way of learning is trial and error but I would love some heads up on this one. So what do you think I should do

Share this post


Link to post
Share on other sites

It seems to me like you're going to get a lot of complexity for very little gain. If we ignore players for a moment, there are no obstacles with which the players can collide, so you don't need a path finding system to move them around. Now if we consider players, you have obstacles but their positions are changing so often you will have a challenge maintaining the graph used for path finding. You'd either need to constantly recompute paths, which means that most of the last computed path would have never been used, or you're going to need to do a lot of work to predict where players are going to be.

 

Think about a path as having two sets of constraints - static and dynamic. Static constraints are those that do not move, such as buildings or cars or whatever else can just sit there in your way. Dynamic constraints would be other moving objects or players. Minimum path algorithms are great with static constraints.

 

In handling dynamic constraints in path finding, you generally use various steering behaviors to avoid the collision, or you replan the local portions of the path. In your application, your static constraints are going to be essentially non-existent, and you will have a lot of dynamic constraints on a path. So the question is, if we need to use short localized paths or steering behaviors to handle all these dynamic constraints, and there are no static constraints, what does path finding get you?

 

I think steering behaviors are your best bet for this because they are more suited to constant re-evaluation and they are more localized than a path finding approach. If you check out the book "Programming Game AI by Example" by Mat Buckland, you'll get some ideas for combining steering behaviors and how to implement them to give you good results in a sports game. There is also a good amount of information online for steering behaviors, but it's usually for more simple actions such as Seek, Flee, Patrol or Wander. The book will give you information on the more interesting ones like Interpose, which is going to be useful when getting players to intercept a pass.

Share this post


Link to post
Share on other sites
In an AI I took class we implemented simple pathfinding once using repulsor and attractor fields meaning you can add shapes to grid that effect a flow vector for every other point on the grid. Enemies would push away for a short range, the target would pull from a very far range. Our pathing agents would simply follow the flow. It worked surprisingly well, although it wouldn't work at all in a maze but a soccer field really isn't a maze.

You could have different fields depending on the state of the player (ie, on defense vs on offense with the ball/without the ball). Also something to note, you don't calculate the entire flow field, just the single point where the player is.

Share this post


Link to post
Share on other sites

I don't see enough reason to do path finding in a soccer game. Soccer field is an open space that you can establish a line of sight from anywhere to anywhere. All obstacles in the soccer game are other players which are dynamic and bad candidates for caching and sharing their states, which can be very bad if every player is also doing his own path planning periodically. Steering behaviors seem more suitable for this type of game. The natural looking movement is also a nice bonus.

Share this post


Link to post
Share on other sites

I seem to be doing this often as of late, but i second the recommendation to check out "AI game programming by example" by buckland. In fact, it's probably one of the best "game dev" books i have seen on the subject. Matt actually does a soccer pitch as a multi agent sim. It would definitely give you a good starting point. the key points are that agents use steering behaviors (such as seek, interpose, and wall avoidance) to navigate the pitch.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this