Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: the directional system
Home

[Freeciv-Dev] Re: the directional system

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: the directional system
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Mon, 10 Sep 2001 19:42:01 -0400

At 12:26 PM 01/09/10 +0200, Raimar Falke wrote:
>On Mon, Sep 10, 2001 at 06:06:45AM -0400, Jason Dorje Short wrote:
[...]
>So we may have:
>extern int _DIR_REVERSE[8],_DIR_PREV[8],_DIR_NEXT[8];
>#define DIR_REVERSE(dir) (_DIR_REVERSE[dir])
>...
>
>The arrays are filled once at runtime. I like this since this will be
>system independent.

Actually, since you are using macros, how you implement them is a matter
of changing a few lines of header code, and should not be a cause for
great debate or concern.

It is probably foolish to define arrays for either the rotational or
array based order reverse operations since they have a simple more
efficient expression implementation. Provided you aren't doing shared 
object loads where you might mix systems with incompatible shared
objects and this will have otehr worse problems, this will work fine.

Filling arrays once at runtime is a recipe for disaster. Better to define
them at compile time as const objects and never have to worry about the
setup order etc.

For just next and previous (note next implies clockwise) or left and right
again in a rotational system the expression works well. But for an array
based system, the array is definitely the way to go.

Except, that you don't want to limit yourself to single steps. You really
want a DIR_LEFT(n, dir) and DIR_RIGHT(n, dir) where in fact you don't put
any limits on how many elements there are in the array. For the 2nd ring
outwards there are 16 elements, in a hexagonal map there are 6.

Again these are simple expressions in a rotational system, and the only
arrays needed are the primary ones for X and Y increments.

The array technique may be useful when more complex systems are tried
but there is no need to go overboard until it is needed - it is a good
fallback to have on the shelf though.

>BTW: NEXT and PREV aren't good names. CLOCKWISE and COUNTERCLOCKWISE
>would be better.

Not really. They are both too long when simpler choices exist. Unless
you want to go for CW and CCW.

>       Raimar
>
>-- 
> email: rf13@xxxxxxxxxxxxxxxxx
>  A supercomputer is a computer running an endless loop in just a second




[Prev in Thread] Current Thread [Next in Thread]