# [Map Script] LandMasses

Discussion in 'Civ4 - Map Scripts' started by Thedrin, Mar 24, 2007.

1. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
I saw that thread and it did inspired me to get to work on making changes - thanks, Seven Spirits - though I'll be doing everything through Python.

Putting together code governing start placement will also allow me to try to restrict the number of water tiles in a capital cities fat cross and to apply flood plains to rivers that are placed next to settlers. Other options that should appear include Terra maps (including multiple uninhabited land masses) and the ability to choose between inland or coastal starts.

2. ### SevenSpiritsImmortal?

Joined:
Jul 7, 2007
Messages:
512
I'm not sure if you're still working on this, but I was working on solving the same problem for the script PerfectWorld.py. So if you haven't seen it you might want to take a look at the starting plot distribution code in the file in this post:
http://forums.civfanatics.com/showpost.php?p=6182898&postcount=197

A summary of what it does:
1) Calculate value of city on every plot.
2) From best to worst possible city, eliminate all cities within 4 spaces of it.
3) This thing:
Spoiler :
Code:
```		###NOTE: Added a complicated system where we loop through cities from best to worst,
###and each city casts a vote against the worst city that is within some distance of it.
###Two votes kills a city. The voting radius grows each iteration. Loop until only the
###best remain.
###This change kind of ruined the subsystem where cities get extra points for "controlling"
###other cities, but it's totally worth it.
numPlots = len(self.plotList)
if(numPlots == 0):
return

alives = range(numPlots) #if it's equal to its index, it's alive. -1 it's dead. other number it's "on the block"
wasVote = True
countdown = range(len(self.plotList))
countdown.reverse()
deaths = 0
time = 0
distance = 3
leave = False
if (numPlayers >= numPlots) | (numPlayers == 1):
leave = True
while (leave==False):
distance += 1
time += 1
if time > numPlots + 10000:
wasVote = False
for n in range(numPlots):
if leave:
break
if alives[n] == -1:
continue
if n >= len(self.plotList) - 1:
break
y = self.plotList[n].y
x = self.plotList[n].x
for m in countdown:
if leave:
break
if alives[m] == -1:
continue
dy = abs(self.plotList[m].y - y)
dx = abs(self.plotList[m].x - x)
if dx > hm.mapWidth / 2:
dx = hm.mapWidth - dx
if (m != n) & (dx <= distance) & (dy <= distance):
wasVote = True
if alives[m] == m:
alives[m] = n
else:
deaths += 1
alives[m] = -1
if numPlayers + deaths >= numPlots:
leave = True
if numPlayers + deaths > numPlots:
raise ValueError, "Not enough plots left!   numPlots: "+str(numPlots)+"  deaths: "+str(deaths)+"  votes: "+str(votes)+"  players: "+str(numPlayers)
break

###

#Now place all starting positions
n = 0
for m in range(len(self.plotList)):
###
if n >= numPlayers:
break
if (alives[m] != -1):
###
###if self.plotList[m].vacant == False:
sPlot = gameMap.plot(self.plotList[m].x,self.plotList[m].y)
if sPlot.isWater() == True:
raise ValueError, "Start plot is water!"
playerID = self.playerList[n]
player = gc.getPlayer(playerID)
sPlot.setStartingPlot(True)
player.setStartingPlot(sPlot,True)
###
self.plotList[m].vacant = False
###
n += 1```

No worries if you don't need it of course. I'm looking forward to the updates to the script, especially new world options!

3. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
Thanks, I'll look into it. I've tried half a dozen different ways of placing multiple civs so far and none of them have been succesful, nevermind succesful and sufficiently fast.

4. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
I won't have time to get a version that is as close to complete as I would like ready before the New Year. So, in this thread (not the opening post), is an early version of LandMasses containing civ start options.

The three new (permanent) options added to the game set up menu are:
1) Starting Positions:
a) Standard placement; uses the default civ placement.
b) LandMasses placement; uses alternative placement described below and activates other starting placement options.

2), 3) Min/Max New Worlds (requires that Starting Positions be set to LandMasses placement):
Allows the minimum number and the maximum number of initially uninhabited land masses to be set. E.g. In a game with 4 land masses, the number of uninhabited land masses can be set to between 0 and 1 so that there is a 50% chance that civs will be placed on only 3 of the 4 available land masses.

LandMasses placement description:

