# Computer AI

**URL:** https://forum.kirupa.com/t/computer-ai/14742
**Category:** flash
**Created:** [March 2, 2003, 5:58am UTC](https://forum.kirupa.com/t/computer-ai/14742 "2003-03-02T05:58:13Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![korrupt](https://avatars.discourse-cdn.com/v4/letter/k/e56c9b/32.png) [@korrupt](https://forum.kirupa.com/u/korrupt)
#### Post date: [March 2, 2003, 5:58am UTC](https://forum.kirupa.com/t/computer-ai/14742/1 "2003-03-02T05:58:13Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 5:59am UTC](https://forum.kirupa.com/t/computer-ai/14742/2 "2003-03-02T05:59:25Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 6:14am UTC](https://forum.kirupa.com/t/computer-ai/14742/3 "2003-03-02T06:14:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 7:25am UTC](https://forum.kirupa.com/t/computer-ai/14742/4 "2003-03-02T07:25:01Z")

</div>

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… !!!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 7:34am UTC](https://forum.kirupa.com/t/computer-ai/14742/5 "2003-03-02T07:34:53Z")

</div>

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… 🙂 )

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 5:29pm UTC](https://forum.kirupa.com/t/computer-ai/14742/6 "2003-03-02T17:29:32Z")

</div>

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

## Algorithm Not Code

```auto

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 7:44pm UTC](https://forum.kirupa.com/t/computer-ai/14742/7 "2003-03-02T19:44:56Z")

</div>

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](http://www.stickslaughter.com/games/Untitled-3.fla), incase you can help…

Thanks again,  
KoRRupt

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 9:11pm UTC](https://forum.kirupa.com/t/computer-ai/14742/8 "2003-03-02T21:11:20Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 2, 2003, 11:20pm UTC](https://forum.kirupa.com/t/computer-ai/14742/9 "2003-03-02T23:20:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 3, 2003, 2:27am UTC](https://forum.kirupa.com/t/computer-ai/14742/10 "2003-03-03T02:27:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 3, 2003, 2:43am UTC](https://forum.kirupa.com/t/computer-ai/14742/11 "2003-03-03T02:43:10Z")

</div>

Sounds great,

Movie Size: 550x200  
Framerate: Default (12)

Thanks so much man, your a huge help,

Thanks again,  
KoRRupt

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 3, 2003, 3:22am UTC](https://forum.kirupa.com/t/computer-ai/14742/12 "2003-03-03T03:22:36Z")

</div>

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:

```php

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]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 3, 2003, 3:27am UTC](https://forum.kirupa.com/t/computer-ai/14742/13 "2003-03-03T03:27:48Z")

</div>

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](mailto:mentalconcepts@hotmail.com)

Might have to work with ya more on this.
