Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7304) iso-map support for mapgen
Home

[Freeciv-Dev] Re: (PR#7304) iso-map support for mapgen

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7304) iso-map support for mapgen
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Wed, 28 Jan 2004 15:49:13 -0800
Reply-to: rt@xxxxxxxxxxx

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

On Wed, 28 Jan 2004, Jason Short wrote:

> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7304 >
> 
> Gregory Berkolaiko wrote:
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7304 >
> > 
> > 1. This
> > 
> > +  for (yn = ymin; yn < ymax; yn++) {
> > +    for (xn = 0; xn < map.xsize; xn++) {
> > +      do_in_map_pos(x, y, xn, yn) {
> > 
> > is surely whole_map_iterate
> 
> Only if ymin and ymax have the correct values!

Ugh, didn't notice this.

> We could do a filtered whole_map_iterate:
> 
>    whole_map_iterate(x, y) {
>      map_to_native_pos(&xn, &yn, x, y);
> 
>      if (has_poles && (yn == 0 || yn == map.ysize - 1)) {
>        continue;
>      }
> 
>      ...
>    }
> 
> but this is neither faster nor less code.  Plus Ross would yell at us.

Why would he yell at us?  For too many extra index->coords conversions?

> There would be some use for a loop like
> 
>    #define native_block_iterate(xn0, yn0, w, h, xn, yn) \
>      { \
>        int xn, yn; \
>        for (xn = xn0; xn < xn0 + w; xn++) { \
>          for (yn = yn0; yn < yn0 + h; yn++) {
> 
> possibly with a conversion to map coordinates included.  But I haven't 
> yet written such a block.

Yes, this would be nice.  Immediately breaks your newly proposed macro 
rules too!  But useful in many places.

> > 2. Here
> > 
> > +    get_random_nat_position_from_state(&xn, &yn, pstate);
> > +    if (hnat(xn, yn) == 0 && (hnat(xn + 1, yn) != 0
> > +                         || hnat(xn - 1, yn) != 0
> > +                         || hnat(xn, yn + 1) != 0
> > +                         || hnat(xn, yn - 1) != 0)) {
> > 
> > you are doing adjacency in natural coordinates, a bad idea!
> > when fixing, make sure you hide away all arithmetic, say using
> > cartesian iterate.
> 
> Hmm.  I had thought this math was supposed to be done in native 
> coordinates - most of the map math is.  But I see now it's just a 
> cartesian_iterate.  I think.

yes, here it tries to place a piece of land non-diagonally adjacent to 
some other peice of land.  Native would give you diagonally adjacent.

> > 4. In general, wherever possible, try to get rid of cycles and do 
> > iterates.  For example all cycles of initworld can be done within one 
> > whole_world_iterate plus a few ifs.  This will make things more portable I 
> > feel.
> 
> Possibly.  I moved away from doing loops like
> 
>    whole_map_iterate(x, y) {
>      if (...) {
> 
>      }
>    }
> 
> because Ross's blood pressure was getting too high.  I think the current 

I am glad I missed it.  Can you summarize the argument though?

G.




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