Advertisement

Moving unit in strategy game

Started by September 13, 2004 03:38 PM
2 comments, last by Zefrieg 20 years, 2 months ago
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
a.k.a javabeats at yahoo.ca
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/
Advertisement
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.
I am the master of ideas.....If only I could write them down...
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.

This topic is closed to new replies.

Advertisement