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: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: The AI Strikes Back: CMA 1.0
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Sun, 23 Sep 2001 02:00:36 -0700 (PDT)

[ 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? ]

Yes, this is due to me cutting and pasting out of the
diff. I have adjusted
to reading diff files as they are. But if you are
referring to the

>line that my emails sometimes have I cannot do
anything. Blame Yahoo! I can
send attachments instead if you prefer.

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

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

Why the hell not? It certainly should be valid C, all
I am attempting to do is below.

I am finding out how whether the no of scientists in
the city minus the
required scientists is a greater than zero number.
This is the second part of the patch
which I thought you would not need explanation for.
Referring to my previous example of 
a size 8 city

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 minus
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.

Now the sequel.

My function

Size 8 city, has to change

from current 5 workers, 2 taxman and 1 scientist
to           5 workers, 1 taxman and 2 scientist

We are currently at the same stage as in the previous
example,
having sent a packet to change a taxman to an elvis.

Now we set the workers who were not already at the
right tile co-ords with

"result->worker_positions_used[x][y] &&
pcity->city_map[x][y] != C_TILE_WORKER"

Now we have to discover whether more scientists or
more taxman are required. The
first 3 cases above got rid of extra workers, taxmen
or scientists. This has created
a pool of elvises exactly the right size. Check the
math! It will always be exactly the
right amount of elvises created.

So we have to figure out exactly how many more taxman
or entertainers are required.
We take the result->scientists, the scientists we want
in the city, subtract from
it the scientists already there to figure out how MANY
MORE scientists are needed.
The previous function only gets rid of extra
scientists, it only works in the case 
that there are more scientists than needed in the
city. This case approaches the other end, 
if there are LESS scientists in the city than needed,
it changes elvises to scientists while
no of elvises does not equal required number of
scientists.

My explanation of taxmans is exaclty the same as
scientists, just substitute taxman where
scientist is currently. I will provide another
example, to make it clearer

Size 8 city, has to change

from current 5 workers, 2 taxman and 1 scientist
to           5 workers, 1 taxman and 2 scientist

In order to make the minimum changes, has to figure
out 3 things

More or less scientists
More or less taxmans
Position of workers on tiles

You seem to be clear on the worker tile problem.
Therefore  I shall address
only 1 & 2.

We have to create entertainers before we can set
specialists. 
extra_taxman is the taxmans we can set to
entertainers. In order to discover if there
are surplus taxman we take

current_taxmen - result_taxman = extra_taxman.
Substituting
2 - 1 = 1
This formula gives us the extra taxman. Now we can set
him to be an entertainer.
This formula can also have a negative answer, but then
the result is just ignored.
The negative answer means more taxman are required.

Or in C code

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

But there is a worm in the apple. This is fine for
creating a pool of entertainers,
but how do we figure out how many taxman or scientists
to set the entertainers to.
If the answer is non-negative

result_scientists - current_scientists =
req_scientists;
2 - 1 = 1

Or in C code

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

The exact same thing is done for taxman.

> +  /*
> +   * 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"

You are absolutely correct. For missing such an
obvious errors I will sentence myself to 40 mantras.
"RMS is great and GNU/Linux is the true way".

  /*
   * Set scientists.
   */

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

What is this?

  /*
   * Set taxmans.
   */

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

What is this?





__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. 
http://im.yahoo.com


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