Menu

#51 Generalize fish bonus calculation to work for other goods

Current
closed-fixed
nobody
None
1
2015-08-14
2008-12-29
abartels
No

Right now, the calculation of fish bonus is a hard-coded special case, because fish bonus is the only one taking characteristics of adjacent tiles (land/!land, river) into account.

1.
Tile:getFishBonus() should be generalized into Tile:getGoodsBonus(GoodsType), to work for other types of goods as well.

2.
All necessary constraints&values should be loaded from specification.xml.

Discussion

  • Michael Vehrs

    Michael Vehrs - 2009-01-05

    Which "constraints&values" do you envisage?

     
  • abartels

    abartels - 2009-01-05

    "Condition" would have been the better term, not constraint...

    For fish bonus, we have the following conditions:
    A: More than 2 adjacent tiles are land (bonus_value=2)
    B: At least 1 adjacent tile is a river (bonus_value=1)

    [Where B is not completely Col1-compatible yet. For full compatibility, it should be:
    B': At least one river adjacent in a possible river flow direction (NW, NE, SW, SE), which flows towards "this" tile.]

    One could think of similar conditions for other resources:
    Lumber: More than 3 adjacent tiles are forested (bonus for heavily forested areas)
    Grain: More than 2 adjacent tiles are a river (bonus for fertile ground alongside a river)
    Ore: If the tile has an ore bonus; then bonus_value=X, where X=number of adjacent mountain/hill tiles.

    So generally, we'd need to encode the following to make the above possible:
    1. Tile-condition: What tile-type? What bonus resource? Special cases like "hasRiver" or "isForested"
    2. Adjacent-tiles-condition: as above, combined with Min/Max (number of tiles that need to fulfill that condition), Adjacency (what positions are considered adjacent for this rule)
    3. the bonus modifier (=value), that is applied if all conditions are met.

    A possible XML-structure for that might be (using fish bonus as example):

    //fish bonus along coasts
    <goods-modifier id="***">
    <tile-condition condition="isWater"/>
    <tile-adjacent-condition condition="isLand" min="3" max="8" adjacency="8-neighbourhood"/>
    <modifier id="model.goods.fish" type="additive" value="2"/>
    </goods-modifier>

    //fish bonus in ocean near river mouths
    <goods-modifier id="***">
    <tile-condition condition="isOcean"/>
    <tile-adjacent-condition condition="hasRiver" min="1" max="8" adjacency="4-neighbourhood-minor"/>
    <modifier id="model.goods.fish" type="additive" value="1"/>
    </goods-modifier>

     
  • Mike Pope

    Mike Pope - 2013-05-30

    By 0.10.7 this is much more generalized as suggested. Closing.

     
  • Mike Pope

    Mike Pope - 2013-05-30
    • status: open --> closed-fixed
    • Group: --> Accepted
     

Log in to post a comment.