Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] Re: (PR#8624) New clima function to best handle terrain pl
Home

[Freeciv-Dev] Re: (PR#8624) New clima function to best handle terrain pl

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#8624) New clima function to best handle terrain place, used to place poles.
From: "Marcelo Burda" <mburda@xxxxxxxxx>
Date: Fri, 7 May 2004 11:16:55 -0700
Reply-to: rt@xxxxxxxxxxx

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

Le ven 07/05/2004 à 19:06, Jason Short a écrit :
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=8624 >
> 
> Marcelo Burda wrote:
> 
> >>And...
> >>
> >>You can't hard-code the number of tiles.  This value would change under 
> >>a hex-tiled map.  Instead we need an else clause.  I guess this means 
> >>you need a hard-coded iterator.  Or maybe add an "else" clause to one of 
> >>the existing iterators.
> >>
> > 
> > mmm... i need there this function. 
> > In the hex-tiled map you need to patch with a else for the hard coded
> > number. the concept of these patch is based in the way i need implement
> > iterators, then i am no choice about the hard coded number.
> > probably i go use a litle sqare today, this will change in exteded
> > topologies patch.
> > i need to see your hex patch to make choices but i ll am no make it
> > today
> 
> With the right implementation it will work find for hex tiles too.
> 
> Something like:
> 
>    for (x_itr = -2; x_itr <= 2; x_itr++)
>      for (y_itr = -2; y_itr <= 2; y_itr++)
>        if (map_distance_sq(x, y, x0 + x_itr, y0 + y_itr) <= 4)
>          if (!is_real_map_pos(x0 + x_itr, y0 + y_itr))
>            return TRUE;
>    return FALSE;
> 
> the problem is that this iteration is actually looking for the unreal 
> case.  All of the iterators in map.h skip automatically past such 
> positions.  So there is no way to use the current iterators to do this task.
> 
> It also may not be obvious why this works in hex tiles.  Hex tiles don't 
> correspond to cartesian coordinates the way rectangular tiles do, so the 
> loop may actually cover a weird shape on the map.  However 
> map_distance_sq will give the correct value so things will actually work.
> 
> It would be possible to change the iterators to allow for an "else" 
> case.  But it wouldn't be pretty.
this option of else is not realy nice: "else what!" there are more than
one action can make a else. this is not realy clear concept.

I can use a full writed code inside this function, but this is probably
99% the some than one iterator of map.h.

the probem is to known the number to counted in a no-singular position
and compare it  the option i am thinking in.:
static int near_count_tiles(int map_x, int map_y) 
{
  int count = 0;
  /* any iterator there ! */
  square_dxy_iterate(map_x, map_y, 1, x_itr, y_itr, dx_itr, dy_itr) {
    count++;
  } square_dxy_iterate_end;

  return count;
}


static bool near_singularity(int map_x, int map_y)
{
  static int target_count = -1;

  /* i asume singularities are only near borders */
  if(!IS_BORDER_MAP_POS(map_x, map_y, 1)) {
    return FALSE;
  }

  /* first call */
  if (  target_count < 0) {
    do_in_map_pos(x, y, map.xsize / 2, map.ysize / 2) {
      target_count=near_count_tiles(x, y);
    }
  }

  /* this is a basic iterator, we can't use for this more complex ones*/
  square_dxy_iterate(map_x, map_y, 1, x_itr, y_itr, dx_itr, dy_itr) {
    count++;
  } square_dxy_iterate_end;

  return near_count_tiles(map_x, map_yy) < target_count ;
}

> 
> jason
-- 
 . /  .     '    ,    .      (*)   '        `     '      `    .    
  |    ,  |   `     ,     .      ,   '  Marcelo Julián Burda      .
 /  '     \     `     \@_     '      .        '      `        '    
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




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