Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: build_cost_prime (PR#1194)
Home

[Freeciv-Dev] Re: build_cost_prime (PR#1194)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: build_cost_prime (PR#1194)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 5 Jan 2002 20:39:48 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Jan 03, 2002 at 05:45:37AM -0800, Gregory Berkolaiko wrote:
> Hi,
> 
> the variable with an expressive name "fprime" is calculated in the same
> way in 3 different places.  I propose to separate the calculation into a
> function and supply it with a comment.  The patch is attached.

Can you create a better name? Or can you explain the "prime"?

You may also remove the fprime variable in the callers.

>  /**************************************************************************
> +In the words of Syela:
> +"Using funky fprime variable instead of f in the denom, so
> +that def=1 units are penalized correctly."
> +Translation (GB):
> +build_cost_prime is used in the denominator of the want equation (see, e.g.
> +find_something_to_kill) instead of just build_cost to make AI build more 
> +balanced units.
> +**************************************************************************/
> +int build_cost_prime(Unit_Type_id i)
> +{
> +  int res;
> +
> +  res = 2 * unit_types[i].build_cost * unit_types[i].attack_strength /
> +    (unit_types[i].attack_strength + unit_types[i].defense_strength);
> +  return res;
> +}

Make it a simple return statement.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "With a PC, I always felt limited by the software available.
   On Unix, I am limited by my knowledge."
    -- Peter J. Schoenster <pschon@xxxxxxxxxxxxxxxxx>


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