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: Reinier Post <rp@xxxxxxxxxx>
Cc: Freeciv developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: the directional system
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 16 Sep 2001 14:08:21 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Sep 16, 2001 at 12:50:02PM +0200, Reinier Post wrote:
> On Fri, Sep 14, 2001 at 08:55:03PM +0200, Raimar Falke wrote:
> > On Fri, Sep 07, 2001 at 02:18:45PM +0200, Raimar Falke wrote:
> > > On Fri, Sep 07, 2001 at 04:51:36AM -0700, Trent Piepho wrote:
> > > > On Fri, 7 Sep 2001, Jason Dorje Short wrote:
> > > > 
> > > > +#define DIR_REVERSE(dir) (((dir) + 4) % 8)
> > > > 
> > > > This is a faster way to do it.  Modulus operations are very expensive, 
> > > > but a
> > > > bitwise and is very cheap.
> > > > 
> > > > +#define DIR_REVERSE(dir) (((dir) + 4) & 7)
> > 
> > As one last experiment I change the current (7-dir) to the general
> > form which will always work in every direction system:
> > 
> > diff -urd -X freeciv.current/diff_ignore freeciv.current/common/map.h 
> > work/common/map.h
> > --- freeciv.current/common/map.h        Fri Sep 14 09:31:33 2001
> > +++ work/common/map.h   Fri Sep 14 18:47:39 2001
> > @@ -442,7 +442,16 @@
> >  };
> > 
> >  /* return the reverse of the direction */
> > -#define DIR_REVERSE(dir) (7 - (dir))
> > +#define DIR_REVERSE(dir) \
> > +((dir)==DIR8_WEST?DIR8_EAST: \
> > + ((dir)==DIR8_EAST?DIR8_WEST: \
> > +  ((dir)==DIR8_NORTH?DIR8_SOUTH: \
> > +   ((dir)==DIR8_SOUTH?DIR8_NORTH: \
> > +    ((dir)==DIR8_NORTHWEST?DIR8_SOUTHEAST: \
> > +     ((dir)==DIR8_NORTHEAST?DIR8_SOUTHWEST: \
> > +      ((dir)==DIR8_SOUTHWEST?DIR8_NORTHEAST: \
> > +       ((dir)==DIR8_SOUTHEAST?DIR8_NORTHWEST: \
> > +       (dir)/0))))))))
> > 
> >  /* is the direction "cardinal"?  Cardinal directions
> >   * (also called cartesian) are the four main ones */
> 
> This way you hardwire a 'chess-like' grid, which is less general than
> a general rotational system.  For example, the 3 other types of regular
> Cartesian grids (triangular, square without diagonals, hexagonal) 

> cannot be expressed in this way

Why not?

>, while they would be fairly easy to implement in Freeciv.

I doubt this. There would be a lot of places which have to change.

> > So the general form is 1% slower.
> > 
> >     Raimar
> 
> That's acceptable, and as long as no other grid types are supported,
> it's obvious makes the code easier to understand.

I wasn't proposing such a change. We are still in a performance
discussion ;)

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Transported to a surreal landscape, a young girl kills the first woman
  she meets and then teams up with three complete strangers to kill again."
    -- TV listing for the Wizard of Oz in the Marin Independent Journal


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