Freeciv21
Develop your civilization from humble roots to a global empire
advtools.cpp
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 
14 #include <cmath>
15 
16 #include "advtools.h"
17 
25 adv_want amortize(adv_want benefit, int delay)
26 {
27  double discount = 1.0 - 1.0 / (static_cast<double>(MORT));
28 
29  /* Note there's no rounding here. We could round but it would probably
30  * be better just to return (and take) a double for the benefit. */
31  return benefit * pow(discount, delay);
32 }
adv_want amortize(adv_want benefit, int delay)
Amortize means gradually paying off a cost or debt over time.
Definition: advtools.cpp:25
#define MORT
Definition: advtools.h:16
float adv_want
Definition: fc_types.h:1144