Complete.Org: Mailing Lists: Archives: freeciv-ai: January 2003:
[freeciv-ai] Re: Goto coordinates and ai roles
Home

[freeciv-ai] Re: Goto coordinates and ai roles

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: "Per I. Mathisen" <per@xxxxxxxxxxx>, freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: Goto coordinates and ai roles
From: Mike Kaufman <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 18 Jan 2003 14:51:37 -0600

On Sat, Jan 18, 2003 at 12:05:39PM -0500, Ross W. Wetmore wrote:
> 
> If you cannot rely on an arbitrary map_position to represent an invalid
> position (i.e. all map positions are potentially valid), then you need an
> extra bit of information somewhere. There are two common ways to do this.
> 
> Set a goto_active guard bit and do things like 
>   if (punit->goto_active) {
>     /* punit->goto_dest_x, punit->goto_dest_y accesses */
>   }
> 
> Make the goto_dest a map_position pointer and use null as the guard test.
>   if (punit->goto_dest) {
>     /* punit->goto_dest->x, punit->goto_dest->y accesses */
>   }
> 
> Note, the pointer can point back into the punit structure, so you don't
> need to track extra memory allocations, and can in fact directly access 
> the punit goto(x,y) values if necessary, bypassing the guard check. The
> pointer acts very much as a guard test that allows you to turn the goto
> map_position on and off.
> 
> Both of these mean breaking backwards compatibility for the (-1,-1)
> error assumptions including over network communications. But the tests
> are much simpler than a same_pos() or some unnormalized version to
> detect the special case. 

yes, either of these is far better than (-1,-1) which I've never ever had a
good feeling about. Take your pick really, but I prefer the the map_position
pointer because it's cleaner...

-mike


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