If only one civ starts on a piece of land, that civ will be placed on the coastal tile that will have the least number of water tiles. If there are multiple choices, the civ will be placed on the tile meeting this requirement that is as close to the center of the piece of land as possible.

If multiple civs are to be placed, SevenSpirits algorithm is used. Civs will be spaced out with starting sites rated as follows: 'coastal city with 2 water tiles in the fat cross' > 'coastal city with 3 water tiles in the fat cross' > 'coastal city with 4 water tiles in the fat cross' = inland city > 'coastal city with 5 water tiles in the fat cross > etc...'. This is to ensure that it is unlikely that a civ will be placed on a peninsula. No non coastal starting site chould contain salt water tiles.

BTS Forests issue:

This has not yet been resolved. A temporary option has been included so that the function 'normaliseAddExtras', which is responsible for fat cross forest spam, is ignored. This option can be set regardless of whether or not standard placement or LandMasses placement has been selected.

Other changes:

When multiple land amsses are to be generated, there are limits on the sizes of the land mass so that it is less likely that one land mass will be reduced to insignifigance.
The fantasy terrain option has been removed.
Flood plains will now appear on the appropriate tiles next to rivers that where added to the map during civ placement.
The list of options has been expanded so that options that previously governed multiple variables (e.g. Woodlands) have been split into multiple options (Woodlands -> Forests and Jungles). This change may be reversed at a later date.

LandMasses2.90

5. ### hookmonkeyevolved monkey

Joined:
Feb 21, 2004
Messages:
201
Location:
the Netherlands
Nice man, really like the 'terra' option. Have had a very nice game with it. It would be nice tough if you had a option that the largest landmass would not become the uninhabited world. Last game it was very crowded on the 2 habitated islands but the unhabitated landmass was huge! Kinda sucked for civs not starting near it because colonies were really necesarry in that game.

Maybe you should enter this script for the modding contest. If you fix the bug where it closes down I think this would win the mapscript category.

6. ### DragonTempestChieftain

Joined:
Dec 1, 2002
Messages:
61
Location:
Lubbock, TX
Is there gonna be more with LandMasses?
I use it alot on generating worlds and find it the best one out there.

Personally I would like to see that the oceans and seas separating the continents would vary instead of looking like someone just separated them with a large knife. but I love the script and if that changes its fundamentally, then please dont change a thing

7. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
I've no plans for any new versions of the script at the moment. I've also given up on creating starting point generator, since I was having a great deal more difficulty with than I thought that I would.

If people want to, I don't object to alternative versions of the code being created.

Edit: I haven't been on here in a while. Anyone know if a script for generating less foresty starting poitions was created?

8. ### AngstRambling and inconsistent

Joined:
Mar 3, 2007
Messages:
12,980
Location:
A Silver Mt. Zion

9. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
Uh, what? I've been away from this site for a while so I don't know what 'the hack' is. I'm away from my computer today but I should be able to re-upload it during the week if necessary.

10. ### AngstRambling and inconsistent

Joined:
Mar 3, 2007
Messages:
12,980
Location:
A Silver Mt. Zion
The hack removed all of the uploaded files in CFC, including pics, anything.

except for the avvies-.

11. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
LandMasses

I think that this was the trial version that contained some options governing starting positions. I'll have a rout around my machine for the last non trial version.

12. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
LandMasses Version 3

A new BtS compatable (at least it hasn't crashed on me yet) version of LandMasses is now available.

LandMasses has been broken down into 5 lesser map scripts. Each one gives you full control over one area of the map generation previously performed by LandMasses - map size, land placement, terrain placement, features placement, and bonus placement (start placement is gone - I was never happy with it) - but the generated map will be very basic in all other respects.

By running the master Modules script you can make use of all 5 LandMasses scripts at once, or less if you prefer. Modules does not give you direct access to the options available with each of the lesser LandMasses scripts, but it is designed to run any given LandMasses script according to the parameters selected when the LandMasses script was last used.

So, for example, if you generate a 4 land mass map with Modules, using LandMasses Lands, but want to play a 3 land mass map:
1) Select LandMasses Lands script in the Custom Game Setup menu, and choose 3 land masses (and whatever other options you want).
2) Set map size to Duel (not necessary but much faster) and generate the LandMass Lands map.
3) Return to the Custom Game Setup menu and select Modules. Select LandMasses under the Lands option (and whatever other options you want).
4) Set the appropriate map size and generate the Modules map. The resulting map will be generated using the LandMass Lands script, with the no. of land masses variable set to 3.

