Advertisement

AI in a football game- how to start?

Started by March 20, 2002 05:40 AM
18 comments, last by zip7000 22 years, 7 months ago
hello, I create a football game(speedball game like if you know).there are 5 players on each side. I am a beginner in AI and even if I already have some ideas, I would like some advices to be sure that I go in the right way. Here are my ideas : - each player will have a piece of the pitch. If the ball comes in his area, then the player will go through the ball. - if the player has the ball, he will go to the goal of the adversary. When he will be at the limit of his area, he will give the ball in the direction of one of his team member front of him. -if an adversary comes in his area with the ball, he will strike him.(violent game ) Is it a good starting? Is someone has some ideas to make an AI for a team? what about the data structure? Thank you for any help you could give!
Sounds good. I don''t think any approach is wrong Some are just more limiting than others!

You might want to take a look at a couple month-old threads, both relating to the same topic. There are some intereting ideas there too.

Alex


Artificial Intelligence Depot - Maybe it''s not all about graphics...

Join us in Vienna for the nucl.ai Conference 2015, on July 20-22... Don't miss it!

Advertisement
Sports games aren''t too hard to model (realism is hard) since players have generally have specific goals. For example you would have the QB deciding plays and choosing targets for handoffs or passes. A running back will try to run with the ball without being tackled. A wide recieve must run out for a pass catch it and then he becomes a running back. You probably would have to make a full state diagram.
quote: Original post by Jindocai
Sports games aren''t too hard to model (realism is hard) since players have generally have specific goals.

While I would generally agree with you, the pathetic state of all current sports game AI leads me to believe it must be harder than it seems. Either that, or these companies are full of weenies who never touched a pigskin or roundball...

I''m working lazily on a sports game myself, and have determined a number of rules for behavior. Implemented as a state machine, you''d have a huge monstrosity with deeply nested substates, so some other form of decision making is necessary (in conjunction with fairly high-level state processes). Also, a lot of reasoning in sports is purely "physical": when advancing downfield on offense, the offensive player will pick spots where he is least likely to be intercepted/defended by the other team or most likely to gain advantage. These are complex position-velocity relationships that we instantaneously calculate in the real world, but a lot more complex to simulate authentically. <br><br><small>[ <a href="http://www.gamedev.net/reference/start_here/">GDNet Start Here</a> | <a href="http://www.gamedev.net/community/forums/search.asp">GDNet Search Tool</a> | <a href="http://www.gamedev.net/community/forums/faq.asp">GDNet FAQ</a> | <a href="http://msdn.microsoft.com/library/">MS RTFM [MSDN]</a> | <a href="http://www.sgi.com/tech/stl/">SGI STL Docs</a> | <a href="http://www.google.com/">Google!</a> ]<br>Thanks to Kylotan for the idea!</small>
Being an "ex-wennie" of one those companies you are refering to, I can tell you first hand that many of the difficulties we ran into, especially on Supercross 2000, was adding the ''human factor'' to the AI. It was easy to make the AI logic play the game with computer accuracy and reflexes. The flaws happen when you try to make the AI play player X better then player Y. Also, team sports provide other interesting challenges, as the AIs need to react to what other players on the same team are doing. This is a big key to a decent AI in hockey, basketball or soccer (although you could make an argument against basketball if you are talking pro hoops! ). I don''t see it quite as important to American football, although the defense should probably be able to react as a team.

--
Robert Costello
www.moonthrone.com
--Robert Costellowwww.playfulminds.com
I find individual sports like racing to be a lot more life-like than team sports games. I distinctly remember being slack-jawed with amazement when I saw a competing rider off his bike with a spanner in his hand trying to fix some sort of mechanical fault in a 1990 moto grand prix game on my IBM XT (4.33MHz, 20MB HDD, etc).

Take basketball (my canonical example). Why it took until 2002 for the games to implement the break and transitions properly is beyond me. Prior to this year, point guards on the break would run into the frontcourt with an unobstructed path to the basket, and then pull up at the top of the arc allowing everybody else to catch up. Comments from this year''s developers lead me to believe they "patched" last years AI to "fix" this flaw rather than reevaluating their entire set of base assumptions/behaviors. I could go on about a myriad such issues. The really funny thing is that Lakers vs Celtics and the NBA Playoffs (EA, 1989) didn''t have this flaw. Go figure...

