It is currently Tue Nov 21, 2017 7:08 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: artificial intelligence
PostPosted: Sun Mar 03, 2013 3:54 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2361
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.


Top
 Profile  
 
PostPosted: Sun Mar 03, 2013 6:36 pm 
Offline
User avatar

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

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Sun Mar 03, 2013 10:44 pm 
Offline
User avatar

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


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 1:12 pm 
Offline
User avatar

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

_________________
.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group