Football game coursework, I need help writing a script.

6 views (last 30 days)
Im writing the script for a player who needs to move to wherever the ball is on the pitch which will change through out the game. I just need him to chase the ball and stay on the pitch and I don't really know where to start with it any help would be appreciated, thanks.
  4 Comments
John D'Errico
John D'Errico on 5 Feb 2015
Were I a betting man, my bet would be that the reference to pitch suggests it is a different kind of football indicated here.

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 5 Feb 2015
The most sophisticated solution is likely a Kalman filter. However, I would start instead with a relatively simple Pursuit curve solution. This would likely be much easier to implement.
  2 Comments
Jack Johnson
Jack Johnson on 5 Feb 2015
That looks like the right thing I just really don't know where to start on writing the script but thanks for the help
Star Strider
Star Strider on 5 Feb 2015
My pleasure!
I doubt that an analytic solution would be appropriate, since the trajectory of the football is always changing. (If you have the Symbolic Math Toolbox, that might where to start, though, to give you some idea of how the differential equation solves the pursuit problem in a simple system. Use matlabFunction to create an anonymous function so you can see it outside of the Symbolic Math Toolbox, and so without all that Toolbox’s computational overhead.)
You likely need to explore the various ODE solvers to determine the best one for your simulation. I would start with ode45, and use the ‘Events’ structure to determine when the ball or player goes out-of-bounds. You will likely use ode15s, since it is much more robust in ‘stiff’ problems, and this could be one such.
It seems to me that this is quite complicated, although for a simple trajectory it might be easy. If it gets involved, you might consider searching out the solutions video game developers use, and how the various video game engines handle those problems. At least in your simulation, you likely don’t have to worry about the offsides rule!

Sign in to comment.

More Answers (0)

Categories

Find more on Just for fun in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!