This is not to put them down as developers. I am very much aware of how much goes into making even the simplest of games, so I respect their ability to even produce these titles. Kudos to you and your former co-workers!

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
Advertisement
*I must take a big breath to get all this out*

I have read interviews with EA Sports programmers who say it wouldn't be hard to make a perfect AI for most games, especially since each player could have access to what the other players "know" or "see."

It wouldn't be hard to make an AI that is impossible to beat.

Therefore, it seems to me that the hardest part about making a sports AI is making it dumb enough to be beaten. (I think basketball and soccor were the two exceptions of the rule given in the interview--those are supposed to be hard no matter what you do).

Remember, a single player usually has the advantage. I know when I'm playing against my friends that the person on a team by his/herself will usually win, because coordinating plays is easy (you throw the ball to yourself, run the play yourself, etc.). When playing on a team, I notice receivers doing stupid things like running the wrong way, or people who should be providing coverage trying to sack the quarterback. Computer AI would obviously have the advantage here.

Anyway, I don't think a completely real AI in sports would be that fun. In fact, complete realism (other than visual) in sports games makes them dull (that's why the default length is usually shorter). This is why I like NFL Blitz over Madden football. When I play Madden, I turn on Arcade mode and turn off a lot of the realistic features.

I know it's an oversimplification, but take TicTacToe for example. It's very easy to make a perfect AI that will never lost a game. But would this be fun? Of course not.

Same reason it's not as fun to play a nightmare bot in Quake 3 (oh wait, bad example. I've been into that lately because I can't play on the net here...stupid firewall).

And some advice I read in the book Secrets of the Sages.

