<URL: http://bugs.freeciv.org/Ticket/Display.html?id=38406 >
As comment says: "Assigns tech wants for techs to get better units with given role, but *only for cheapest* to research "next" unit up the chain." So it gives want only for one tech, not to every tech that provide role units. This will not help us getting role units, if tech want is increased for unreachable tech. Attached patch makes sure that tech want is given to reachable tech. This problem was found when writing another fix for Mongols scenario (namely: AI should research tech that gives first settler units). - ML
diff -Nurd -X.diff_ignore freeciv/ai/aitech.c freeciv/ai/aitech.c --- freeciv/ai/aitech.c 2007-03-05 21:11:52.000000000 +0200 +++ freeciv/ai/aitech.c 2007-03-19 01:43:08.000000000 +0200 @@ -256,6 +256,7 @@ } else if (can_eventually_build_unit(pcity, iunit)) { int cost = 0; Impr_type_id iimpr = iunit->impr_requirement; + bool reachable = TRUE; if (itech != A_LAST && get_invention(pplayer, itech) != TECH_KNOWN) { /* See if we want to invent this. */ @@ -269,22 +270,30 @@ if (preq->source.type == REQ_TECH && (get_invention(pplayer, preq->source.value.tech) != TECH_KNOWN)) { - int iimprtech = preq->source.value.tech; - int imprcost = total_bulbs_required_for_goal(pplayer, iimprtech); + if (tech_is_available(pplayer, preq->source.value.tech)) { + int iimprtech = preq->source.value.tech; + int imprcost = total_bulbs_required_for_goal(pplayer, iimprtech); - if (imprcost < cost || cost == 0) { - /* If we already have the primary tech (cost==0), - * or the building's - * tech is cheaper, go for the building's required tech. */ - itech = iimprtech; /* get this first */ - cost = 0; - } - cost += imprcost; + if (imprcost < cost || cost == 0) { + /* If we already have the primary tech (cost==0), + * or the building's + * tech is cheaper, go for the building's required tech. */ + itech = iimprtech; /* get this first */ + cost = 0; + } + cost += imprcost; + } else { + /* We can't get tech for required building */ + reachable = FALSE; + break; + } } } requirement_vector_iterate_end; } - if (cost < best_cost) { + if (cost < best_cost + && tech_is_available(pplayer, itech) + && reachable) { best_tech = itech; best_cost = cost; best_unit = iunit;
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev