How can I add an advanced ai

Discuss game development design and post your game ideas

Post » Tue Apr 05, 2016 2:40 pm

I would like to see if I can add an ai that can wait for a random guy time and then move toward a player at increments stopping in between, like a guard on watch :?:
B
7
S
3
G
1
Posts: 6
Reputation: 1,728

Post » Tue Apr 05, 2016 2:58 pm

There are many different ways of doing enemy AI but the simple and effect way I handle AI is giving each of your sprites an AI instance variable and set their behaviors to coincide different values.

Enemy AI=0 the enemy does nothing
Enemy AI=1 move up
Enemy AI=2 move down
Enemy AI=3 move towards the player and attack every random(1,3) seconds

Then set the variable based on time or distance or collisions. So if the enemy does not have line of sight to the player every 3 seconds switch between 1 and 2 then if the enemy gets line of sight set the variable to 3. You could also do this by creating invisible checkpoints and mapping out paths for them to walk changing their AI variable based on which checkpoint they collide with. It can get very complex but that is my quick explanation on how I do it.
B
34
S
15
G
1
Posts: 80
Reputation: 2,727

Post » Tue Apr 05, 2016 3:39 pm

Just an idea

https://
drive.google.com/open?id=0B1SSuCVV8v74Rll5cktQcGR1Skk

But, you have to finetune it yourself.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 06, 2016 3:41 am

Talking about advanced AI......

I wonder if it is possible to create a game like street fighter, to fight against different characters, each one with a particular AI.

maybe it is too difficult to do.
B
67
S
32
G
69
Posts: 217
Reputation: 40,060

Post » Wed Apr 06, 2016 1:09 pm

That would be an interesting game to play, you could make it retro style and retro graphics as well.
B
7
S
3
G
1
Posts: 6
Reputation: 1,728

Post » Fri Apr 15, 2016 9:55 am

State Machines would be the best practice method I guess. This Tutorial for example: https://www.scirra.com/tutorials/1139/h ... e-machines
B
6
Posts: 13
Reputation: 283


Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: No registered users and 0 guests