# Ai opponent

**URL:** https://forum.kirupa.com/t/ai-opponent/185458
**Category:** Uncategorized
**Created:** [April 13, 2006, 2:33pm UTC](https://forum.kirupa.com/t/ai-opponent/185458 "2006-04-13T14:33:59Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Nemesis619](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Nemesis619](https://forum.kirupa.com/u/Nemesis619)
#### Post date: [April 13, 2006, 2:33pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/1 "2006-04-13T14:33:59Z")

</div>

im currently making a flash game here it is [http://www.freewebs.com/bmjw619/wayofthewarrior.htm](http://www.freewebs.com/bmjw619/wayofthewarrior.htm)  
all i have to do is now sort out the opponent i was thing of using random actions but im unsure how to do them.  
Or would there be a better way of programming the opponent

---

<div class="post-metadata">

### Author: ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)
#### Post date: [April 13, 2006, 3:05pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/2 "2006-04-13T15:05:57Z")

</div>

Soo whats the question? If theres a better way to program AI without random actions. well AI is just that. So it how you do it that counts.

---

<div class="post-metadata">

### Author: ![Scarybug](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/scarybug/32/2863_2.png) [@Scarybug](https://forum.kirupa.com/u/Scarybug)
#### Post date: [April 13, 2006, 3:27pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/3 "2006-04-13T15:27:50Z")

</div>

I would weight the random actions based on the actions of the player. If the player tends to throw more high punches, for example, make high blocks and low attacks slightly more likely to come up. Also make sure the computer doesn’t attack unless it’s close enough to the opponent.

Also, your game could use a more readable font and some directions as to what the controls are 🙂

---

<div class="post-metadata">

### Author: ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)
#### Post date: [April 13, 2006, 6:01pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/4 "2006-04-13T18:01:04Z")

</div>

between the frames put a

```auto
 stop(); 

```

so they wont do the same move over and over 😛

---

<div class="post-metadata">

### Author: ![rpgfanatic](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rpgfanatic](https://forum.kirupa.com/u/rpgfanatic)
#### Post date: [April 16, 2006, 10:10pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/5 "2006-04-16T22:10:01Z")

</div>

a few guidelines:  
in an rpg with an enemy that has simple ai,it can even be made just with creating roots,random  
and using the if(else) commands:

example:  
as the main setup(just an easy fight,monster can heal you attack):

put this in the first frame:

* * *

monsterhp = 2750;  
youhp = 2300;

monstermp = 150;

yourmp = 270;  
dmgmagic1 = 300;  
yourattackdmg = 70+random(101);  
monsterattackdmg = 100+random(201)  
youabletocastice = 0  
Malmostdeadatcastmagic = 0  
Malmostdeadatattack = 0

* * *

2nd KEY frame put this(btw,lower down,i will cover the actionscripting that you have to insert in the buttons in this frame):

* * *

Stop();

* * *

3rd keyframe(here comes the simple ai,that can be wrenched up to an incredible feat to kill the monster that has the ai,when you understand it):

* * *

stop();  
if(\_root.mp\<50){  
\_root.youabletocastice=\_root.youabletocastice+1;  
\_root.Malmostdeadatcastmagic=\_root.Malmostdeadatcastmagic+1;  
}

if(\_root.monsterhp\<300){  
\_root.Malmostdeadatcastmagic=\_root.Malmostdeadatcastmagic+1;  
}  
if(\_root.monsterhp\<171){  
\_root.Malmostdeadatattack = \_root.Malmostdeadatattack+1;  
}

if(\_root.Malmostdeadatcastmagic=\>1){

GotoAndPlay(“monsterheal”);}else{  
if(\_root.Malmostdeadatattack\>0){  
GotoAndPlay(“monsterheal”);  
}else{  
GotoAndPlay(“monsterattack”);

}

}

and making a few buttons that direct you to attacking and using magic(with the frames to match those commands)  
then the enemy would be clever enough to measure it chances if you would use the strongest attack(in this case ice,only if you have mp enough to do it)  
and would heal just before it would possibly die for example,so it woulnd’t spend to much mp

ill explain more if you ask me 🙂

---

<div class="post-metadata">

### Author: ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)
#### Post date: [April 16, 2006, 10:18pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/6 "2006-04-16T22:18:56Z")

</div>

@up , nice :d

thnx u helped me too with this 🙂

now i can add + damage to my player when he lvls up 😛

could u make a .fla from that? 🙂

---

<div class="post-metadata">

### Author: ![rpgfanatic](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rpgfanatic](https://forum.kirupa.com/u/rpgfanatic)
#### Post date: [April 17, 2006, 12:29pm UTC](https://forum.kirupa.com/t/ai-opponent/185458/7 "2006-04-17T12:29:36Z")

</div>

> [@ricer](#):
>
> @up , nice :d
> 
> thnx u helped me too with this 🙂
> 
> now i can add + damage to my player when he lvls up 😛
> 
> could u make a .fla from that? 🙂

sure mate,np,graphics will probably suck,cuase ill make it in a snap,ill post the link when it’s done
