Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] (PR#13772) CVS: civserver get_invention assert
Home

[Freeciv-Dev] (PR#13772) CVS: civserver get_invention assert

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: yautja@xxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#13772) CVS: civserver get_invention assert
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Sat, 27 Aug 2005 02:31:37 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13772 >

> [jdorje - Thu Aug 25 18:33:49 2005]:
> 
> Mateusz Stefek wrote:
> > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13772 >
> > 
> >>[yautja@xxxxxxxxxxxxxxx - Thu Aug 25 07:17:34 2005]:
> >>
> >> > civserver: tech.c:60: get_invention: Assertion `tech == (200-2) || 
> >>(tech >= 0 && tech < game.control.num_tech_types)' failed.
> >>Abort
> >>
> >>Happens in the savegame if you turndone / timeout. Only things that
stop 
> >>it is giving a new research goal or changing the science rate.
> > 
> > Evaluation for Great Library:
> > 
> >     case EFT_TECH_PARASITE:
> >       v += (total_bulbs_required(pplayer) * (100 - game.info.freecost)
> >           * (nplayers - amount)) / (nplayers * amount * 100);
> >       break;
> > 
> > The bug is that total_bulbs_required can't be called for A_UNSET. 
> > This evaluation is also strange it strongly depends on current research
> > progress. I propose the attached evaluation, which seems to be little
> > more reasonable.
> 
> Shouldn't we divide by bulbs_last_turn not multiply by it?
> 
> Why does the amount of research we have matter at all?  What should 
> matter is how many techs (bulbs) are available to be parasitized.  If we 
> assign a fixed gold cost for each bulb (1 bulb ~= 1 gold) then we can 
> ammortize this gain and find the exact gold benefit of making the wonder.
> 
> P.S.  All want calculations should be in units of gold.
> 
> -jason
> 
What about this patch?
It somehow aproximates the benefit gained from GL, assumming that
technology tree is rather linear.
--
mateusz
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.238
diff -u -r1.238 aicity.c
--- ai/aicity.c 22 Aug 2005 21:15:49 -0000      1.238
+++ ai/aicity.c 27 Aug 2005 09:25:12 -0000
@@ -406,9 +406,50 @@
          }
          break;
        case EFT_TECH_PARASITE:
-         v += (total_bulbs_required(pplayer) * (100 - game.info.freecost)
-             * (nplayers - amount)) / (nplayers * amount * 100);
+       {
+         int turns;
+         int bulbs;
+         int value;
+         
+         if (nplayers <= amount) {
+           break;
+         }
+          
+         turns = 9999;
+         bulbs = 0;
+         players_iterate(aplayer) {
+           int potential = aplayer->bulbs_last_turn
+                           + city_list_size(aplayer->cities) + 1;
+           if (tech_exists(pimpr->obsolete_by)) {
+             turns = MIN(turns, 
+               total_bulbs_required_for_goal(aplayer, pimpr->obsolete_by)
+               / (potential + 1));
+           }
+           if (players_on_same_team(aplayer, pplayer)) {
+             continue;
+           }
+           bulbs += potential;
+         } players_iterate_end;
+  
+         /* For some number of turns we will be receiving bulbs for free
+          * Bulbs should be amortized properly for each turn.
+          * We use formula for the sum of geometric series:
+          */
+         value = bulbs * (1.0 - pow(1.0 - (1.0 / MORT), turns)) * MORT;
+         
+         value = value  * (100 - game.info.freecost)     
+                 * (nplayers - amount) / (nplayers * amount * 100);
+         
+         /* WAG */
+         value /= 3;
+
+          CITY_LOG(LOG_DEBUG, pcity,
+                  "%s parasite effect: bulbs %d, turns %d, value %d", 
+                   get_improvement_name(id), bulbs, turns, value);
+       
+         v += value;
          break;
+       }
        case EFT_GROWTH_FOOD:
          v += c * 4 + (amount / 7) * pcity->surplus[O_FOOD];
          break;

[Prev in Thread] Current Thread [Next in Thread]