Discussion:
[Freecol-developers] GoodsType, AbstractGoods, etc
Enrico Weigelt, metux IT consult
2016-12-03 08:53:26 UTC
Permalink
Hi folks,


could anyone please give me some insight, how GoodsType, AbstractGoods
and Lists of AbstractGoods play together ?

I guess, GoodsType describes the existing types of goods, while
AbstractGoods represents a storage slot (eg. in city or on a ship).

What puzzles me most: why are List<AbstractGoods> at all ?
AFAIK, the number of good types is strictly limited, so eg. in the
cities we could easily use an fixed-size array, thus never having to
iterate lists here.

Where are the producable goods on individual tiles coming from ?
Is this individual to each tile or derived from the terrain type ?
And how are the worker-type dependent values computed ? Is there some
per-worker-type factor ?


--mtx
Michael T. Pope
2016-12-03 09:57:42 UTC
Permalink
On Sat, 3 Dec 2016 09:53:26 +0100
Post by Enrico Weigelt, metux IT consult
could anyone please give me some insight, how GoodsType, AbstractGoods
and Lists of AbstractGoods play together ?
"Some insight"... no problem. Just do not ask for a "full
understanding"...
Post by Enrico Weigelt, metux IT consult
I guess, GoodsType describes the existing types of goods,
GoodsType is a type of goods, e.g. tobacco.
Post by Enrico Weigelt, metux IT consult
AbstractGoods represents a storage slot (eg. in city or on a ship).
Actually no, the Colony and Unit classes are instances of GoodsLocation
which wraps a GoodsContainer which does not store its contents in
AbstractGoods but in a java.util.Map, although some of its public
interface uses AbstractGoods for convenience. AbstractGoods is a
{<GoodsType>, <amount>} tuple. It is used in *many* different ways, and
the amount is sometimes usefully negative.
Post by Enrico Weigelt, metux IT consult
What puzzles me most: why are List<AbstractGoods> at all ?
I recommend reading the code a bit more to appreciate how often we need
to consider collections of AbstractGoods. You may also encounter Goods,
which are AbstractGoods with a Location, which also appear in Lists,
sometimes with non-unique GoodsTypes.
Post by Enrico Weigelt, metux IT consult
AFAIK, the number of good types is strictly limited, so eg. in the
cities we could easily use an fixed-size array, thus never having to
iterate lists here.
You are mostly right here that there is an upper bound, but the lists are
usually short and thus both faster to traverse and smaller than a
usually mostly-empty array.
Post by Enrico Weigelt, metux IT consult
Where are the producable goods on individual tiles coming from ?
Is this individual to each tile or derived from the terrain type ?
And how are the worker-type dependent values computed ? Is there some
per-worker-type factor ?
Yes to all the above, and more. The production rules are complex. I
believe I understood them about three months ago when we were actively
working on them, but the detail is fading. You are going to have to read
the code (see opening remark above).

Cheers,
Mike Pope

Loading...