Computer AI

Hey, would anyone know how to make computer AI (artifical intelligence) for opponents in a stick fighting type game. I have no clue how and really needa figure out some way.

Any ideas, suggestions, scripts (:)) are greatly appreciated…

Thanks alot,
KoRRupt

do a search on the forums for “game AI” you should get something that will get you started…

Since computers aren’t capable of intelligent thought, AI is just a manipulation of variables and mathematical forumulas…

Ya I know, I know a few random number scripts and what not, but I’m not sure how to make all the random movement, then the moves…

Btw, searching on the forums for “game ai” didn’t do squat…

Hopefully someone can help me out…

Peace,
KoRRupt

I’ve worked with game ai before and actually you should have found a script on a Pac Man AI… It’s very complex…

Stick Fighting Game… How do you wish it to be done… By random or… If a guy is low on health… Or… set up random groupings of actions… !!!

Ya, I did find the pacman script… but I didn’t think it would work out for fighting… (Also, that’s mostly an excuse because I’ll unintelligent in fixing it up for fighting… :slight_smile: )

Okay well, it would be great if it was just random, with certain moves when the main player is close to the enemies… Practically, if the player gets close to the enemy, he startes punching/kicking, then chases him kinda…

I can show you the fla so you know what your working with if you want…

Thanks man,
KoRRupt

Here… lemem give you a short algorithm… This should be able to help you out with your thinking process… :slight_smile:

Algorithm Not Code


if(player-x is short distance away)
{
   action = make random number;
   switch(action)
   {
      case 1 :
      {
         perform kick1;
      }break;
      case 2 :
      {
         perform kick2;
      }break;
   }
} else {
   action = make random number;
   switch(action)
   {
      case 1 :
      {
         perform fireball;
      }break;
      case 2 :
      {
         perform run towards;
      }break;
   }
}

That should help you come up with a good decisive procurrsion to what it may be.

Ya, that helps alot, makes lots more sense now…

But I’m still a AS newb and have only been learning for a couple weeks now. I’m very incapable…

I kinda need examples…

I can sorta figure it out, 1/4 the time, but the other 3/4 kill me,

Do you think it’s possible to actually show me examples from my fla?

I would really appreciate it and put you and your site in the credits for sure…

Thanks alot man, you can download the fla from http://www.stickslaughter.com/games/Untitled-3.fla, incase you can help…

Thanks again,
KoRRupt

Ugh… .fla’s… It’s probably better just doing it yourself and me helping… As people know about me… I don’t do .fla’s… I can’t stand looking at other people’s code…

Nothing against you but I have a weird style lmao

Just tell me what you might need… Do you have all the animations done for kicking and stuff?

Oh, sorry bout that, I guess I haven’t been here long enough…

Hmm, okay well, the main mc is the boss, with the instance name of “boss”…

He’s got only a few moves so far…

Frame 1-5 = Walking
Frame 7-14 = Punch Left
Frame 16-24 = Punch Right

But basically, I want it to be that all the enemy’s (bosses i guess, lol) come after the main player (instance name “hero”). Then when there close enough, they’ll punch left (or right).

They don’t have to be directly drawn to him… maybe just if you start punching them, they come after you? I dunno, put in a few ideas of your own…

Btw, thank so much for helping me, I appreciate it greatly,
KoRRupt

Now… I just need a few more facts and then I can make you a decent script… I’m guessing this is a FInal Fight type game and not a fighting game… Beat em Up game…

Double Dragon style… Sounds cool man… Well I can make a small script that would do this…

If distance is medium… Get the “boss” attention… Then if you get closer… They start to attack you…

Sound good?

I just need to know what your movie height and width is and what the fps is.

Sounds great,

Movie Size: 550x200
Framerate: Default (12)

Thanks so much man, your a huge help,

Thanks again,
KoRRupt

First off you might wanna up the fps to at the least 20-30 fps… It’ll smooth out some of the gameplay… Then…

:rambo:



MovieClip.prototype.checkDistance = function(enemy)
{
   temp = this._x - enemy._x;
   return(temp);
}

_root.onEnterFrame = function()
{
   for(x=0; x<bossesOnScreen; x++)
   {
      distance = hero.checkDistance(_root["boss"+x]);
      if(Math.abs(distance) >= 50 && Math.abs(distance)<= 100)
      {
         _root["boss"+x].gotoAndPlay(1);
      }
      if(Math.abs(distance) <50)
      {
         if(distance > 0)
         {
            _root["boss"+x].gotoAndPlay(7);
         } else {
            _root["boss"+x].gotoAndPlay(16);
         }
      }
   }
}


[EDIT] I hate it when I screw things up… Here is the right version [/EDIT]

Allright… Here’s my aim name and yahoo name and msn name… Add me if you got those…

yah : playamarz
aim : SupaMarMar
msn : mentalconcepts@hotmail.com

Might have to work with ya more on this.