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]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: the directional system
From: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Date: Sun, 09 Sep 2001 06:00:07 -0400
Reply-to: jdorje@xxxxxxxxxxxxxxxxxxxxx

Raimar Falke wrote:
> 
> On Sun, Sep 09, 2001 at 05:08:00AM -0400, Jason Dorje Short wrote:

> > #define DIR_ADJACENT(dir1, dir2) ((dir1+1)%8==dir2 || (dir2+1)%8==dir1)
> >
> > versus
> >
> > #define DIR_ADJACENT(dir1, dir2) \
> >  ( dir1 == DIR8_NORTH  ? (dir2==DIR8_NORTHEAST || dir2==DIR8_NORTHWEST)
> > :
> >  ( dir1 == DIR8_NORTHEAST ? (dir2==DIR8_NORTH || dir2==DIR8_EAST) :
> >  ( dir1 == DIR8_EAST ? (dir2==DIR8_NORTHEAST || dir2==DIR8_SOUTHEAST) :
> >  ( dir1 == DIR8_SOUTHEAST ? (dir2=DIR8_EAST || dir2==DIR8_SOUTH) :
> >  ( dir1 == DIR8_SOUTH ? (dir2==DIR8_SOUTHEAST || dir2==DIR8_SOUTHWEST) :
> >  ( dir1 == DIR8_SOUTHWEST ? (dir2==DIR8_SOUTH || dir2==DIR8_WEST) :
> >  ( dir1 == DIR8_WEST ? (dir2==DIR8_SOUTHWEST || dir2==DIR8_NORTHWEST) :
> >  ( dir1 == DIR8_NORTHWEST ? (dir2==DIR8_WEST ||
> > dir2==DIR8_NORTH)))))))))
> 
> $ grep -Ir DIR_ADJACENT .|wc -l
>       0

No, there is not yet such a macro.  However dir_ok and
straightest_direction use code very similar to this.  They are also
incomprehensible.

> So I can't comment on this. The second DIR_ADJACENT looks more ugly
> but the first one holds knowledge about the ordering.

If this macro were placed into map.h, it would be acceptable for it to
hold knowledge about the ordering.

This is exactly what has already been done with DIR_IS_CARDINAL: the
macro has been created but no simplifications are easily possible under
the current directional system.  If the directional system were changed
it would be possible to have more elegance and better efficiency in
these macros.

> > I really don't see how you can argue the rotational system isn't
> > better.
> 
> Because the current non-rotational system is in place and works.

You are saying it's not worth the trouble to fix.

jason


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