[freeciv-ai] (PR#12243) bug: compute_tech_sell_price is overly symmetric
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12243 >
> [bhudson - Sun Feb 13 22:57:34 2005]:
>
> Mateusz made a nice patch in #12129, and I responded he shouldn't
> change the logic.
>
> Turns out he should have:
> /* Don't risk it falling into enemy hands */
> if (pplayers_allied(taker, eplayer) &&
> is_player_dangerous(giver, eplayer)) {
> return BIG_NUMBER;
> }
>
> Means that in the attached (hacked) savegame, the Germans evaluate the
> worth
> of Alphabet as 33,333. So I can get quite a lot from them -- Radio,
> for instance.
>
> The reason? They're allied with the chileans, and I'm at war with
> them.
> Therefore, I evaluate alphabet as being dangerous to give away. And
> the
> germans are willing to pay for that!
>
> I'm not sure how to design the logic to avoid this.
>
>
> Another comment is that the cost to me shouldn't be 100k for something
> as minor as Alphabet. It should be based on the value my enemy places
> on the tech, which would be about 100.
>
Ok. Here's a patch
--
mateusz
Index: ai/advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.65
diff -u -r1.65 advdiplomacy.c
--- ai/advdiplomacy.c 12 Feb 2005 09:54:02 -0000 1.65
+++ ai/advdiplomacy.c 15 Feb 2005 11:57:58 -0000
@@ -199,14 +199,18 @@
Calculate a price of a tech.
Note that both AI players always evaluate the tech worth symetrically
This eases tech exchange.
+ is_dangerous returns ig the giver is afraid of giving that tech
+ (the taker should evaluate it normally, but giver should never give that)
**********************************************************************/
static int compute_tech_sell_price(struct player* giver, struct player* taker,
- int tech_id)
+ int tech_id, bool* is_dangerous)
{
int worth;
worth = ai_goldequiv_tech(taker, tech_id);
+ *is_dangerous = FALSE;
+
/* Share and expect being shared brotherly between allies */
if (pplayers_allied(giver, taker)) {
worth /= 2;
@@ -232,7 +236,7 @@
/* Don't risk it falling into enemy hands */
if (pplayers_allied(taker, eplayer) &&
is_player_dangerous(giver, eplayer)) {
- return BIG_NUMBER;
+ *is_dangerous = TRUE;
}
if (pplayers_allied(taker, eplayer) &&
@@ -262,6 +266,7 @@
bool give = (pplayer == pclause->from);
int giver;
struct ai_dip_intel *adip = &ai->diplomacy.player_intel[aplayer->player_no];
+ bool is_dangerous;
assert(pplayer != aplayer);
@@ -273,9 +278,14 @@
case CLAUSE_ADVANCE:
if (give) {
- worth -= compute_tech_sell_price(pplayer, aplayer, pclause->value);
+ worth -= compute_tech_sell_price(pplayer, aplayer, pclause->value,
+ &is_dangerous);
+ if (is_dangerous) {
+ return -BIG_NUMBER;
+ }
} else if (get_invention(pplayer, pclause->value) != TECH_KNOWN) {
- worth += compute_tech_sell_price(aplayer, pplayer, pclause->value);
+ worth += compute_tech_sell_price(aplayer, pplayer, pclause->value,
+ &is_dangerous);
}
break;
@@ -955,6 +965,7 @@
struct player* player2)
{
int worth[game.num_tech_types];
+ bool is_dangerous;
tech_type_iterate(tech) {
if (tech == A_NONE) {
@@ -963,13 +974,23 @@
}
if (get_invention(player1, tech) == TECH_KNOWN) {
if (get_invention(player2, tech) != TECH_KNOWN) {
- worth[tech] = -compute_tech_sell_price(player1, player2, tech);
+ worth[tech] = -compute_tech_sell_price(player1, player2, tech,
+ &is_dangerous);
+ if (is_dangerous) {
+ /* don't try to exchange */
+ worth[tech] = 0;
+ }
} else {
worth[tech] = 0;
}
} else {
if (get_invention(player2, tech) == TECH_KNOWN) {
- worth[tech] = compute_tech_sell_price(player2, player1, tech);
+ worth[tech] = compute_tech_sell_price(player2, player1, tech,
+ &is_dangerous);
+ if (is_dangerous) {
+ /* don't try to exchange */
+ worth[tech] = 0;
+ }
} else {
worth[tech] = 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freeciv-ai] (PR#12243) bug: compute_tech_sell_price is overly symmetric,
Mateusz Stefek <=
|
|