# Battle Engine 2D

This topic is 4851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok, so I'm really new to AI. But I'm trying to develop an engine much like SHining Forces. The problem I'm going to be facing soon is monster AI. Take a look at this screenshot so maybe you will understand better. http://www.freewebs.com/theprophecyseries/example.gif Pretend that the character is a monster. Now pretend there is that monsters target on the other side of the bush. How would I go about making the monster travel around the bush instead of just trying to walk into it? I'm designing the game in VB and I know very little c++, so if you could either describe it in psuedocode or simple c/c++, that would be awesome. Thank you :) I hope I explained it well enough.

##### Share on other sites
Wow looks pretty cool.

You're probably after FOV (field of view alg) can the monster see the player?
Or a path finding algorithm the path the monster should take to the player.

Yet Another Fast FOV (from the rogue-like newsgroup)

Dijkstras shortest path algorithm is a simple path finding alg and still pretty good

A terse description of the A* path finding alg

##### Share on other sites
No, there is no FOV. I'm just looking for a pathfinding technique.

I've downloaded a couple source examples to look at the different ways, but they are all huge garbled pieces of code. I don't even know where to start to understand what the code is all about. Any help? If the code is complicated I'm looking for something VB based. :)

And thanks Balaam

edit: Also, the monster may not be able to complete the whole move in one turn.

##### Share on other sites
The simplest method to find the shortest path is as follows:

Let Q be an empty queue
Add the current position of the monster to the queue, and set its predecessor to null
while Q is not empty

remove position x from the queue
mark x as visited
for each position y adjacent to x

if y is the destination, set its predecessor to x, and you can now follow the trail of predecessors back to the starting position to get the path, and we're done

if y is a valid space to move to and it has not been visited, add it to the queue, and set its predecessor to x

end for

end while

if the destination was never reached in the while loop, it must be unreachable

This algorithm is called breadth first search.

##### Share on other sites
oops, I made a mistake in that pseudocode. a position should be marked as visited when it is added to the queue.

##### Share on other sites
I'm quite familiar with the shining force series. When building up possible walkable locations you simply branch out from the source location based on movement distance and exclude unwalkable paths. Once your tree is made the unit can select a target within that walkable tree and it'll already know how to walk there. You have to consider flying units and walking units differently however since flying units can fly over regions walking units can't.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 9
• 31
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634118
• Total Posts
3015607
×