Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: The AI Strikes Back: CMA 1.0
Home

[Freeciv-Dev] Re: The AI Strikes Back: CMA 1.0

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: The AI Strikes Back: CMA 1.0
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 23 Sep 2001 09:16:54 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sat, Sep 22, 2001 at 08:28:47PM -0700, Raahul Kumar wrote:

[ All your mails have weird wrapings. There are only minor problems
with normal text but it makes the patch hard to read. Can you fix
this? ]

> This is an improved apply_result_on_server. Please review and point
> out any mistakes.  The replacement has the same best case as your
> previous function and it's average case is better than your previous
> function.
> 
> Examle runs
> 
> Your function
> 
> Size 8 city, has to change 
> from current 5 workers, 2 taxman and 1 scientist 
> to           5 workers, 1 taxman and 2 scientists
> 
> Sets all ppl to entertainers 8 messages to server
> sets workers               5 messages to server
> sets scientists                     2 packets to server       
> sets taxman                  1 packet
> 
> My function
> 
> Checks if workers are currently in the worker_positions_used Only
> the ones who are not are turned into entertainers
> 
> Checks if pcity->ppl_scientist - result->scientists is greater than
> 0.  Only sets extra scientists to elvises. In this case
> 
> 1 - 2 = -1 so does nothing
> 
> Checks if pcity->ppl_taxman - result->taxmans =
> extra_taxmans is greater than 0.
> It is so  for (i = 0; i < extra_taxmans; i++) {
> packet.specialist_from = SP_TAXMAN;
> +    packet.specialist_to = SP_ELVIS;
> 
> 1 packet to server changing taxman to elvis
> 
> The code for setting workers remains the same as your
> code.
> 
> Checks if result->scientists - pcity->ppl_scientist =
> req_scientists is greater than 0.
> if so 
>  for (i = 0; i < req_scientists; i++) {
> +    packet.specialist_from = SP_ELVIS;
> +    packet.specialist_to = SP_SCIENTIST;
> +    last_request_id =
> send_packet_city_request(&aconnection, &packet,
> +                                            PACKET_CITY_CHANGE_SPECIALIST);
> +    if (!first_request_id) {
> +      first_request_id = last_request_id;
> +    }
> +  }
> +
> 
> Result 1 packet to server changing elvis to scientist.
> 
> End result: the new code sent only 2 packets where the
> old code sent at
> least 14.

Overall I think your idea is good and will be included.

> Are there any other functions you feel need to be
> optmised in the current CMA code?

You can make a profile game. Do you know how to do it?

> +  /*
> +   * Change surplus scientists to entertainers
> +   */

> pcity->ppl_scientist - result->scientists =
> extra_scientists;

What is this? This doesn't look like valid C.

> +  /*
> +   * Change extra taxmans to entertainers
> +   */

> pcity->ppl_taxman - result->taxmans = extra_taxmans;

What is this?

> +  /*
> +   * Set workers
> +   */
> +  city_map_iterate(x, y) {
> +    if (x == 2 && y == 2)
> +      continue;
> +

> +    if (result->worker_positions_used[x][y]) {

IMHO this should be "result->worker_positions_used[x][y] &&  
pcity->city_map[x][y] != C_TILE_WORKER"

> +  /*
> +   * Set scientists.
> +   */

> result->scientists - pcity->ppl_scientist =
> req_scientists;

What is this?

> +  /*
> +   * Set taxmans.
> +   */

> result->taxmans - pcity->ppl_taxman = req_taxmans;

What is this?

        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]