Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8754) effects patch
Home

[Freeciv-Dev] (PR#8754) effects patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: vasc@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#8754) effects patch
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 May 2004 19:36:17 -0700
Reply-to: rt@xxxxxxxxxxx

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

The main difference in your design from Ben's original design is that
you use a "ruleset" and a "sources" cache instead of Ben's "effects" cache.

The effects cache includes all effects applicable to a particular target
range.  It is generated from time to time - a time-consuming activity,
and bug-prone.

By comparison, you use two different caches and use a double-lookup to
find the applicable effects.

The ruleset cache lists which sources provide which effects.  An entry
in this cache says "increased research is provided by the library".  So
when doing something with the EFT_SCIENCE_BONUS, you do the lookup and
come up with library (among others).

The ruleset cache is introduced by Vasco's patch.  It is computed when
the ruleset is loaded and never needs to be changed.

The sources cache lists which sources are present at a particular range.
 Once you've found that library provides EFT_SCIENCE_BONUS, now you need
to know how many libraries are within the "City" range.  So you do a
lookup into the sources cache and find that the city has a library.  So
the city gets the bonus.

Vasco's patch doesn't introduce any new sources caches but makes use of
existing caches.  To get full support a different cache is needed for
each range and each source type.  So you need a list of city-improvs,
island-improvs, player-improvs, world-improvs.  This "list" should just
be an array of integers (holding the number of such sources within the
range).  For wonders there are already player- and world-ranged caches.
 Techs also have player- and world-ranged caches.  All improvements have
a city-ranged cache.  There is no island-range improv cache nor any unit
caches.  I'm not sure about government caches.

The sources cache is updated when sources are changed.  As the existing
sources caches show this is pretty easy (and it's O(1)).

It seems clear to me that the ruleset+sources cache method is better
than the effects cache method.  It's easy to update the sources cache as
you go along, rather than finding the right places to update the effects
cache (if you have too many places it will be very slow; with too few
there will be bugs).  And the lookups into each cache should be of
comparable speed.  I believe everyone has agreed that the
ruleset+sources-cache method is easier to code.  And it should be
obvious that the types of lookups allowed are the same in both methods,
so the effects-cache method loses its last advantage.  I cannot see any
advantage to the effects-cache method.

Can anyone more knowledgable about the effects system offer a rebuttal?

jason



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