Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2005:
[Freeciv-Dev] Re: Changing City Variables
Home

[Freeciv-Dev] Re: Changing City Variables

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Per Inge Mathisen <per@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Changing City Variables
From: YaChu Yang <yyan050@xxxxxxxxxxxxxxxxx>
Date: Thu, 8 Sep 2005 11:04:01 +1200

Quoting Per Inge Mathisen <per@xxxxxxxxxxx>:

> On Wed, 7 Sep 2005, YaChu Yang wrote:
>
> > I'm just wondering which methods from which files should I look at if I
> want to
> > change each city variable e.g. food stock, shield production etc. so that
> it's
> > stored on the server. And if I'm allowed to change these variables
> directly, is
> > there some method that's pre-written that allows us to check if these
> variables
> > comply to the freeciv rulesets?
>
> Unfortunately, I do not understand the question. These city variables are
> already stored on the server. The rulesets do not set bounds for these
> variables.
>
>   - Per

What I mean is that using say the following:

+  city_list_iterate(game.player_ptr->cities, pcity) {
+    freelog(LOG_NORMAL, "Original food stock is: %d", pcity->food_stock);
+    pcity->food_stock = 10;
+    freelog(LOG_NORMAL, "New food stock is: %d", pcity->food_stock);
+  } city_list_iterate_end;

The above will get food stock for a particular city and then set food stock to
10. However using the above method, it only updates the local copy of food
stock. Hence in the next turn, my food stock won't be 10 for this particular
city, it'll be the original value plus the amount it's suppose to increase by
per turn.

What I'm wondering is, whether there are particular methods that allow us to
change these city variables (food stock, shield, trade, luxuary etc.) so that I
can do something like the above, except that it will actually update the city
variable values. And I'm also wondering how do I check whether or not say
assigning 10 to food stock is valid for this turn.

For example:

my current city food_stock=5
and the city can only increase by say 2
so in the next turn it should be, food_stock=7
But not knowing this I change the city food_stock=10
then this would be considered as "cheating" in the game.

So I'm wondering is there a method or something that allows me to check whether
increasing food_stock to 10 is valid or not for a particular city.

These questions must sound silly, I'm really sorry, I'm such a novice in C/C++.
But basically why I want to do the above things is because I want to see if I
could use genetic algorithms to optimize city growth e.g. whether it be food
production, gold etc. Sort of like the game's CMA. I've had a look at the
client CMA files, and I'm totally lost and confused about what exactly is going
on within each method in the CMA files. And I'm quite understand how exactly
the CMA works. Because with the CMA you have two slider bars one called factor
and another one per city variable. I don't quite understand how these two work,
and how changing the values affect the city growht. I've tried looking for some
documentation on the Freeciv website about the CMA, and I couldn't find
anything, or I found little descriptions about the CMA, but unfortunately the
blond me didn't understand it or it was just a very short description.

Any help would be greatly appreciated, you guys have all been really nice,
helpful and patient with me. Thank you so much for your time.



--
Cheers
YaChu

Smile-
it's the second best thing you can do with your lips.




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