nesdev.com
https://forums.nesdev.com/

artificial intelligence
https://forums.nesdev.com/viewtopic.php?f=2&t=9881
Page 1 of 1

Author:  psycopathicteen [ Sun Mar 03, 2013 3:54 pm ]
Post subject:  artificial intelligence

Does anybody have an idea how the enemy AI works in a game like Gunstar Heroes? I tried programming it earlier today, but I realized that it was more difficult than I thought it would be.

Author:  Kasumi [ Sun Mar 03, 2013 6:36 pm ]
Post subject:  Re: artificial intelligence

Lots and lots of conditionals, random numbers when there's more than one option. I think enemy AI is simple to understand, just hard to do well.

Stuff like

Code:
if(playhorizontaldistance < grabrange){
     attempttothrowplayer();
}else{
     if(getrandomnumber()%2){
          isplayeronright(){
               moveenemyright();
          }else{
               moveenemyleft();
          }

     }else{
          shootplayer();
     }
}


This would try to throw a player if the player is close enough to be thrown. If the player is not close enough to be throw, it would randomly either shoot at the player, or move the enemy toward the player. If you want smarter AI, you need more conditionals.

For instance, I might have a state for shooting, because it'd be weird if the player moves toward the player half the time, and shoot them half the time.

Like... move a pixel, shoot one bullet, move a pixel shoot one bullet. So I'd have it choose to enter a shooting stance for a few frames so it doesn't look as choppy.

It's just a lot of conditionals until it appears smart.

Author:  blargg [ Sun Mar 03, 2013 10:44 pm ]
Post subject:  Re: artificial intelligence

Most enemies are way more powerful than the player, so that their AI doesn't have to be very smart. Only in games where the enemy has the same abilities as the player is the AI smart, though still it has the advantage of superhuman speed, instant perception of player actions, and instant decision making.

Author:  zzo38 [ Mon Mar 04, 2013 1:12 pm ]
Post subject:  Re: artificial intelligence

In many games the AI is acting too stupid though. Such as in Pokemon Card GB2, often the opponents will draw way too many cards.

In a slow computer such as Famicom, you might calculate some decisions ahead of time too during the loops doing other stuff, if it does not have to act right away, but such things may be more difficult to program.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/