artificial intelligence

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
psycopathicteen
Posts: 3140
Joined: Wed May 19, 2010 6:12 pm

artificial intelligence

Post by psycopathicteen »

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.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: artificial intelligence

Post by Kasumi »

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: Select all

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.
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Re: artificial intelligence

Post by blargg »

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.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: artificial intelligence

Post by zzo38 »

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.
(Free Hero Mesh - FOSS puzzle game engine)
Post Reply