Add terrain affinity for tribe immovables
Bug #1338204 reported by
SirVer
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
widelands |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
Only world trees have terrain affinity right now. Fields, vine and everything else that tribes plant should have affinity too.
This needs
1) adding affinity parsing for tribe immovablaes (conf files) into the engine.
2) defining terrain affinity and testing it.
I think we should do this for b19 if possible.
Related branches
lp:~widelands-dev/widelands/bug-1731652-worker-plant-attribute
- kaputtnik (community): Approve
- TiborB: Approve
-
Diff: 2529 lines (+586/-360)114 files modifieddata/scripting/editor/tree_help.lua (+5/-26)
data/scripting/formatting.lua (+24/-0)
data/scripting/help.lua (+53/-0)
data/tribes/immovables/ashes/helptexts.lua (+2/-3)
data/tribes/immovables/ashes/init.lua (+24/-2)
data/tribes/immovables/blackrootfield_harvested/helptexts.lua (+2/-3)
data/tribes/immovables/blackrootfield_harvested/init.lua (+1/-0)
data/tribes/immovables/blackrootfield_medium/helptexts.lua (+2/-3)
data/tribes/immovables/blackrootfield_medium/init.lua (+1/-0)
data/tribes/immovables/blackrootfield_ripe/helptexts.lua (+2/-3)
data/tribes/immovables/blackrootfield_ripe/init.lua (+1/-0)
data/tribes/immovables/blackrootfield_small/helptexts.lua (+2/-3)
data/tribes/immovables/blackrootfield_small/init.lua (+1/-0)
data/tribes/immovables/blackrootfield_tiny/helptexts.lua (+2/-3)
data/tribes/immovables/blackrootfield_tiny/init.lua (+2/-1)
data/tribes/immovables/cornfield_harvested/helptexts.lua (+2/-3)
data/tribes/immovables/cornfield_harvested/init.lua (+1/-0)
data/tribes/immovables/cornfield_medium/helptexts.lua (+2/-3)
data/tribes/immovables/cornfield_medium/init.lua (+1/-0)
data/tribes/immovables/cornfield_ripe/helptexts.lua (+2/-3)
data/tribes/immovables/cornfield_ripe/init.lua (+1/-0)
data/tribes/immovables/cornfield_small/helptexts.lua (+2/-3)
data/tribes/immovables/cornfield_small/init.lua (+1/-0)
data/tribes/immovables/cornfield_tiny/helptexts.lua (+2/-3)
data/tribes/immovables/cornfield_tiny/init.lua (+2/-1)
data/tribes/immovables/destroyed_building/helptexts.lua (+2/-3)
data/tribes/immovables/destroyed_building/init.lua (+1/-0)
data/tribes/immovables/field_harvested/helptexts.lua (+2/-3)
data/tribes/immovables/field_harvested/init.lua (+1/-0)
data/tribes/immovables/field_medium/helptexts.lua (+2/-3)
data/tribes/immovables/field_medium/init.lua (+1/-0)
data/tribes/immovables/field_ripe/helptexts.lua (+2/-3)
data/tribes/immovables/field_ripe/init.lua (+1/-0)
data/tribes/immovables/field_small/helptexts.lua (+2/-3)
data/tribes/immovables/field_small/init.lua (+1/-0)
data/tribes/immovables/field_tiny/helptexts.lua (+2/-3)
data/tribes/immovables/field_tiny/init.lua (+11/-1)
data/tribes/immovables/grapevine_medium/helptexts.lua (+2/-3)
data/tribes/immovables/grapevine_medium/init.lua (+1/-0)
data/tribes/immovables/grapevine_ripe/helptexts.lua (+2/-3)
data/tribes/immovables/grapevine_ripe/init.lua (+1/-0)
data/tribes/immovables/grapevine_small/helptexts.lua (+2/-3)
data/tribes/immovables/grapevine_small/init.lua (+1/-0)
data/tribes/immovables/grapevine_tiny/helptexts.lua (+2/-3)
data/tribes/immovables/grapevine_tiny/init.lua (+2/-1)
data/tribes/immovables/reed_medium/helptexts.lua (+2/-3)
data/tribes/immovables/reed_medium/init.lua (+1/-0)
data/tribes/immovables/reed_ripe/helptexts.lua (+2/-3)
data/tribes/immovables/reed_ripe/init.lua (+1/-0)
data/tribes/immovables/reed_small/helptexts.lua (+2/-3)
data/tribes/immovables/reed_small/init.lua (+1/-0)
data/tribes/immovables/reed_tiny/helptexts.lua (+2/-3)
data/tribes/immovables/reed_tiny/init.lua (+2/-1)
data/tribes/immovables/resi_coal1/helptexts.lua (+5/-4)
data/tribes/immovables/resi_coal1/init.lua (+2/-1)
data/tribes/immovables/resi_coal2/helptexts.lua (+5/-4)
data/tribes/immovables/resi_coal2/init.lua (+2/-1)
data/tribes/immovables/resi_gold1/helptexts.lua (+5/-4)
data/tribes/immovables/resi_gold1/init.lua (+2/-1)
data/tribes/immovables/resi_gold2/helptexts.lua (+5/-4)
data/tribes/immovables/resi_gold2/init.lua (+2/-1)
data/tribes/immovables/resi_iron1/helptexts.lua (+5/-4)
data/tribes/immovables/resi_iron1/init.lua (+2/-1)
data/tribes/immovables/resi_iron2/helptexts.lua (+5/-4)
data/tribes/immovables/resi_iron2/init.lua (+2/-1)
data/tribes/immovables/resi_none/helptexts.lua (+2/-4)
data/tribes/immovables/resi_none/init.lua (+2/-1)
data/tribes/immovables/resi_stones1/helptexts.lua (+15/-8)
data/tribes/immovables/resi_stones1/init.lua (+2/-1)
data/tribes/immovables/resi_stones2/helptexts.lua (+15/-8)
data/tribes/immovables/resi_stones2/init.lua (+2/-1)
data/tribes/immovables/resi_water1/helptexts.lua (+2/-4)
data/tribes/immovables/resi_water1/init.lua (+2/-1)
data/tribes/immovables/shipconstruction_atlanteans/helptexts.lua (+2/-3)
data/tribes/immovables/shipconstruction_atlanteans/init.lua (+2/-0)
data/tribes/immovables/shipconstruction_barbarians/helptexts.lua (+2/-3)
data/tribes/immovables/shipconstruction_barbarians/init.lua (+2/-0)
data/tribes/immovables/shipconstruction_empire/helptexts.lua (+2/-3)
data/tribes/immovables/shipconstruction_empire/init.lua (+2/-0)
data/tribes/scripting/help/building_help.lua (+2/-2)
data/tribes/scripting/help/immovable_help.lua (+85/-0)
data/tribes/scripting/help/init.lua (+13/-0)
data/tribes/scripting/help/ware_help.lua (+1/-3)
data/tribes/wares/armor/init.lua (+27/-1)
data/tribes/workers/atlanteans/blackroot_farmer/init.lua (+1/-1)
data/tribes/workers/atlanteans/farmer/init.lua (+1/-1)
data/tribes/workers/atlanteans/shipwright/init.lua (+1/-1)
data/tribes/workers/barbarians/farmer/init.lua (+1/-1)
data/tribes/workers/barbarians/gardener/init.lua (+1/-1)
data/tribes/workers/barbarians/shipwright/init.lua (+1/-1)
data/tribes/workers/empire/farmer/init.lua (+1/-1)
data/tribes/workers/empire/shipwright/init.lua (+1/-1)
data/tribes/workers/empire/vinefarmer/init.lua (+1/-1)
src/economy/flag.h (+1/-1)
src/economy/fleet.h (+1/-1)
src/economy/portdock.cc (+1/-1)
src/economy/road.h (+1/-1)
src/logic/map_objects/immovable.cc (+3/-0)
src/logic/map_objects/map_object.cc (+6/-3)
src/logic/map_objects/map_object.h (+7/-1)
src/logic/map_objects/tribes/battle.h (+1/-1)
src/logic/map_objects/tribes/building.cc (+5/-4)
src/logic/map_objects/tribes/building.h (+0/-4)
src/logic/map_objects/tribes/tribe_descr.cc (+4/-3)
src/logic/map_objects/tribes/tribe_descr.h (+1/-0)
src/logic/map_objects/tribes/ware_descr.cc (+5/-5)
src/logic/map_objects/tribes/ware_descr.h (+0/-6)
src/logic/map_objects/tribes/worker.cc (+31/-40)
src/logic/map_objects/tribes/worker_descr.cc (+4/-3)
src/logic/map_objects/tribes/worker_descr.h (+0/-5)
src/logic/map_objects/tribes/worker_program.cc (+25/-31)
src/scripting/lua_map.cc (+47/-43)
src/scripting/lua_map.h (+4/-5)
test/maps/lua_testsuite.wmf/scripting/immovables_descriptions.lua (+12/-12)
Changed in widelands: | |
status: | New → Incomplete |
importance: | Undecided → Wishlist |
milestone: | none → build19-rc1 |
Changed in widelands: | |
milestone: | build19-rc1 → none |
Changed in widelands: | |
status: | Expired → Incomplete |
Changed in widelands: | |
status: | Incomplete → Expired |
Changed in widelands: | |
status: | Expired → Confirmed |
Changed in widelands: | |
milestone: | none → build20-rc1 |
assignee: | nobody → GunChleoc (gunchleoc) |
status: | Confirmed → In Progress |
Changed in widelands: | |
status: | In Progress → Fix Committed |
assignee: | GunChleoc (gunchleoc) → nobody |
tags: | added: tribes |
To post a comment you must log in.
The simplest way to do that is to use terrain affinity from trees (https:/ /bugs.launchpad .net/widelands/ +bug/1328635). The model for this feature should be a bit easier :)
At first I thought about bringing only "fertility" from the stats and use that, but that can't work on some terrains (desert, winterland). There are two possibilities:
1. Take a value as a mean of fertility and humidity
2. Take a maximum value of them
Then we can use the value for the immovable like in the trees model, but probably not the same way (more fertile land can be used as well as exact fertile land: we can assume that farmers know that the seeds can be put less deep to very fertile soil and grow as well as deeper seeds on less fertile land).
Here is a sample of code of this model: bazaar. launchpad. net/~widelands- dev/widelands/ terrain_ affinity/ view/head: /src/logic/ terrain_ affinity. cc)
(according to http://
TerrainAffinity ::TerrainAffini ty(const LuaTable& table, const std::string& immovable_name) richness_ (table. get_double( "preferred_ richness" ))
: preferred_
double terrain_humidity = 0;
double terrain_fertility = 0;
(...)? How can we get the mean values of terrain affinity? I don't understand that part of code.
// it is like fertility, but the name already exists humidity, terrain_ fertility) ; humidity+ terrain_ fertility) /2;
const double terrain_richness = max(terrain_
// OR (depend on model):
const double terrain_richness = (terrain_
const double sigma=0.0288; //The value can change- it is only to make a 0.1 wide slope of gauss gauss=0. 95;
double pure_gauss=1.;
double advanced_
if(terrain_ ruchness< preffered_ richness( )){ exp(-pow2( terrain_ richness- preffered_ richness( ))/(2*pow2( sigma)) ); gauss=pure_ gauss*0. 9+0.05;
pure_gauss=
advanced_
}
return advanced_gauss;
END :) richness= =preffered_ richness( ) or more. richness( ). So if there is: richness( )-0.15, then possibility ~=0.05 richness( )-0.1, then possibility ~= 0.05 richness( )-0.05, then possibility ~= 0.5 richness( ), then possibility == 0.95 richness( )+0.05, then possibility == 0.95
As a result the possibility of growth is always more than 0.5 and less than or equals 0.95.
It is equal 0.95 for the value terrain_
The slope of gauss begins on 0.1 value before preffered_
terrain_richness == preffered_
terrain_richness == preffered_
terrain_richness == preffered_
terrain_richness == preffered_
terrain_richness == preffered_
This is only and idea. Feel free to discuss it.
Prefered richness should be about 0.5-0.8, because some lands (desert or winterwolrd) can be unplayable.