Advertisement

Tennis game AI

Started by November 08, 2002 02:12 AM
5 comments, last by RajanSky 22 years ago
Hi, I was just wondering if anyone has any tips on where I should start looking for ideas on how to implement AI for a tennis game, so that the computer opponent plays "intelligently" and in a human-like fashion. Currently my idea is basically to combine FSMs with a bunch of ad-hoc tests such as "if the player is near the net, then try to aim further down the court". But I mean, that''s all simple stuff that any kid could implement, given sufficient time, so I wonder if there''s a more elegant or sophisticated way to do it. The only other AI I know is basic search and planning techniques as covered in my course at the university but I''m not quite sure how they would apply to this kind of game.. Well if anyone might have any tips on some AI techniques which might apply to this problem I''d really appreciate it if you could give me some clues =) Thanks a lot! Raj
Sounds like this could be a job for reinforcement learning.

http://www-anw.cs.umass.edu/~rich/book/the-book.html

It might not be the best way to implement tennis ai, but it''s certainly more interesting and fun than a FSM.
Advertisement
I think a simple rule-based AI could do the trick:

- When the ball is hit by an opponent, move to intercept it. Simply, the ball has a straight-line trajectory. Find the point on that line closest to your current position, and move there.

- When you hit the ball, aim the point farthest from the opponent.

- When you''re doing neither of these other two things, move towards the center of the court so you''re prepared to hit the next ball.

That''s all!
You don''t want to make it completely rule based, however. If you were playing the computer, you would know where the next shot is going to go based on your current position and begin to head that way. There are often times where the opponent will hit to the less obvious spot so that you can''t expect it. Some amount of fuzziness should be applied to break up the predictability.

Dave Mark - President and Lead Designer
Intrinsic Algorithm - "Reducing the world to mathematical equations!"
RIPPL Sports - NFL Statistical Analysis and Prediction System

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

The computer player should also carefully choose where the ball will go so that he isn't left vulnerable. You don't hit the ball straight to the other player when you're against the net at one side. All the other player has to do is hit the ball behind you on the empty part of your court and he scores. In situations like that, the computer player should lob the ball to give him time to move to cover his court and prepare for the returning shot.

Just one example.

Realistic physics would be nice too. The computer player might not have the chance to lob the ball if his racket isn't in the right position when the ball is flying at him.

Also, you need to have the right footing to switch directions. Otherwise, the instant the computer player hits the ball, he moves to the center and it would look very "computerized".

Just suggestions. Sometimes makeing the game more computerized than real makes for a game that is more fun.

[edited by - Waverider on November 8, 2002 2:23:11 PM]
It's not what you're taught, it's what you learn.
Awesome, thanks for the ideas, guys!
I will look into reinforcement learning although I am guessing that an FSM with some fuzziness would work best. I guess it will be more a matter of tweaking it than anything else.
Yea I''ll try to make the physics good although I''m not sure if we''re aiming for "realistic". We might make it a little exaggerated, (think like, cartoon physics). The reason being that there are already a lot of realistic tennis games so if we did that, our game wouldn''t really stand out from anything else.

Thanks again!

Raj
Advertisement
You should really try to analyse "Tennis 2K2" by Sega (I guess), is the best Tennis game I´ve ever seen, it´s AI is pretty amazing specially in expert mode, you can see how the computer waits for the ball in the right position to put it in the perfect spot so the other player can´t take it.

This topic is closed to new replies.

Advertisement