Ai help

Blitz3D Forums/Blitz3D Beginners Area/Ai help

Azaratur(Posted 2007) [#1]
I try to write my own ai, i need to say something like that "if an enemy attack this entity with long range weapon find a cover".
I don't know what i can do to set the perimeter of an object.. like an house there is the front side, back side, right and left side.
Do i create some pivot and say "stay inside at this 2 pivot"?
Aza


Ross C(Posted 2007) [#2]
Well, it's a bit more complex that a simple if statement. You'd need a route for the enemy to goto, making waypoint as safe places to retreat to and such. I think you need to do somemore research into pathfinding and the like :o)


IPete2(Posted 2007) [#3]
Azaratur,

Perhaps you could employ a grid system, like in chess,where you calculate a number representing a good move (a high score) or a bad move ( a negative score). Give them all the same score to begin, and update this score as the game progresses. So if a baddy is in grid 100,40 then that would be unsafe, but where is he looking or launching grenades to? Say he tosses a grenade into grid 20,20. This grid plus all the surrounding grids would be affected. You would need to have a method of knowing which grid squares were next to each other. Using types to maintain this grid system, calculate the current, variable, amount of safeness, so you know which grid would be safe and which would be deadly to enter. Then make the AI character 'look' for a safe haven, away from the nasty long range whatever weapons.

As Ross says its not as simple as it may at first appear. I use a very crude waypoint system in my latest game, which works very nicely, but every implementation will be different, due to the circumstances of the game you are building.

You can show your grids on screen using cubes or cones, give them a colour to represent how safe they are red= unsafe, to yellow = moderately safe, to green = totally safe. Obviously anything which can hurt you in the game needs to have an affect the safeness - therefore the colour of these grids/cones. By iterating through every loop you will find that the situation changes quickly and you move your AI character to a score which represents safe and watch out for if it becomes unsafe. At which point move him to a new nearby safe place and then your very basic AI will have started life.

Good luck

IPete2.


Azaratur(Posted 2007) [#4]
Thanks, i like the grid idea but how can i create a pathfinding? An example, my ai find a safe box he must go there but if there other object in his direction he must choose another safe path to reach the cover.. How?
Do you understand this?

Another question i create an ai not really "intelligent" i say if he want go to work then go in this first waypoint, now in the second.. to the last.
It's possible to create a function that receive first waypoint and last one and it calculate the path?

Aza


boomboom(Posted 2007) [#5]
http://www.policyalmanac.org/games/aStarTutorial.htm


Azaratur(Posted 2007) [#6]
I read it and i think it's really good guide thank boomboom, i need to create in 3d mode do you think i can create a 3d grid?


Moraldi(Posted 2007) [#7]
Take a look here: http://www.blitzbasic.com/Community/posts.php?topic=73941


Azaratur(Posted 2007) [#8]
I already dl it just 6 hours ago but i still at work now... I'll see it tomorrow!
Thanks


Ross C(Posted 2007) [#9]
I have created a pathfinding algo too. It's based around A*, to find the quickest path between START and END nodes.

I'll post it later when i create a decent interface to see it working :o)


Azaratur(Posted 2007) [#10]
Ok thanks a lot!


Azaratur(Posted 2007) [#11]
I create mine pathfinding.. It's really fast but not so perfect! In a normal maps with some building it can work perfectly but in a maze it probably lost hisself..
I try many time with the collision check for the building but it' doesn't work.
I need to close my cube but the only way i find is with entitydistance, and that is not so perfect, in what other way i can close the cube(node)?