Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9799) PATCH: rewrited adjust_map()
Home

[Freeciv-Dev] (PR#9799) PATCH: rewrited adjust_map()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9799) PATCH: rewrited adjust_map()
From: "Marcelo Burda" <mburda@xxxxxxxxx>
Date: Fri, 27 Aug 2004 05:18:09 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Ven. Aoû. 27 00:51:11 2004]:
> 
>
> > -  /* Translate heights so the minimum height is 0. */
> > -  maxval -= minval;
> > +  /* Translate heights so the minimum height is 0 and  maximum is
maxval.
> > +     and count pos in granularity */
This code will count the numbers of occurencies of some height
> > +  max -= min;
> >    whole_map_iterate(x, y) {
> > -    hmap(x, y) -= minval;
> > +    hmap(x, y) = (hmap(x, y) - min) * maxval;
> > +    hmap(x, y) /= max;
> > +    f[hmap(x, y)]++;
> >    } whole_map_iterate_end;
> > +
this part do a incremental distributions of occurenties to create the
linearize function
> > +  /* create the linearize function */
> > +  for(i =  -1; i++ < maxval;) {
> > +      count += f[i];
> > +      f[i] = (count * maxval) / (map.xsize * map.ysize) ;
> > +     }
> > +
> > +  /* apply the linearize function */
> > +  whole_map_iterate(x, y) {
> > +    hmap(x, y) = f[hmap(x, y)];
> > +  } whole_map_iterate_end; 
> >  }
> 
> I think this can be better done using qsort and skipping the translation 
> step.
> 
no sort any time, noting to do with qsort!
> jason
> 
> 
> 
Marcelo



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