Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [PATCH] try to cleanup assess_danger (PR#1321)
Home

[Freeciv-Dev] Re: [PATCH] try to cleanup assess_danger (PR#1321)

[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] try to cleanup assess_danger (PR#1321)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Mon, 11 Mar 2002 11:17:45 +0100

Dear diary, on Sun, Mar 10, 2002 at 06:11:47PM CET, I got a letter,
where Markus Linnala <maage@xxxxxxxxx> told me, that...
> 
> Change variable names to what they mean.

Hey, hey, you're touching code I cleaned up and want to submit for inclusion
when I'll have some time ;). But, well.. :) I'll anyway probably change more
things a bit more aggressively. This cleanup looks ok as is and is worth the
commit. Just prepare for more patches touching this code later ;).

Anyway, you may want to have a look at http://pasky.ji.cz/~pasky/dev/freeciv/,
there's link to my CVS repository - choose the one with old cleanups and have a
look at my version of assess_danger(), maybe it'll help you as well.

> diff -ur -X freeciv/diff_ignore freeciv/ai/advmilitary.c 
> freeciv-cleanup-assess-danger-1/ai/advmilitary.c
> --- freeciv/ai/advmilitary.c  Wed Mar  6 12:05:09 2002
> +++ freeciv-cleanup-assess-danger-1/ai/advmilitary.c  Sun Mar 10 19:08:28 2002
> @@ -228,15 +228,14 @@
..snip..
>    struct player *pplayer;
>    bool pikemen = FALSE;
> -  bool diplomat = FALSE; /* TRUE mean that this town can defend
> -                  * against diplomats or spies */
> -  int urgency = 0;
> +  bool def_against_diplomat = FALSE; /* TRUE mean that this town can defend
> +                                   * against diplomats or spies */

I happen not to like this name change. It's difficult to read and this is
already clear from the code. Also using 'diplomat' variable is common practice
in AI code.

> @@ -252,10 +251,11 @@
>  
>    pcity->ai.grave_danger = 0;
>    pcity->ai.diplomat_threat = FALSE;
> +  pcity->ai.urgency = 0; /* need to cache this for bodyguards now -- Syela */

This is nice change. If autogames are same, I like it ;).

> @@ -370,64 +370,63 @@
>    if (danger < 0 || danger > 1<<24) /* I hope never to see this! */
>      freelog(LOG_ERROR, "Dangerous danger (%d) in %s.  Beware of overflow.",
>           danger, pcity->name);
> -  if (danger2 < 0 || danger2 > 1<<24) /* I hope never to see this! */
> -    freelog(LOG_ERROR, "Dangerous danger2 (%d) in %s.  Beware of overflow.",
> -         danger2, pcity->name);
> -  if (danger3 < 0 || danger3 > 1<<24) /* I hope never to see this! */
> -    freelog(LOG_ERROR, "Dangerous danger3 (%d) in %s.  Beware of overflow.",
> -         danger3, pcity->name);
> -  if (danger4 < 0 || danger4 > 1<<24) /* I hope never to see this! */
> -    freelog(LOG_ERROR, "Dangerous danger4 (%d) in %s.  Beware of overflow.",
> -         danger4, pcity->name);
> -  if (danger5 < 0 || danger5 > 1<<24) /* I hope never to see this! */
> -    freelog(LOG_ERROR, "Dangerous danger5 (%d) in %s.  Beware of overflow.",
> -         danger5, pcity->name);
> +  if (danger_wall < 0 || danger_wall > 1<<24) /* I hope never to see this! */
> +    freelog(LOG_ERROR, "Dangerous danger_wall (%d) in %s.  Beware of 
> overflow.",
> +         danger_wall, pcity->name);
> +  if (danger_coastal < 0 || danger_coastal > 1<<24) /* I hope never to see 
> this! */
> +    freelog(LOG_ERROR, "Dangerous danger_coastal (%d) in %s.  Beware of 
> overflow.",
> +         danger_coastal, pcity->name);
> +  if (danger_sam < 0 || danger_sam > 1<<24) /* I hope never to see this! */
> +    freelog(LOG_ERROR, "Dangerous danger_sam (%d) in %s.  Beware of 
> overflow.",
> +         danger_sam, pcity->name);
> +  if (danger_sdi < 0 || danger_sdi > 1<<24) /* I hope never to see this! */
> +    freelog(LOG_ERROR, "Dangerous danger_sdi (%d) in %s.  Beware of 
> overflow.",
> +         danger_sdi, pcity->name);

We must do something with this later :^).

..snip..
>  /* My first attempt to allow ng_wa >= 200 led to stupidity in cities with
> -no defenders and danger = 0 but danger > 0.  Capping ng_wa at 100 + urgency
> -led to a failure to buy walls as required.  Allowing want > 100 with !urgency
> +no defenders and danger = 0 but danger > 0.  Capping ng_wa at 100 + 
> pcity->ai.urgency
> +led to a failure to buy walls as required.  Allowing want > 100 with 
> !pcity->ai.urgency

You probably need to reformat this so that it wraps correctly.


-- 

                                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]