Sign in to follow this  

Moving unit in strategy game

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this