# My AI isn't working

**URL:** <https://forum.kirupa.com/t/my-ai-isnt-working/58805>\
**Category:** programming\
**Created:** [July 26, 2004, 12:26pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805 "2004-07-26T12:26:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)\
**Post date:** [July 26, 2004, 12:26pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/1 "2004-07-26T12:26:41Z")

</div>

hi guys, just wondering if u could take a look at my simple AI. I know the problem is sumthing simple but i cant find out whats wrong with it. Any help would be great, thanx.

```auto
 action = Math.ceil(Math.random()*100);
aTimer = 0;
eattack = false;
//
function enemyAttack() {
aTimer++;
if (aTimer == 180) {
aTimer = 0;
if (action>=0 && action<45) {
_root.dino.gotoAndStop("walk");
eattack = true;
//
} else if (action>=45 && action<70) {
_root.dino.gotoAndStop("chomp");
eattack = true;
//
} else if (action>=70 && action<100) {
_root.dino.gotoAndStop("tailslap");
eattack = true;
//
} else {
_root.dino.gotoAndStop("stand");
eattack = true;
}
}
}
if (eattack=false) {
enemyAttack();
}

```

i traced the aTimer and it duznt count up so for sum reason the timer isnt being initiated. hope that helps.

---

<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:** [July 26, 2004, 12:28pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/2 "2004-07-26T12:28:11Z")

</div>

You should have:

if(eattack == false)

---

<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:** [July 26, 2004, 12:56pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/3 "2004-07-26T12:56:53Z")

</div>

```auto
 action = Math.ceil(Math.random()*100);
aTimer = 0;
eattack = false;
//
function enemyAttack() {
 aTimer++;
 eattack = true;
 if (aTimer == 180) {
  aTimer = 0;
  if (action>=0 && action<45) {
   _root.dino.gotoAndStop("walk");
   //
  } else if (action>=45 && action<70) {
   _root.dino.gotoAndStop("chomp");
   //
  } else if (action>=70 && action<100) {
   _root.dino.gotoAndStop("tailslap");
   //
  } else {
   _root.dino.gotoAndStop("stand");
  }
 }
}
if (eattack == false) {
 enemyAttack();
}

```

ok i fixed that, but now it just counts to 1. any help?

---

<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:** [July 26, 2004, 4:46pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/4 "2004-07-26T16:46:04Z")

</div>

Change the first line to this:

action = random(100)+1;

---

<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:** [July 27, 2004, 2:01am UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/5 "2004-07-27T02:01:46Z")

</div>

hhmm. its still not working. i attached the FLA with sum quickly drawn graphics.

---

<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:** [July 27, 2004, 1:49pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/6 "2004-07-27T13:49:59Z")

</div>

I don’t think I can help. I don’t have flash on this computer and the internet isn’t working on mine. Someone else will know.

Nevermind. It’s working now. I don’t know why, but this works:

---

<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:** [July 27, 2004, 3:50pm UTC](https://forum.kirupa.com/t/my-ai-isnt-working/58805/7 "2004-07-27T15:50:39Z")

</div>

yay thank you very much.
