[Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Tue, Oct 23, 2001 at 09:32:54AM -0700, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> Raimar Falke wrote:
> >
>
> <snip snip snip>
>
> > It looks like the filter approach and the "classical" approach both
> > have cases were one is faster. What do you think about a general
> > interface:
> >
> > #define RAND_POS(x, y, pos_check,max_count)
> > if(max_count==0)
> > RAND_POS_CHECKED(x,y,pos_check);
> > else
> > {
> > do {
> > x=myrand(map.xsize);
> > y=myrand(map.ysize);
> > } while (!(pos_check(x,y)) && max_count-->0);
> > }
> >
> > Now the programmer can choose based on number he collected which
> > approach he uses.
>
> What about something like this?
Is it needed to have multiple map positions?
> +/* Determines whether the position is normal given that it's in
> + the range 0<=x<map.xsize and 0<=y<map.ysize. It's primarily a
> + faster version of is_normal_map_pos since such checks are pretty
> + common. */
> +#define is_normal_map_pos2(x, y) (1)
IMHO this name is still not acceptable.
> +/* Parameters:
> + * x_arr, y_arr: arrays (or single pointers) for the x and y coordinates
> + * number: an identifier containing the number of positions desired. It is
> + modified to contain the number of positions found.
> + * pos_check: an expression that determines if position (x, y) is valid.
> + * max_count: the maximum number of times a random algorithm should be
> + used before the structured algorithm is used. The random algorithm
> + may give duplicate coordinates, so use max_count==0 if you need all
> + distinct coordinates. */
> +#define RAND_POS_CHECKED(x_arr, y_arr, number, pos_check, max_count)
> \
> +{
> \
> + int *_x_arr = (x_arr); /* if x_arr is "x", it'll conflict down below */
> \
> + int *_y_arr = (y_arr);
> \
In general I think we should use "struct map_position" more. This may
such a place.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Of course, someone who knows more about this will correct me if I'm
wrong, and someone who knows less will correct me if I'm right."
-- David Palmer (palmer@xxxxxxxxxxxxxxxxxx)
[Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), jdorje, 2001/10/23
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017),
Raimar Falke <=
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Jason Dorje Short, 2001/10/23
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Raimar Falke, 2001/10/23
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Jason Dorje Short, 2001/10/23
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Raimar Falke, 2001/10/24
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Ross W. Wetmore, 2001/10/28
- [Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Raimar Falke, 2001/10/28
[Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), Ross W. Wetmore, 2001/10/23
[Freeciv-Dev] Re: PATCH: rand_pos function and usage(PR#1017), Jason Dorje Short, 2001/10/24
[Freeciv-Dev] Re: PATCH: rand_pos function and usage(PR#1017), Ross W. Wetmore, 2001/10/28
[Freeciv-Dev] Re: PATCH: rand_pos function and usage (PR#1017), jdorje, 2001/10/26
|
|