This script is in its early days. I'm thinking about expanding the Modules options so that aspects of other maps, such as Terra, Highlands, and a few others, can be mixed and matched, and may shortly open up a new thread for that.

Any problems, questions, or issues; feel free to raise them here.

13. ### jdog5000Revolutionary

Joined:
Nov 25, 2003
Messages:
2,601
Location:
California
Awesome, and welcome back This mix-n-match module idea seems like it opens a lot of cool possibilities.

14. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
Thanks. I only came up with as a method of getting LandMasses to work - like proposing the photon and discovering quantum mechanics as a result, or something less grand.

15. ### GarretSidzakaChieftain

Joined:
Dec 17, 2002
Messages:
4,696
Location:
Arizona
checking it out

16. ### GarretSidzakaChieftain

Joined:
Dec 17, 2002
Messages:
4,696
Location:
Arizona
can you explain to me how the modules work?

17. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
Each module within the Modules script, or the specific workings of each of the LandMass scripts?

18. ### GarretSidzakaChieftain

Joined:
Dec 17, 2002
Messages:
4,696
Location:
Arizona
i just want to play your script, which python am i supposed to load. i would like to feature it on modcast, if i can figure it out.

19. ### ThedrinChieftain

Joined:
Jan 24, 2002
Messages:
2,649
Location:
London
To play the script you just need to download LandMasses Version 3 and extract the files to the Public Maps folder of Civlization IV.

The Python link exists for people who wish to customise resource placement to a greater degree than that offered by LandMasses. The LandMasses resource placement code - which now exists independently as the LandMasses Bonuses module - was deliberately designed to make resource placement very flexible. However, it wasn't feasible to provide access to all available options through Custom Game Setup menu, and probably still isn't, due to the large amount of options that would be required. As a result, a handful of specific configurations are available for each option in LandMasses Bonuses, as well as being able to set each of these options to "Custom".

As an example, the option "Resource Tiles" allows you to determine what resources can be placed on what tiles. The options available are:
"Standard": which follows normal resource placement rules,
"LandMasses": which can place resources on different types of specific tiles - e.g. ivory can appear on grassland, plains, and tundra, but still can't be placed on desert or snow. Mineral resources can be placed on any workable land tile.
"Crazy": Places resources on any workable tile, after taking account of whether a resource is aquatic or land based.
"Custom": By default this mimics "LandMasses".

To make use of the "Custom" choice available in each of LandMasses Bonuses options you need Python. If you use Python to enter the LandMasses Bonuses script there is, near the top, a well layed out list of resources and the custom attributes assigned to them, which can be edited. A map with the edited resource attributes can then be generated by launching LandMass Bonuses.

In the example above, if Resource Tiles had been customised using Python, you'd only need to select Custom for the Resource Tiles when setting up a map. You could continue to select predefined choices for the other options in LandMasses Bonuses.

As another example of what the "Custom" options can do, consider the "Strategic Quantities" option. This allows you to determine whether there are many of each strategic resource, a normal amount, only a few, or 1 per civilization. Using Python to edit LandMass Bonuses will allow you to alter this option so that you could generate a map with precisely 1 iron resource, many horse resources, few copper resources, and standard for all other strategic resources.

In my haste to update last night I most certainly deleted over some important information. Also the original link that was provided in the first post is most likely out of date. In fact, I downloaded a new version of Python last week, so the link could certainly stand to be updated. If you Google search Python it should take you to the homepage. The latest version, appropriate to your system, shouldn't be too difficult to track down.

If you haven't used the LandMasses method of placing bonuses, then I'd say not to use the custom options just yet. Get used to what each of the predefined choices for each of the options is meant to do first.

20. ### GarretSidzakaChieftain

Joined:
Dec 17, 2002
Messages:
4,696
Location:
Arizona
ahhh ok
this is nice. im definately playing it tonite.

i personally don't like that you didn't support a gui for the python changes (mainly because im code illiterate) but i know that Ken (at modcast) is a coder at firaxis and will find this feature really cool. so, unless this is a crash fest, its going on the podcast

well if you update your python version and then update the script, will you please send me a PM so i can link it later?

thanks bro, i will be playing....