Make a stupid AI. Watch it, and wait for it to make a mistake (shouldn't take long). Then code the fix for that mistake. This is basically training the AI.

I can't think of any other way to code AI than using iterative design. Start with making the AI move towards the player with the ball or something.

--TheMuuj

[edited by - TheMuuj on March 25, 2002 12:57:18 AM]
--TheMuuj
quote: Original post by TheMuuj
I have read interviews with EA Sports programmers who say it wouldn''t be hard to make a perfect AI for most games, especially since each player could have access to what the other players "know" or "see."

It wouldn''t be hard to make an AI that is impossible to beat.

That''s quite useless. And it''s a cop-out by those developers.

quote: Therefore, it seems to me that the hardest part about making a sports AI is making it dumb enough to be beaten. (I think basketball and soccor were the two exceptions of the rule given in the interview--those are supposed to be hard no matter what you do).

The hardest part about making a sports AI is to make it genuinely challenging and play authentically, yet give the user a good shot at winning.

quote:
When playing on a team, I notice receivers doing stupid things like running the wrong way, or people who should be providing coverage trying to sack the quarterback. Computer AI would obviously have the advantage here.

The people suck. The people should lose.

A well-designed and implemented sports AI will require proper play to be beaten. I''m not looking for an arcade game (I''ve played enough NBA Jam and Hardwood Heroes to last me a lifetime), so I don''t require that every player be able to simply drive to the hole and dunk on Shaq. What I want to see is a game that rewards a player for tactics and technique, not penalizes him/her. NBA Live, for example, has always had pitiful gameplay. Doubleteaming (even when switched off) creates gaping holes in the defense that the computer exploits, resulting in losses that should not have been. Rebounding is off, there''s virtually no boxing out (even when team strategy is set to Box Out) so the computer gets offensive boards and second-chance opportunities...

You probably get my drift. The complete ignorance of the details of the game, the core that makes the exciting plays and fastbreak dunks possible in real life, are conspicuously absent from virtually every basketball game I have ever played. And I''ve played a lot.


But it''s easy to criticize, so allow me to give you some of my designs and ideas (technical implementation schematics, not abstract "concepts"). I also include ideas that I think are ancilliary to better AI:


  1. Control
    A critical part of being able to scale the AI up to realistic levels is giving the player more precise control over what happens. Being able to alter shots, for example, would change post and above-the-rim play remarkably. As it stands, a player can''t take the ball strong and make a layup; it always has to be a dunk or the ball will likely get blocked.

    More precise control of movement, passing and off the ball movement would also make significant differences. Ask for a screen, then wave it off (currently impossible). Maintain direction (as much as reasonable) so that plays are more efficient - moving in smooth arcs instead of zig-zagging all over the place - staying in bounds as much as logical (ie, allow a player to step out of bounds if "concentration" is low, "pressure" is high, or velocity is "out of control"). These little modifications to control already create a more expressive game. See my thread on input interpretation for more details on this.


  2. Motionsets are evil!
    Motionsets (static sequential animation data) are the bane of sports games. Why? Because they don''t allow the player respond as quickly as they would like. For example, the "spin move" motionset in Live takes so long and moves in such an arbitrary direction that it often causes the player to spin out of bounds. Stupid.

    Motionsets should be replaced with an interpolated skeletal animation scheme. The interpolation/composition allows the player to do two things at once and respond dynamically. A scheme similar is being employed in the new Unreal engine. My implementation had keyframe target vectors per joint, and the joint position was interpolated from current to target. This allowed a new target to instantly be set with a velocity and the skeleton to respond in a fluid, natural manner. I don''t talk about this too much because I haven''t implemented it yet, and as such it''s still "theory".

    Implementing an animation system like I have described increases user control and makes the user more able to respond to/compete with more advanced AI. I''ll expand on this shortly.


  3. "Physical reasoning"
    Sports are physical. Obvious, but profound. A lot of the responses by athletes are prompted by observing an action and attempting to anticipate the next step in a sequence. If you observe steals leaders like John Stockton, you''ll see that a lot of his steals come off blind side defensive help because he sees the ball handler turning into a zone where he wont be seen, so he quickly makes his move.

    Similarly on offense, the secret to Iverson''s crossover breakdowns is the fact that the defensive player will try to compensate for the first cross. So he shakes left, crosses right then fakes going left again. Compensation, but he didn''t move that way; he went right all the way and gets a layup. McGrady''s All-Star game toss-up dunk was made possible because the defensive players anticipated him tossing that lob to another player, not to himself off the board.

    Well, what does this mean for AI? If player A is at position x moving with velocity v at time t, it is logical that at time t+1 player A will be at x'' = v(t+1) + 0.5 v''(t+1)^2 - simple Newtonian physics. Why not use this as an input to defensive logic? Try to attain a position that narrows player A''s advance towards the basket earlier. The upside to a human player is that you can then fake motion, instead of the current system where defensive players are nearly "glued" onto you and the only way to beat them is a pump fake, a spin move (which might dump you out of bounds) or passing.

    Also, if a player has an unobstructed path to the basket, he should go for it. If nothing comes of that run and the defense catches up, then reset the offense. We see it all the time in the real game. Nothing kills me more than being on the 2-on-1 break, getting ready to throw up the lob for the alley-oop when the cutting player suddenly stops at high post position with no defender around. The entire play is broken.


Just employing these three tenets will yield a far superior AI and a much more challenging and rewarding game, IMO.

quote:
And some advice I read in the book Secrets of the Sages.

Make a stupid AI. Watch it, and wait for it to make a mistake (shouldn''t take long). Then code the fix for that mistake. This is basically training the AI.

I think that''s absolutely horrible advice.

quote: I can''t think of any other way to code AI than using iterative design. Start with making the AI move towards the player with the ball or something.

Intelligent initial assumptions and base behaviors, and a good selection function beat "iterative design" for sports.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
Oluseyi,

Unless I am mistaken, the original question was about how to go about coding AI for a sports game.

How can you base it on real players when the sport itself doesn't actually exists (or am I ignorant on the existance of speedball).

Of course you are right about most sports AI being dumb. But like I said, I don't like realistic sports games, which is where most of my reasoning comes from. I actually don't really like sports in general. I think a lot computer programmers also don't like sports (or else they wouldn't be computer programmers, would they). I know I'm generalizing, but until you get real experts teaching coders what the AI should do and WHY (this is the most important part...understanding WHY), sports games will continue to fall short of the real thing.

