.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 2: The Ascension Wars

Reply
 
Thread Tools Display Modes
  #1  
Old March 24th, 2004, 02:27 AM

Leif_- Leif_- is offline
Sergeant
 
Join Date: Sep 2003
Location: Norway
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
Leif_- is on a distinguished road
Default Map Randomizer

I've finally gotten around to do some more work on the MapRandomizer utility for Dominion maps. The latest Version is found at http://home.Online.no/~rmoldskr/Domi...Randomizer.zip however you will need to create a sensible configuration file, as the one that's included is only meant to show the syntax.

There's also README file or other documentation (yet), so here's a brief overview:

To use it, you will have to install the two perl modules WeightedSets.pm and RandomizedMap.pm into your perl modules library (On my system that is /usr/share/perl5 but it can vary. Check the documentation for your perl installation.)

Next, you will have to run the command "randomize_map.pl MAP_FILE CONFIGURATION_FILE" (For instance "randomize_map.pl original.map randomizer.cfg") This will create a new .map file in the current directory, which is named the same as the original map-file, but with "_randomized" just before the ".map" ending. (So "original_randomized.map" in the example.)

The configuration-file is where the meat lies; and unfortunately it can be a little tough to understand. Basically, it's centered around the idea of weighted sets - which is basically a set of numbers, where some of the numbers are more influential (or "heavier") than others. When making a random choice from a weighted set, a more influential number is more likely to be choosen than a less influential number.

A weighte set is, in it's simplest form, just a comma-separated list of numbers, enclused in curly braces: {1,2,3,4,5} - In such a set, all the numbers are equally weighted, so each number in the set {1,2,3,4,5} has a 20% chance of being selected.

You can also use ranges when writing a set, such as {1, 5-10, 20} which is equal to {1,5,6,7,8,9,10,20}

To set weights in a set, you add a
code:
<xN>

modifier behind an element, where N is the weight. For instance
code:
{1<x2>,2<x8>}

which means that "1" has the weight 2, and "2" has the weight "8" That in turn means that a choice from this set will give "1" in 20% of all the cases, and "2" in 80% of the cases. (The probability that a particular number will be choosen from a set is the weight of the number divided by the total weight of all numbers in the set.)

In addition, you can use the set union operator "U", the set intersection operator "^" and the set difference operator "\" - although this is not very useful yet. So, you can write expressions such as {1-1000} \ {200-214,318} which will be a set that contains all the numbers from 1 to 1000 except the numbers 200 through 214 and 318.

On to the configuration file.

There are a number of meaningful sets you can specify in the configuration file:

PopulationType - The population type for a province.

CommanderNumber - The number of commanders to add to a province

CommanderType - The type of unit to use as a commander

RandomEquip - The random equipment level to give to a commander

BodyguardSize - The number of units in the "bodyguard" squad for a commander

BodyguardType - The type of unit to use for the bodyguard

UnitsNumber - The number of squads of reguler troopers (not bodyguards) to create for a commander

UnitsSize - The number of units in a regular squad

UnitsType - The type of unit to use for a regular squad

Fort - Whether or not to create a fort in a province

Lab - Whether or not to create a lab in the province

Temple - Whether or not to create a temple in the province

For instance, if you want the default choice of population for a province to be Barbarians (population type 25) half the time, Hoburgs (type 38) 25% of the time and one of amazon types (types 40-43) the rest of the time, you just set the PopulationType set in the configuration file as shown:
code:
#PopulationType = {25<x200>,38<x100>,40-43<x25>}

(Note that the weight you give after a range will apply to every element in the range - so
code:
{1,2-3<x2>}

is equal to
code:
{1,2<x2>,3<x2>}

)

That's easy enough - however, you can also add several different sets for population type, each specified with zero or more constraints. For instance, say you want to use the above population-type set for most provinces, but you want provinces that have forest terrain to be populated by either lizards or woodsmen. To do that you will specify two sets:

code:
#PopulationType = {25<x200>,38<x100>,40-43<x25>}
#PopulationType_Terrain(128) = {36,37}

The constraint in the second set is that "The Terrain must have the value 128." The MapRandomizer will always use whatever set that the current province fullfulls the highest number of constraint but do not break any of the constraints. Basically, the "best and most precise" set will be used - so for provinces with forest terrain the second set will be used, while the first set will be used for all others.

In addition to "Terrain" the other constraints you can use is the other selections for a province that has already been made. The name of these constraints are the same as the base-name (before any constraints) of the sets; and the selections are made in the following order:

1. Terrain (Unchanged from the original map.)
2. Population type
3. Fort
4. Lab
5. Temple
6. Number of Commanders

Then for each commander
7.1 Commander Type
7.2 Random Equip
7.3 Bodyguard Type
7.4 Units Number

Then for each squad:
7.5.1 Units type
7.5.2 Units Size

So, basically, any choice for a value in this list can depend on the selections of any value above it in the list. The selection of wether or not there is a fort in the province can depend on the population type, but the population type can not depend on whether or not there's a fort (since we don't know that at the point we decide the population type.)

To say that a province has a 5% chance to have a watch-tower (fort-type 2), unless the population type in the province is barbarians (type 25), in which case the province will never have a fort, you will say:

code:
#Fort = {0<x95>,2<x5>}
#Fort_PopulationType(25) = {0}

You can also add more than one constraint - so if you want a special commander type in provinces with woodsmen and a lab you can specify

code:
#CommanderType_PopulationType(37)_Lab(1) = {333}

Note that for Labs a value of "0" means "province hasn't got a lab" while a value of "1" means "province has got a lab." Likewise for temples


I know the above is all rather complicated and weird - but I haven't got the time right now to write a better documentation. Look at the example configuration-file and try to run the program a few times and look at the resulting map. If you have any particular questions, just post them here and I'll answer.

One Last thing - be aware that the progam doesn't understand the way the terrain-types work in Dominions, so at the moment you can only specify an exact match. I.e. #PopulationType_Terrain(128) will only affect provinces that have pure forests as terrain - and not provinces that are mixed, such as "large forests" (terrain value 130) or "forests and river" (terrain value 136) This is a large flaw, and I will add a proper handling of this to the program - eventually.

[ March 23, 2004, 12:38: Message edited by: Leif_- ]
__________________
"Freefall, my old nemesis! All I have to do is activate my compressed gas rocket boots and I will cheat you once again! Belt control ON!…On?" [i]Othar Trygvasson[i]
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 02:47 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.