need help with designing ai movement

chandan1014chandan1014 Member Posts: 14
edited November -1 in Working with GS (Mac)
hi, its my first post on the forums, so hi everyone. i am making a game in which the ai actor dodges you shots and throws shots at you. the problem is, my ai actor is either perfect or too dumb. here's how i decide how to move the ai: it starts moving in a random direction at the start of the game, then it moves tangentially away from the shot that you throw at the ai. this makes the ai just perfect, you just cant hit him, he dodges all your shots. how can i add some random random stupidity to the ai movement? please help!

Comments

  • BeyondtheTechBeyondtheTech Member Posts: 809
    I would create an integer Game.Attribute called AI. You can set this value to be 1-100, 1 being the dumbest, and 100 being the smartest.

    In your Rules, use a random number between 1 and 100 and insert it in your Enemy Actor's logic.

    For example:

    If bullet is traveling towards the Enemy Actor AND Game.AI < random(1,100), move away.

    Looking at the above example, if you set the value of AI to 80, then he has an 80% percent chance of doing the right thing

    Or if you're just using an angle, change it to angle + random(-1*(100-Game.AI),100-Game.AI).

    So, if the perfect angle to move away from an incoming bullet is 90 degrees and his AI is set to 80, the calculated angle will be 90+random(-20,20) or anywhere between 70 to 110.

    Does that make sense?
  • chandan1014chandan1014 Member Posts: 14
    makes enough sense! thanks a lot beyondthetech. i will probably tweak the algorithm a bit more and play around with the values to get the perfect balance. thanks a lot again.
Sign In or Register to comment.