# Moving unit in strategy game

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

## Recommended Posts

Hello, This is a beginner's question... In a clone of Final Fantasy Tactics, my map has a Coordinate system with x, y, z values, where z is the height of the block the unit is standing on. I want to move an unit from coodinate 0,0,0 to coordinate 6,6,0, for example, and I want to know where I can find resources to help me implement this. I am using java, and I have a Coordinate class. Each Block (also a class) of a Scenario has a Coordinate. So, when an Unit moves, it calculates the "best path" that it can take to get where it wants, returning for the Engine an array of Coordinates indicating the Blocks the unit will walk over. Of course, Blocks that are deep water, or obstacles, can't be walked over. So, this is the situation... Am I too wrong, or is this the right way to do it? Suggestions would be appreciated. Forgive my poor english, Son of Cain

##### Share on other sites
I think you need a basic A* algorithm.

Try
http://www.geocities.com/jheyesjones/astar.html
and
http://www.edenwaith.com/products/pige/tutorials/a-star.php

some java source here
http://cvs.sourceforge.net/viewcvs.py/spgl/spgl/src/com/shavenpuppy/jglib/algorithms/

##### Share on other sites
There are some good arcticles on A* on gamedev.net. Also if the unit moves over difficult terrain, you can add points to the amount it has moved so far.

##### Share on other sites
You don't need A* for a FF tactics clone. Considering the size of your board, the way unit's availiable movements are defined, and the restrictions on the length of movement for a peice (no more than 9 or so), you should use an iterative-deepening search. Iterative-deepening would be faster in your case.

A* searches should mainly be used where there are variable hueristics. Iterative-deepening is usually a better choice when every move has a constant cost (ie every move has a cost of 1). That is, unless the search space is relatively large. FF tactics isn't large at all.

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632960
• Total Posts
3009476
• ### Who's Online (See full list)

There are no registered users currently online

×