Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8876) CM cache1 is way too big
Home

[Freeciv-Dev] (PR#8876) CM cache1 is way too big

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8876) CM cache1 is way too big
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 30 May 2004 15:02:45 -0700
Reply-to: rt@xxxxxxxxxxx

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

The citizen management code's cache1 cache is much bigger than it needs 
to be.  This is because it uses a spatially inefficient index mechanism.

With n citizens to be places as citizens and m different citizen types, 
you really only need

   C(n + m - 1, m - 1)

different combinations (I could be off-by-one here).  With the current 
m==3 this is (n + 2) * (n + 1) / 2.

However the cache contains

   (n + 1) ^ (m - 1)

different elements.  Of course all the extra ones aren't valid positions 
and are unused.  With the current m==3 this is

   (n + 1) ^ 2

of course specialists that can't be used by the city shouldn't be 
included in the "m" here.  Currently this may include some citizens 
based on city size.  But this may be extended in future (some 
specialists may have tech_reqs, others may be obsoleted by new specialists).

jason




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8876) CM cache1 is way too big, Jason Short <=