Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2004:
[Freeciv-Dev] Re: (PR#8959) remove CAR_DIR_D[XY]
Home

[Freeciv-Dev] Re: (PR#8959) remove CAR_DIR_D[XY]

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#8959) remove CAR_DIR_D[XY]
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Tue, 22 Jun 2004 05:09:57 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=8959 >

On Mon, 21 Jun 2004, Jason Short wrote:

> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8959 >
>
> > If the ordering of the directions is changed to rotational, the test for
> > cardinal-ness is just a test for even-ness (or odd-ness).
>
> Except on a hex map.

On a fake hex map you mean.  Because on a real one every valid direction
is cardinal (edge-joined with the center tile).

> We have a similar problem for adjc_dir_iterate in that in hex maps not
> all directions are "valid".  So either we need a call to is_valid_dir
> here or we need something else clever.  adjc_dir_iterate actually is
> used a lot (unlike cart_iterate which is almost never used) so there
> actually is a speed issue here.  However the alternatives have drawbacks
> as well:

I am not quite sure whether the below are disjoint alternatives or
combinable parts.  So here is a proposal based on some of them:

Part (a)
> Make new arrays VALID_DIRS[] and CARINDAL_DIRS[].  These arrays
> contain the list of valid (for adjc_dir_iterate) and cardinal (for
> cart_iterate) directions.  Of course these arrays must be initialized,
> and that means extra code (in init_topology).

Part (b)
Make two variables NUM_VALID_DIRS and NUM_CARD_DIRS which give sizes of
the arrays from part (a).

Part (c)
Make a macro
  dir_array_iterate(...., dir_array, num_dirs)

Part (d)
   #define adjc_dir_iterate(...) \
     dir_array_iterate(..., VALID_DIRS, NUM_VALID_DIRS)

   #define cart_iterate(...) \
     dir_array_iterate(..., CARD_DIRS, NUM_CARD_DIRS)

This, I feel, will have the best features of Ross' model and be more
extensible because the subset of dirs over which you want to iterate next
doesn't have to form an arithmetic progression in the total set of all
directions.

G.

P.S. I still remain very sceptical about new topologies such as hex or
quincical.  I think there are more worthy issues to be dealt with.




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