Re: [Freeciv-Dev] (PR#40612) updated patch
http://bugs.freeciv.org/Ticket/Display.html?id=40612 > Hello all, missed to small changes (city_refresh => city_refresh_vision) Matthias diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/common/game.c freeciv-2.1.99svn.patch/common/game.c --- freeciv-2.1.99svn15387/common/game.c 2008-12-25 19:45:44.0 +0100 +++ freeciv-2.1.99svn.patch/common/game.c 2008-12-30 19:04:41.0 +0100 @@ -275,6 +275,9 @@ game.info.celebratesize = GAME_DEFAULT_CELEBRATESIZE; game.info.savepalace= GAME_DEFAULT_SAVEPALACE; game.info.natural_city_names = GAME_DEFAULT_NATURALCITYNAMES; + game.info.migrationdist = GAME_DEFAULT_MIGRATION_DIST; + game.info.migrationworld = GAME_DEFAULT_MIGRATION_WORLD; + game.info.migrationplayer = GAME_DEFAULT_MIGRATION_PLAYER; game.info.angrycitizen = GAME_DEFAULT_ANGRYCITIZEN; game.info.foodbox = GAME_DEFAULT_FOODBOX; game.info.shieldbox = GAME_DEFAULT_SHIELDBOX; diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/common/game.h freeciv-2.1.99svn.patch/common/game.h --- freeciv-2.1.99svn15387/common/game.h 2008-12-25 19:45:44.0 +0100 +++ freeciv-2.1.99svn.patch/common/game.h 2008-12-30 21:38:38.0 +0100 @@ -248,6 +248,18 @@ #define GAME_DEFAULT_NATURALCITYNAMES TRUE +#define GAME_DEFAULT_MIGRATION_DIST 4 +#define GAME_MIN_MIGRATION_DIST 0 /* 0 = no migration */ +#define GAME_MAX_MIGRATION_DIST 7 + +#define GAME_DEFAULT_MIGRATION_PLAYER 70 +#define GAME_MIN_MIGRATION_PLAYER0 +#define GAME_MAX_MIGRATION_PLAYER100 + +#define GAME_DEFAULT_MIGRATION_WORLD 10 +#define GAME_MIN_MIGRATION_WORLD 0 +#define GAME_MAX_MIGRATION_WORLD 100 + #define GAME_DEFAULT_AQUEDUCTLOSS0 #define GAME_MIN_AQUEDUCTLOSS0 #define GAME_MAX_AQUEDUCTLOSS100 diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/common/packets.def freeciv-2.1.99svn.patch/common/packets.def --- freeciv-2.1.99svn15387/common/packets.def 2008-12-27 17:25:16.0 +0100 +++ freeciv-2.1.99svn.patch/common/packets.def 2008-12-30 19:01:07.0 +0100 @@ -414,6 +414,9 @@ UINT8 razechance; BOOL savepalace; BOOL natural_city_names; + UINT8 migrationdist; + UINT8 migrationplayer; + UINT8 migrationworld; BOOL turnblock; BOOL fixedlength; BOOL auto_ai_toggle; diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/server/cityturn.c freeciv-2.1.99svn.patch/server/cityturn.c --- freeciv-2.1.99svn15387/server/cityturn.c 2008-12-25 19:45:49.0 +0100 +++ freeciv-2.1.99svn.patch/server/cityturn.c 2008-12-30 22:56:57.0 +0100 @@ -1867,3 +1867,303 @@ remove_city(pcity); return TRUE; } + +/** + Helpful function to make a score of a city. + + formula: + score = (city size + feeling) * factors + + * feeling of the citizens + + 1.00 * happy citizens + + 0.00 * content citizens + - 0.25 * unhappy citizens + - 0.50 * unhappy citizens + + * factors + * the build costs of all buildings + f = (1.0 + [build shield cost]/1000) + * the trade of the city + f = (1 + [city surplus trade]/100) + * the gold within the city + f = (1 + [city surplus gold]/100) + * the luxury within the city + f = (1 + [city surplus luxury]/100) + * the science within the city + f = (1 + [city surplus science]/100) +**/ +static float city_score(struct city *pcity) +{ + float score = 0.0; + float feeling = 0.0; + float f_build_cost, f_trade, f_gold, f_luxury, f_science = 0.0; + int build_shield_cost = 0; + + /* feeling of the citizens */ + feeling = 1.00 * pcity->feel[CITIZEN_HAPPY][FEELING_FINAL] + + 0.00 * pcity->feel[CITIZEN_CONTENT][FEELING_FINAL] + - 0.25 * pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL] + - 0.50 * pcity->feel[CITIZEN_ANGRY][FEELING_FINAL]; + + /* take shild costs of all buidings into account */ + city_built_iterate(pcity, pimprove) { +build_shield_cost += impr_build_shield_cost(pimprove); + } city_built_iterate_end; + f_build_cost = (1.0 + (float)build_shield_cost/1000); + /* take trade into account */ + f_trade = (1.0 + (float)pcity->surplus[O_TRADE]/100); + /* take gold into account */ + f_gold = (1.0 + (float)pcity->surplus[O_GOLD]/100); + /* take luxury into account */ + f_luxury = (1.0 + (float)pcity->surplus[O_LUXURY]/100); + /* take science into account */ + f_science= (1.0 + (float)pcity->surplus[O_SCIENCE]/100); + + score = (pcity->size + feeling) * f_build_cost * f_trade * f_gold + * f_luxury * f_science; + + freelog(LOG_DEBUG, "[M] %s score: (%d + %6.3f) * (%5.3f * %5.3f " + "* %5.3f * %5.3f * %5.3f) = %6.3f", + city_name(pcity), pcity->size, feeling, + f_build_cost, f_trade
Re: [Freeciv-Dev] (PR#40612) updated patch
http://bugs.freeciv.org/Ticket/Display.html?id=40612 > Hello all, here is an updated version of the patch. The changes are * I added 3 configuration options game.info.migrationdist: - distance for migration (largest value) game.info.migrationplayer: - chance for migration within one nation game.info.migrationworld: - chance for migration between nations * the score for the cities is calculated as score = (city size + feeling) * factors with 'feeling' as measurement for the attitude of the citizens feelings = 1.00 * happy citizens + 0.00 * content citizens - 0.25 * unhappy citizens - 0.50 * unhappy citizens and the factors take into account the buildings as well as the surplus of the city * the build costs of all buildings f = (1.0 + [build shield cost]/1000) * the trade of the city f = (1 + [city surplus trade]/100) * the gold within the city f = (1 + [city surplus gold]/100) * the luxury within the city f = (1 + [city surplus luxury]/100) * the science within the city f = (1 + [city surplus science]/100) For the Migration between two cities their score is modified. If the migrants go from city A to city B the following values are calculated * for city A take into account the persistence factor (=2) A = score A * 2 * for city B take into account the distance between both cities B = score B * (MIGRATION_MAX_DIST - distance A-B) / MIGRATION_MAX_DIST with MIGRATION_MAX_DIST = 7 If A < B some citizens will migrate from city A to city B. If city A has a size of 1 it will be disbanded. This will _not_ happen if it is the last city of a nation. Also citizens will never migrate out of the capital. It game.info.migrationdist is equal to 0 migration will be disabled. Have a nice time Matthias diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/common/game.c freeciv-2.1.99svn.patch/common/game.c --- freeciv-2.1.99svn15387/common/game.c 2008-12-25 19:45:44.0 +0100 +++ freeciv-2.1.99svn.patch/common/game.c 2008-12-30 19:04:41.0 +0100 @@ -275,6 +275,9 @@ game.info.celebratesize = GAME_DEFAULT_CELEBRATESIZE; game.info.savepalace= GAME_DEFAULT_SAVEPALACE; game.info.natural_city_names = GAME_DEFAULT_NATURALCITYNAMES; + game.info.migrationdist = GAME_DEFAULT_MIGRATION_DIST; + game.info.migrationworld = GAME_DEFAULT_MIGRATION_WORLD; + game.info.migrationplayer = GAME_DEFAULT_MIGRATION_PLAYER; game.info.angrycitizen = GAME_DEFAULT_ANGRYCITIZEN; game.info.foodbox = GAME_DEFAULT_FOODBOX; game.info.shieldbox = GAME_DEFAULT_SHIELDBOX; diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/common/game.h freeciv-2.1.99svn.patch/common/game.h --- freeciv-2.1.99svn15387/common/game.h 2008-12-25 19:45:44.0 +0100 +++ freeciv-2.1.99svn.patch/common/game.h 2008-12-30 21:38:38.0 +0100 @@ -248,6 +248,18 @@ #define GAME_DEFAULT_NATURALCITYNAMES TRUE +#define GAME_DEFAULT_MIGRATION_DIST 4 +#define GAME_MIN_MIGRATION_DIST 0 /* 0 = no migration */ +#define GAME_MAX_MIGRATION_DIST 7 + +#define GAME_DEFAULT_MIGRATION_PLAYER 70 +#define GAME_MIN_MIGRATION_PLAYER0 +#define GAME_MAX_MIGRATION_PLAYER100 + +#define GAME_DEFAULT_MIGRATION_WORLD 10 +#define GAME_MIN_MIGRATION_WORLD 0 +#define GAME_MAX_MIGRATION_WORLD 100 + #define GAME_DEFAULT_AQUEDUCTLOSS0 #define GAME_MIN_AQUEDUCTLOSS0 #define GAME_MAX_AQUEDUCTLOSS100 diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/common/packets.def freeciv-2.1.99svn.patch/common/packets.def --- freeciv-2.1.99svn15387/common/packets.def 2008-12-27 17:25:16.0 +0100 +++ freeciv-2.1.99svn.patch/common/packets.def 2008-12-30 19:01:07.0 +0100 @@ -414,6 +414,9 @@ UINT8 razechance; BOOL savepalace; BOOL natural_city_names; + UINT8 migrationdist; + UINT8 migrationplayer; + UINT8 migrationworld; BOOL turnblock; BOOL fixedlength; BOOL auto_ai_toggle; diff -ur -X./freeciv-2.1.99svn15387/diff_ignore freeciv-2.1.99svn15387/server/cityturn.c freeciv-2.1.99svn.patch/server/cityturn.c --- freeciv-2.1.99svn15387/server/cityturn.c 2008-12-25 19:45:49.0 +0100 +++ freeciv-2.1.99svn.patch/server/cityturn.c 2008-12-30 22:16:17.0 +0100 @@ -1867,3 +1867,303 @@ remove_city(pcity); return TRUE; } + +/** + Helpful function to make a score of a city. + + formula: + score = (city size + feeling) * factors + + * feeling of the citizens + + 1.00 * happy citizens + + 0.00 * content citizens + - 0.25 * unhappy citizens + - 0.50 * unhappy citizens + + * factors + * the build costs of all buildings + f = (1.0 + [build shield cost]/1000) + * the trade of the city + f = (1 + [city surplus trade]/100) + * the gold within the city + f = (1 + [city surplus gold]/100) + * the luxury within the city +