Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
Re: [Freeciv-Dev] Freeciv suggestions
Home

Re: [Freeciv-Dev] Freeciv suggestions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Michael Robert Thomson <robertt@xxxxxxxxxxxxxxxx>, Freeciv Development <freeciv-dev@xxxxxxxxxxx>
Subject: Re: [Freeciv-Dev] Freeciv suggestions
From: Peter Schaefer <schaefer@xxxxxx>
Date: Fri, 28 May 1999 17:16:38 +0200

Michael Robert Thomson wrote:
> 
> Can anyone tell me what the algorithm for working out how much a city
> should cost is?
> 
Read this, I really don't want to translate it to words.

void city_incite_cost(struct city *pcity)
{

  struct city *capital;
  int dist;

  if (city_got_building(pcity, B_PALACE))
    pcity->incite_revolt_cost=1000000;
  else {
    pcity->incite_revolt_cost=city_owner(pcity)->economic.gold +1000;
    capital=find_palace(city_owner(pcity));
    if (capital)
      dist=min(32, map_distance(capital->x, capital->y, pcity->x, pcity->y));
    else
      dist=32;
    if (city_got_building(pcity, B_COURTHOUSE))
      dist/=2;
    if (get_government(city_owner(pcity)->player_no)==G_COMMUNISM)
      dist = min(10, dist);
    pcity->incite_revolt_cost/=(dist + 3);
    pcity->incite_revolt_cost*=pcity->size;
    if (city_unhappy(pcity))
      pcity->incite_revolt_cost/=2;
    if (unit_list_size(&map_get_tile(pcity->x,pcity->y)->units)==0)
      pcity->incite_revolt_cost/=2;
  }
}


> Also, how is it calculated how much a military unit is to buy, depending
> on how many shields are required.
> 
> Sorry if this isn't the right mailing list to ask

This seems to be used:

If it is a unit, it is the missing shields times two 
plus the square of the missing shields divided by twenty,
if it is an improvement, it is just twice the missing shields.
(Why not the same formula, btw. ?)

If the city hasn't build not a single shield of it yet,
buying costs double.

int city_buy_cost(struct city *pcity)
{
  int total,cost;
  int build=pcity->shield_stock;
  if (pcity->is_building_unit) {
    total=unit_value(pcity->currently_building);
    if (build>=total)
      return 0;
    cost=(total-build)*2+(total-build)*(total-build)/20;
    if (!build)
      cost*=2;
  } else {
    total=improvement_value(pcity->currently_building);
    if (build>=total)
      return 0;
    cost=(total-build)*2;
    if(!build)
      cost*=2;
    if(is_wonder(pcity->currently_building))
      cost*=2;
  }
  return cost;
                  

-- 
Peter Schaefer - schaefer@xxxxxx, schaefer@xxxxxx
"FermaT, by Software Migrations Ltd, is an industrial strength program
transformation system used to migrate IBM 370 Assembler modules into 
equivalent readable and maintainable COBOL programs, and to help solve 
the year 2000 challenge for IBM 370 Assembler code."

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