Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: Tech cost patch v8
Home

[Freeciv-Dev] Re: Tech cost patch v8

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Juha Litola <slave@xxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Tech cost patch v8
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Nov 2001 20:07:06 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Nov 30, 2001 at 08:46:54PM +0200, Juha Litola wrote:
> On Fri, Nov 30, 2001 at 07:40:29PM +0100, Raimar Falke wrote:
> > On Fri, Nov 30, 2001 at 08:18:56PM +0200, Juha Litola wrote:
> > > > Second:
> > > > +      mul = 10 * (players - playerswithtech) / players;
> > > > +      return mul * cost / 10;
> > > > should be rewritten as
> > > >        return ((players - playerswithtech)*cost)/players;
> > > Yes, of course. Why didn't I notice that. Will you make the change
> > > or shall I send the v10.
> > You.
> Here is v10:
> - removed 10* from tech cost
> - reformatted a bit
> - tech_cost may drop to 0 if we have many players and cheap tech.
>   In that case use cost 1 for tech.

This isn't valid C:
+static int num_req_techs_rec(Tech_Type_id tech, int *counted) {
+  if (tech == A_NONE)
+    return 0;
+
+  if(counted[tech])
+    return 0;
+
+   int cost =
    ^^^
+    1 +
+    num_req_techs_rec(advances[tech].req[0], counted) +
+    num_req_techs_rec(advances[tech].req[1], counted);

Replace
+      int playerswithtech = 0;
with
+      int players_with_tech = 0;

Replace
+static int goal_tech_cost_rec(struct player *pplayer, Tech_Type_id goal)
+{
+  int price = 0;
+  if (goal == A_NONE)
+    return 0;
+
+  if (pplayer->research.inventions[goal] == TECH_KNOWN)
+    return 0;
+
+  price += goal_tech_cost_rec(pplayer, advances[goal].req[0]);
+  price += goal_tech_cost_rec(pplayer, advances[goal].req[1]);
+
+  price += tech_cost(pplayer, goal);
+
+  return price;
+}

with

+static int goal_tech_cost_rec(struct player *pplayer, Tech_Type_id goal)
+{
+  if (goal == A_NONE)
+    return 0;
+
+  if (pplayer->research.inventions[goal] == TECH_KNOWN)
+    return 0;
+
+  return goal_tech_cost_rec(pplayer, advances[goal].req[0])+ 
goal_tech_cost_rec(pplayer, advances[goal].req[1])+ tech_cost(pplayer, goal);
+}

+ Uses tech_goal to do calculation except with tech_cost_style == 0.

What "tech_goal"?

Why is this special case need for tech_cost_style == 0 in goal_tech_cost?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "It is not yet possible to change operating system by writing
  to /proc/sys/kernel/ostype."              sysctl(2) man page


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