AI-FIGHTER

0 favourites
  • 6 posts
From the Asset Store
Tiny Crash Fighters is a fast-paced action game where you build your ultimate machine to fight.
  • can anyone show me how to create an AI enemy like in street fighter or any

    fighting game? i understand the logic about comparing the x and y of both characters but i don't know how to simulate the movement it self and how an AI will intelligently cast a skill with in a specific situation? please help me.. :)

  • you need to decide under what conditions each action should be taken and the write conditions for them that trigger the action. Besides x and y position you should create variables for what action the player is doing, jumping, crouching, etc.. that way you can have the AI conditions check what the player is doing and respond accordingly.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • do you have an capx example? it can be very helpful to me thank you for your reply sir..

  • I got this from another forum and I held on to it as a sort of AI Bible Verse that i can refer back to whenever I need to do anything AI related. I suggest you do the same. It is based on an example of a tank game but the concept is the same for a fighting game or any other kind of game really.

    You need to think about your AI conceptually. Think about all the decisions you have to make as a player in your game. It may help to make a flowchart. Say you've got a tank game. Here are some decisions the AI has to consider:

    1)  Can I see the human player?
    2)  Do I want to move towards him, stay put, or back off?
    3)  Is my turret aiming at him?  Should I rotate it?
    4)  Do I have a clear shot?
    5)  Which way is the human moving?  Where should I aim to lead the target?
    6)  Am I ready to take a shot?
    7)  If I don't see the human player, which way should I go?
    8)  Is there something blocking my path?  Which way should I turn instead?
    9)  Is a tank shell coming at me?  Where can I move to avoid it?
    

    Just a small example of all the decisions your AI would have to consider. After you've got these all listed, you need to come up with how your AI will come up with the answers. For example:

    1)  Can I see the human player?
       a) If he's closer than 500 units and I have line of sight, I can see him.
       b) If I have seen him in the last 10 seconds and he's no longer in sight, remember where he was at.
    
    2)  Do I want to move towards him, stay put, or back off?
       a) If his back is turned to me, I will move to him
       b) If he's moving closer to me, stay put
       c) If my health is too low, back off
    
    3)  Is my turret aiming at him?  Should I rotate it?
       a) Rotate my turret to face him or his last known position at all     times
    
    4)  Do I have a clear shot?
       a) Is there something between me and where I want to shoot?
       b) If there is, I should move somewhere else
    
    5)  Which way is the human moving?  Where should I aim to lead the target?
       a) Based on speed and direction of the human, and speed of my bullet, calculate the trajectory I need to fire at
       b) Add/subtract some degree of error to this trajectory based on difficulty level of the AI
    
    6)  Am I ready to take a shot?
       a) I can only fire one shot every 5 seconds, make it count
    
    7)  If I don't see the human player, which way should I go?
       a) Can I go straight?  If so, move forward
       b) At random intervals, rotate the tank if the path is free to go in that direction
       c) If I am stuck, determine which way I can move and rotate the tank in that direction
       d) If my health is low, make sure there are obstacles between the human and me
    
    8)  Is there something blocking my path?  Which way should I turn instead?
       a) If I don't see the human, turn a random direction and try that instead
       b) If I see the human, choose a new path to a clear shot
    
    9)  Is a tank shell coming at me?  Where can I move to avoid it?
       a) Determine the angle of the attack and move perpendicular to it if free to do so.
    

    Then, once you have your decisions and how your AI will handle them, then it's up to you to take your flowchart and code it. By this, it means you have to come up with the programming for "If I see the human, choose a new path to a clear shot" and what that means for your game. This could be several lines to hundreds of lines of code for each part, depending on how complex your AI is.

    Then, to go a step further, you can provide the AI some learning capacity:

    1) Does the human player tend to back off when he's hurt?  If so, how should I react to that?
    2) Does the human come straight for me instead of flanking?  If so, how should I react to that?
    3) Is the human fairly accurate with his shots?  If so, should I use cover more?
    

    Again, how to code these measurements and responses is up to you, but you should already be able to see the value in thinking about all these details and writing them down ahead of time, so the coding will be easier when you're ready to program the AI rules of engagement.

  • The approach that describes (nice, clear example, btw!) is called a "behaviour tree", and it's a very common structure used in the A.I. in all sorts of games.

    Here's another slightly more detailed example, which describes the implementation of behaviour trees in the game "Spore": chrishecker.com/My_Liner_Notes_for_Spore/Spore_Behavior_Tree_Docs

  • thank you for your help guys, i appreciate it :), i can be very hard to code but it could bring a quality game play.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)