Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#9763) Not fair: get_defender() fallbacs to tile ar
Home

[Freeciv-Dev] Re: (PR#9763) Not fair: get_defender() fallbacs to tile ar

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#9763) Not fair: get_defender() fallbacs to tile arrival time when selecting between equal units.
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 22 Aug 2004 16:16:15 -0700
Reply-to: rt@xxxxxxxxxxx

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

Gregory Berkolaiko wrote:

> Actually 1 is much easier to implement.  Here is the algorithm (get 
> get_defender before your eyes):
> 
> New variable n_equal is counting the number of equally strong best units 
> so far.
> 1. when change is TRUE we set n_equal = 1
> 2. when we encounter an equally strong unit, 
>   a) n_equal++
>   b) assign the new unit as the defender with probability 1/n_equal
>   c) do NOT reset n_equal
> 
> this algorithm selects the defender from among the equally strong units 
> with equal probability, without actually knowing, a priori, how many of 
> them there will be!  proof is by induction.

The algorithm is easy.  The problem is the result is not reproducable. 
get_defender() called on the same tile twice may not return the same 
defender.  This could be a problem for the AI or server code.  It would 
certainly be confusing for the client (mapview popup).

There are ways around this.  But they're ugly.

Another problem is get_defender() may differ between server and client.

jason




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