Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2001:
[Freeciv-Dev] Re: Compound City Names (PATCH)
Home

[Freeciv-Dev] Re: Compound City Names (PATCH)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: gs234@xxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Compound City Names (PATCH)
From: Erik Sigra <erisi730@xxxxxxxxxxxxxx>
Date: Sun, 28 Jan 2001 14:31:17 +0100
Reply-to: sigra@xxxxxxx

23 Sep 2000 21:40:45 +0200 skrev Gaute B Strokkenes:
> I think you're on to something here.  I always thought that the way
> city names are done right now in Freeciv is rather boring.  For
> instance, there is no randomisation involved: you'll always get the
> same city names, in the same order.  Additonally, if you decide that
> you don't like one of them, it will come back to haunt you the next
> time that you build a city.
> 
> It should be pretty easy to implement this--have a look at
> city_name_suggestion() in server/cityhand.c; which is the function
> that comes up with city names for all nations and players.  Also look
> at server/rulesets.c, where the ruleset data is loaded; it's pretty
> straightforward to modify.

OK, now I have a patch for you. It implements all the namer functionality 
from Xconq. Both the very flexible grammar synthesizer and the simple random 
namer.

I have fixed the city lists of all nations to use the new functionality. For 
toose nations where I could find a good grammar in the Xconq libraries, I 
used it (for examle swedish, english, german, italian). For other nations, I 
just converted the old city list to a random namer. The local people can send 
in grammars for their respective languages when this patch is in.

The random namer is a little different than the old Freeciv way. The cities 
come in random order, and a rejected city is rejected. It won't haunt you any 
more.

Here is the documentation for Xconq namers  from 
<http://sources.redhat.com/xconq/manual/xcdesign_49.html#SEC233>:

------------------------8<--------------------------

Namers

Since one of the purposes of naming is to identify objects uniquely, any name 
generator should be able to maintain some memory as to what has been 
generated already. The objects that do this are namers.

Form: namer symbol/id method

 This form defines an instance of a namer, with either the symbolic name or 
numeric id. If either matches the name or id of an existing namer, then the 
old namer will be overwritten, otherwise a new one will be created. The 
method must be one of the naming methods listed below.

GlobalVariable: default-namer str

 This namer may be used when another namer can no longer produce names, such 
as a random namer that exhausts its list of possibilities. At present, it is 
used only with the junky and random naming methods (presumably the grammar is 
inexhaustible!).Naming Methods

As with general synthesis, Xconq has a number of naming methods available.

NamingMethod: random names ...

 This method picks a name from the given list of names and removes that name 
from the list.

NamingMethod: junky

 This method produces a gobbledy-gook name, very techy-looking.

NamingMethod: grammar root max-length rules...

 This method defines a grammar, where root is the root symbol, max-length is 
a limit on the length of the generated names (in characters), and rules is a 
list of rules of the form (symbol rule-body)

The rule-body can have the following forms: (rule-body rule-body ...)
(or [ weight ] rule-body [ weight ] rule-body ...)
(capitalize rule-body)
(reject rule-body string-or-sym ...)
symbol
string



The generation process for or works by substituting one of the
rule's alternatives for the symbol.  The probability of an alternative
being selected is arrived at by adding up the optional weights
weight (assuming missing weights to be 1), and choosing
with a probability of the weight divided by the total sum of weights.
Thus the weights need not add up to any particular value.

If the list is not prefixed by any of the special symbols, then each
rule body in the list is expanded, and the results concatenated.

Strings and symbols that are not terminals get used directly.  If a
symbol in the rule's chosen expansion does not appear as the lefthand
side in any rule, then it will be handled as a string, otherwise it will
be expanded in turn.  If the symbol matches a namer's name, then that
namer will be run and its result incorporated.

GlobalConstant: or

This designates a list of alternatives.



Symbol: capitalize

Directs capitalization of the result generated by the rule body.

Symbol: reject

A rule body headed by reject includes a list of substrings that
should not appear in a generated name; this is a convenient way to
filter out particularly unlovely results.  This works by retrying
generation if one of the listed strings appears in the name generated by
the rule body in the form.

----------------------------->8---------------------

The patch is at 
<ftp://ftp.freeciv.org/pub/freeciv/incoming/citynames.diff.bz2>. You have to 
run automake, configure and make. There are no crashes that I know about. You 
will find a lot of things to fix, so feel free to improve the patch. Look for 
example at the freelog calls if I picked the right log levels, and things 
like that. Someone probably knows how to compose the copyright notices. I 
have barely touched them. Most of the comments in the code are Stan's.

THE NAMING STANDARD FOR NAMER FILES:

files called "ng-<language>.g" are grammar namers that produce place names in 
that language. The grammar contains syllables that produce suitable place 
names.

files called "ng-cities_<state>_<year1>_to[_<year2>].g" are random namers 
containing a list of names of cities that all belonged to the state between 
year1 and year2. If the city set of the state today equals the city set in 
the namer, the part between [] is omitted. I have guessed some of the years, 
and substituted others with "----".

Erik Sigra



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