Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [PATCH] get rid of floating point calculations (PR#130
Home

[Freeciv-Dev] Re: [PATCH] get rid of floating point calculations (PR#130

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Markus Linnala <maage@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] get rid of floating point calculations (PR#1309)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Mon, 11 Mar 2002 10:56:35 +0100

Dear diary, on Sun, Mar 10, 2002 at 04:45:53PM CET, I got a letter,
where Markus Linnala <maage@xxxxxxxxx> told me, that...
> 
> Try to get rid of floating point calculations.
> 
> diff -ur -X freeciv/diff_ignore freeciv/ai/advmilitary.c 
> freeciv-rid-fp/ai/advmilitary.c
> --- freeciv/ai/advmilitary.c  Wed Mar  6 12:05:09 2002
> +++ freeciv-rid-fp/ai/advmilitary.c   Sun Mar 10 17:37:51 2002
> @@ -59,7 +59,7 @@
>    unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, punit)
>      v = get_defense_power(punit) * punit->hp *
>          (is_sailing_unit(punit) ? 1 : unit_type(punit)->firepower);
> -    if (is_ground_unit(punit)) v *= 1.5;
> +    if (is_ground_unit(punit)) v += v / 2;
>      v /= 30;
>      if (!igwall && city_got_citywalls(pcity) && is_ground_unit(punit)) {
>        v *= l; v /= 10;
> @@ -82,7 +82,7 @@
>    int v;
>    v = get_defense_power(punit) * punit->hp *
>        (is_sailing_unit(punit) ? 1 : unit_type(punit)->firepower);
> -  if (is_ground_unit(punit)) v *= 1.5;
> +  if (is_ground_unit(punit)) v += v / 2;
>    v /= 30;
>    v *= v;
>    if (!igwall && city_got_citywalls(pcity) && is_ground_unit(punit)) {
> diff -ur -X freeciv/diff_ignore freeciv/ai/aiunit.c freeciv-rid-fp/ai/aiunit.c
> --- freeciv/ai/aiunit.c       Wed Mar  6 07:27:57 2002
> +++ freeciv-rid-fp/ai/aiunit.c        Sun Mar 10 17:37:51 2002
> @@ -1105,7 +1105,7 @@
>                                    SINGLE_MOVE) * unit_types[d_type].hp;
>      }
>      d_val /= (unit_type(punit)->move_rate / SINGLE_MOVE);
> -    if (unit_flag(punit, F_IGTER)) d_val /= 1.5;
> +    if (unit_flag(punit, F_IGTER)) d_val -= d_val / 3;
>      freelog(LOG_DEBUG,
>           "%s@(%d,%d) looking for bodyguard, d_val=%d, my_val=%d",
>           unit_type(punit)->name, punit->x, punit->y, d_val,
> @@ -1555,7 +1555,7 @@
>              n = ai_choose_defender_versus(acity, punit->type);
>              v = get_virtual_defense_power(punit->type, n, acity->x, 
> acity->y) *
>                  unit_types[n].hp * unit_types[n].firepower *
> -                (do_make_unit_veteran(acity, n) ? 1.5 : 1.0) / 30;
> +                (do_make_unit_veteran(acity, n) ? 3 : 2) / 2 / 30;
>              if (v * v >= d) { d = v * v; b = unit_types[n].build_cost + 40; }
>            } /* let's hope this works! */
>            if (!is_ground_unit(punit) && !is_heli_unit(punit) &&

I'm ok with this.

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
"If you have acquired knowledge, what do you lack?
    If you lack knowledge, what have you acquired?"
Lev. R. 1:6
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


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