On Nov 21, 2005, at 6:11 AM, Stephen Dodd wrote:
A really simple, though perhaps not processor optimal, solution would
be:
* Make a class representing a hex
* Every hex on the board is an instance of the Hex Class
* Every instance knows the 6 other instances around it.
* Starting from the player's hex, give a movement points value. Send
that value to each of the surrounding 6 hexes.
* When receiving the movement value, the hex subtracts its terrain
count. If there's enough movement value left, it then highlights
itself.
If it's not an instance of impassable terrain. Otherwise you'll have
a problem with troops wandering willy-nilly over your mountains, and
through your streams... Oops.
If it highlights itself it then send the (now subtracted) movement
value to each of the 6 hexes around it.
Except the ones already highlighted, I hope...
* You'll want to flag if a hex has already been "processed" this turn
to avoid redundancy.
In this way, the movement value will propagate out to all hexes that
can take it reducing with each step until it can't go anymore.
Let me know if you need clarification.
Cheers,
From: Thomas Compter <tcompter at adelphia dot net>
Date: Sat, 19 Nov 2005 12:15:23 -0500
I have a question that is not specific to RealBasic, but a general
game
algorithm question.
I'd like to develop a game (in Realbasic and several other platforms)
that plays like the old Panzer General series of wargames.
Specifically, I would like when the player clicks on a unit, all the
hexes that the unit can move to are highlighted, so the player can
just
then click on the desired destination hex. My design includes the
concept of movement points and terrain costs, so it's not as simple as
counting out a given number of hexes.
In my research on the net, I've heard discussion of "path finding"
algorithms, but they seem to be referring more to 1st person shooter
type games where the AI or game has to figure out the shortest path
between two given points. My problem is the inverse: I need to find
every location within range.
Can anyone suggest or point me to an algorithm that would do what I'm
looking for?
Thanks.
--
---------------- TRANSCENA DESIGN INC ---------------
Stephen Dodd | stephen at transcena dot com | 780-429-2363
10714 106 Avenue Edmonton Alberta Canada T5H 0R1
N. America: 1-888-429-2363 | UK: 011 44 20 7529 1465 --------------
http://www.transcena.com -------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
wsquires at satx dot rr dot com dot nospam <- remove the .nospam
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|