Of course, even though I know very little about the techniques used in various sports games, I know something must be wrong. Otherwise, my technique of running Shotgun plays every down and making big passing plays wouldn't work in a football video game. And it doesn't matter, I seem to be able to do this in most football games (it may have to do with how easy they make it to hit your target when passing). I was surprised when it worked in Madden 2002 and NFL Fever.

Of course, when playing with my friends the solution is to turn the penalty for pass interference off. Then it becomes a job of looking for a receiver who isn't being tackled or won't be tacked before the ball gets to him. I know this isn't real, but it does force me to work on my running game (which in turn does make it more real).

I think there needs to continue to be two distinct classes of sports games: realistic and arcade. I prefer arcade because it is impossible to capture the real "thrill" of the game. No matter what you do, a game won't be as exciting as the real thing. No amount of AI will fix that. Maybe it could be solved by making sports games from the First Person perspective. Then you would only be able to see what a real player in the game sees.

--TheMuuj

[edited by - TheMuuj on March 26, 2002 12:42:35 PM]
--TheMuuj
quote: Original post by TheMuuj
How can you base it on real players when the sport itself doesn''t actually exists (or am I ignorant on the existance of speedball).

Well, assume it was a real sport (there have been movies about similar things - RollerBall or something like that, and a movie actually titled Speedball). It would have rules and regulations, tactics and techniques, etc. This would serve as the foundation upon which to build a good AI for the game.

quote: I think a lot computer programmers also don''t like sports (or else they wouldn''t be computer programmers, would they).

I think a lot of American computer programmers are socialize to be "nerdy" and exhibit a disdain for social and physical activities. It doesn''t mean I''m right, but in Nigeria all the programmers I know still enjoy sports. Football (soccer) is huge, and basketball is constantly gaining in popularity.

quote: I know I''m generalizing, but until you get real experts teaching coders what the AI should do and WHY (this is the most important part...understanding WHY), sports games will continue to fall short of the real thing.

Well, I sort of agree and sort of don''t. I think the key is having developers who are great fans of the sports, who play the sports, who study the sports and who know the sports. Not some pickup half-court 3-on-3 basketball players, but guys (and girls) who have played in organized 5-a-side, 12-man team leagues. Developers who have been coached and have studied playbooks, analyzed games, watched miles of tape... Visual Concepts say their developers for NBA 2K2 play, watch and love the game, but I''m convinced they''re casual athletes who enjoy the highlights. I was on my college feeder team my first three years (in Nigeria); I got shot coaching, had to do "suicide drills", defensive manouvers and all the other things coaches do to make you better all round players. I have handles on the ball. I know the game.

quote: I think there needs to continue to be two distinct classes of sports games: realistic and arcade.

I agree, and I classify pretty much all of the currently available basketball games as arcade (football too). I''m interested in creating a basketball simulatin - realistic to the hilt. I have a number of ancillary ideas that I detail in this thread on sports character development and MMO possibilities. As you can see, I have a very different type of game in mind.

quote: ...it is impossible to capture the real "thrill" of the game. No matter what you do, a game won''t be as exciting as the real thing.

But it could be exciting in a different way. Playing an RPG will never be as exciting as going on a real quest, but what''s the likelihood of that ever happening to you? And what about the dangers - of death, for instance? Video games allow us to explore roles and worlds that we likely never would in our day-to-day lives. Lots of people play sports, but few of them can compete at as high a level as professional athletes. Even pro athletes play these games, though, because no one pro athlete can assemble various teams on demand for exhibition games. No pro athlete can just take over management of a franchise and build it over a number of seasons, with no "real" risks.

Playing a sports simulation may not be as exciting as driving the Paris-Dakar, but it''s likely the closest most will get to running that turbo-charged Rally Accord across the Sahara.

For the record, I think an FP-sports game would suck. The lack of peripheral vision would seriously detract from gameplay, as would the inability to look in one direction while acting in another (and possible moving in a third).

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!

This topic is closed to new replies.

Advertisement