Advertisement

Artificial Inteligence

Started by December 18, 2000 01:08 PM
9 comments, last by wolverine 24 years ago
Merry Christmas oh oh oh oh aham Seriously now. I''ve made a game similar to eye beast. Basicly it''s composed by one hero, 5 monsters, some blocks wich define the borders and some other randomly positioned blocks wich the hero uses to trap the monsters. Now, my monsters are very stupid because they just follow the hero in a straight line. What i realy like them to do is to find the closest path to the player counting with the random blocks. Anyone knows any document or particular technique to make this? I apreciate it. Thanks .
Ummm.... look up A* algorithim? (sp?) That''s all I know about it... I heard that the A* alg. is the best for such things - cost vs. distance? I have no idea really

------------------------------
BCB DX Library - RAD C++ Game development for BCB
Advertisement
the A* algorithm seems to be a good way to do it, although i''ve never gotten it to work correctly. it takes a bit of reading to understand it at first, but once you get it, you should be able to implement it easily. some sites with good info are:

http://www.generation5.org
and
http://www.gameai.com


--
davidw@heehaw.com
neonstar entertainment
--david@neonstar.netneonstar entertainment
I''ve also heard about the A* algo, but i never real knew what it was.
Thanks for answering so fast to this posts guys. I''ve been to those two sites and downloaded the docs i''ve found about it. I''ll study them and try to understand them.

Thanks again.
Nop.
I''ve decided to leave the A* algo out of this by two reasons:
first, it seems hard to implement (and understand); second, the position of the player and of the random blocks is changing constantly and since my monsters can only move once per second (being the player a lot faster) they would have to do a lot of calculations for one moment. In the next decision they make they would have to recalculate the new positions because the player may be at a different board position.

There must be more algos to do this.
There has to be....
Try this tutorial instead. It includes an overview of alternative pathfinding algorithms which is really essential to understanding A*. How you arrive at an algorithm is essential to understanding rather than just using the algorithm like the differance between knowing the formula for the area of a circle and understanding why that is the formula. Even if you still decide to not use A* it will explain the alternatives to you.
Keys to success: Ability, ambition and opportunity.
Advertisement
Nice....

I think that the kind of algo that will work better for my game scenario is the Breadth-first search on your doc, LilBudyWizer.

thanks again.

Merry christmas to all.
What do you think about this ideia?

You have the map with the blocks, the hero and the monsters.
I pick the hero and mark all the adjacent houses as ''1'' (just an example), the next ones which are one house away as ''2'' and so on. If one of those houses has a block on it i dont mark it.
Eventualy, if the monster isn''t trapped by the blocks, i''ll be able to mark the house where the monster is in. Then i just have to follow the path marked as n=monster,n-1,....,2,1.

Tell me your opinion about this!!!!!!
Seems it should work. If the destination is a ways away from the starting point it might take a bit of work. Don''t forget that the distance on the diagonal is 1.414 not 1. 1.4 should do well enough though you will favor diagonals. Since you have to keep a list of all the squares arrived at in the last iteration I would short-circuit it any time that list is a length of one. However you are going to get there you have to move to there first. An example would be a room with a single doorway in it. If the player isn''t in the room then the monster has to go through the door. Where to go after that doesn''t matter until you go through the doorway.
Keys to success: Ability, ambition and opportunity.
Well, to my surprise, i''ve coded and it works very well.
The diagonals aren''t much of a problem since the monster can always move one house in either direction (diagonal included).
The hero is the only who can''t do diagonals.
The monsters can only move once per second, but the player speed doesn''t have any limit (this is because there are 5 monsters against one hero; making the mosters speed equal to the players one would be a little bit unfair to the hero).

So every second, before making the monsters movement, i make the hero mark all the houses. Then i move the monsters. Finally i reset all the house numbers to -1.

The only thing that''s missing is changing the monsters behavior when there is no possible path to the hero (when the hero isolates him self from the monsters). This will do well with some random movement.

Thanks for your ideas

This topic is closed to new replies.

Advertisement