[freeciv-ai] Re: [Freeciv-Dev] (PR#6403) massive workers to specialists
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sun, Oct 05, 2003 at 10:49:01AM -0700, Genevieve Gracian wrote:
>
> Sometimes, when a city can't be "normally content" and have 0+ food
> surplus, all/most workers are converted to specialists.
>
> I think that the city should be thrown into disorder instead (at least
> to get the player's attention).
>
> In the savegame, connect as "a" and add the settler to aid the city in
> growing.
There are a few possible solutions.
1) call the current behavior a feature and not a bug
2) issue a warning when a city is in such a state (too much spamming)
3) emulate the old behavior (allow the city to get into disorder and
let the human player take care of this)
We decided for 3). The attached patch in an implementation. If the
server can't find a reasonable result (at least 1 food surplus, 1
shield surplus and not in disorder) on the allocation it will put in
the city into disorder and so get the attention of the human player.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"From what I am reading Win98 and NT5.0 will be getting rid of all that
crap anyway. Seems that Microsoft has invented something called TCP/IP and
another really revolutionary concept called DNS that eliminates the
netbios crap too. All that arping from browsers is going to go away.
I also hear rumors that they are on the verge of breakthrough discoveries
called NFS, and LPD too. Given enough time and money, they might
eventually invent Unix."
-- George Bonser in linux-kernel
Index: client/agents/cma_core.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_core.c,v
retrieving revision 1.49
diff -u -u -r1.49 cma_core.c
--- client/agents/cma_core.c 2003/10/01 09:23:16 1.49
+++ client/agents/cma_core.c 2003/10/20 10:11:34
@@ -726,8 +726,9 @@
dio_get_sint16(&din, ¶meter->happy_factor);
dio_get_uint8(&din, (int *) ¶meter->factor_target);
dio_get_bool8(&din, ¶meter->require_happy);
- /* This option is only for AI use */
+ /* This options is only for AI use */
parameter->allow_disorder = FALSE;
+ parameter->allow_specialists = TRUE;
return TRUE;
}
Index: client/agents/cma_fec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/cma_fec.c,v
retrieving revision 1.16
diff -u -u -r1.16 cma_fec.c
--- client/agents/cma_fec.c 2003/09/20 19:24:54 1.16
+++ client/agents/cma_fec.c 2003/10/20 10:11:35
@@ -131,6 +131,7 @@
dest->happy_factor = 1;
dest->require_happy = FALSE;
dest->allow_disorder = FALSE;
+ dest->allow_specialists = TRUE;
dest->factor_target = FT_SURPLUS;
cmafec_set_fe_parameter(pcity, dest);
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.12
diff -u -u -r1.12 cm.c
--- common/aicore/cm.c 2003/10/03 11:31:18 1.12
+++ common/aicore/cm.c 2003/10/20 10:11:37
@@ -322,6 +322,11 @@
{
int i;
+ if (!parameter->allow_specialists
+ && (result->entertainers + result->scientists + result->taxmen) > 0) {
+ return FALSE;
+ }
+
if (!parameter->allow_disorder && result->disorder) {
return FALSE;
}
@@ -1363,12 +1368,14 @@
continue;
}
- find_best_specialist_arrangement(pcity, parameter, current, &result,
- &major_fitness, &minor_fitness);
- if (!result.found_a_valid) {
- freelog(OPTIMIZE_FINAL_LOG_LEVEL2, " not enough secondary");
- not_enough_secondary++;
- continue;
+ if (parameter->allow_specialists) {
+ find_best_specialist_arrangement(pcity, parameter, current, &result,
+ &major_fitness, &minor_fitness);
+ if (!result.found_a_valid) {
+ freelog(OPTIMIZE_FINAL_LOG_LEVEL2, " not enough secondary");
+ not_enough_secondary++;
+ continue;
+ }
}
freelog(OPTIMIZE_FINAL_LOG_LEVEL2, " is ok");
@@ -1534,6 +1541,9 @@
return FALSE;
}
if (p1->allow_disorder != p2->allow_disorder) {
+ return FALSE;
+ }
+ if (p1->allow_specialists != p2->allow_specialists) {
return FALSE;
}
if (p1->factor_target != p2->factor_target) {
Index: common/aicore/cm.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.h,v
retrieving revision 1.2
diff -u -u -r1.2 cm.h
--- common/aicore/cm.h 2003/09/20 19:24:54 1.2
+++ common/aicore/cm.h 2003/10/20 10:11:37
@@ -41,6 +41,7 @@
int minimal_surplus[NUM_STATS];
bool require_happy;
bool allow_disorder;
+ bool allow_specialists;
enum factor_target factor_target;
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.230
diff -u -u -r1.230 cityturn.c
--- server/cityturn.c 2003/10/13 07:10:15 1.230
+++ server/cityturn.c 2003/10/20 10:11:40
@@ -166,6 +166,7 @@
cmp.require_happy = FALSE;
cmp.allow_disorder = FALSE;
+ cmp.allow_specialists = TRUE;
cmp.factor_target = FT_SURPLUS;
/* WAGs. These are set for both AI and humans.
@@ -194,35 +195,44 @@
cm_query_result(pcity, &cmp, &cmr);
if (!cmr.found_a_valid) {
- cmp.minimal_surplus[FOOD] = 0;
- cmp.minimal_surplus[SHIELD] = 0;
- cmp.minimal_surplus[GOLD] = -FC_INFINITY;
- cm_query_result(pcity, &cmp, &cmr);
- }
-
- if (!cmr.found_a_valid) {
if (!pplayer->ai.control) {
- /* For human players: Try very hard to avoid negative
- * production, even allow disorder. */
+ /*
+ * If we can't get a resonable result force a disorder.
+ */
cmp.allow_disorder = TRUE;
- }
- cmp.minimal_surplus[FOOD] = -(pcity->food_stock);
- cmp.minimal_surplus[TRADE] = -20;
- cm_query_result(pcity, &cmp, &cmr);
- }
+ cmp.allow_specialists = FALSE;
+ cmp.minimal_surplus[FOOD] = -20;
+ cmp.minimal_surplus[SHIELD] = -20;
+ cmp.minimal_surplus[LUXURY] = -20;
+ cmp.minimal_surplus[SCIENCE] = -20;
+
+ cm_query_result(pcity, &cmp, &cmr);
+ } else {
+ cmp.minimal_surplus[FOOD] = 0;
+ cmp.minimal_surplus[SHIELD] = 0;
+ cmp.minimal_surplus[GOLD] = -FC_INFINITY;
+ cm_query_result(pcity, &cmp, &cmr);
+
+ if (!cmr.found_a_valid) {
+ cmp.minimal_surplus[FOOD] = -(pcity->food_stock);
+ cmp.minimal_surplus[TRADE] = -20;
+ cm_query_result(pcity, &cmp, &cmr);
+ }
+
+ if (!cmr.found_a_valid) {
+ CITY_LOG(LOG_DEBUG, pcity, "emergency management");
+ cmp.minimal_surplus[FOOD] = -20;
+ cmp.minimal_surplus[SHIELD] = -20;
+ cmp.minimal_surplus[LUXURY] = -20;
+ cmp.minimal_surplus[SCIENCE] = -20;
+ cmp.allow_disorder = TRUE;
+ cmp.allow_specialists = FALSE;
- if (!cmr.found_a_valid) {
- CITY_LOG(LOG_DEBUG, pcity, "emergency management");
- cmp.minimal_surplus[FOOD] = -20;
- cmp.minimal_surplus[SHIELD] = -20;
- cmp.minimal_surplus[LUXURY] = -20;
- cmp.minimal_surplus[SCIENCE] = -20;
- cmp.allow_disorder = TRUE;
-
- cm_query_result(pcity, &cmp, &cmr);
-
- assert(cmr.found_a_valid);
+ cm_query_result(pcity, &cmp, &cmr);
+ }
+ }
}
+ assert(cmr.found_a_valid);
/* Now apply results */
city_map_checked_iterate(pcity->x, pcity->y, x, y, mapx, mapy) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freeciv-ai] Re: [Freeciv-Dev] (PR#6403) massive workers to specialists conversion,
Raimar Falke <=
|
|