![]() |
Re: tool request (terrain math)
I have a script that does that at home, I'll attach it when I get back from work.
Do you want to require anything of the four neighbours - like, they all have to be the same land/sea, or don't count wastelands, anything like that? |
Re: tool request (terrain math)
I would like them to be the same land/sea.
Thanks for asking. edited: come to think of it. If its not too much bother Id rather nostart anyplace that would get stuck with neighbors of all the same bonuses. water: 3 or more water neighbors. land: 4 or more land neighbors. None of them water. And not all the same terrain (in other words refuse a mountain terrain surrounded by mountains or a swamp terrain surrounded by swamps Id like the water to be 4 or more water and no land neighbors but so far Im having trouble getting PHs mapgen to make oceans |
Re: tool request (terrain math)
Kaljamaha's script will output a text file that will tell you which province has how many neighbors, which provinces are startable and which are not and the output is tab-separated, so you can copy-paste it to a spreadsheet and examine at your leisure. It basically gives you a full bore terrain analysis and neighbor analysis out of a map file.
|
Re: tool request (terrain math)
Quote:
DireAussie has a web page which does this, Jack has that aswell and with source code available, too. There's a Python script in the Urrapand map which does this, although it would have to be changed a little so that the map file name becomes a parameter instead of being hard-coded. Finally, DrP has a done a perl script for this aswell. |
Re: tool request (terrain math)
Great list. http://forum.shrapnelgames.com/images/smilies/happy.gif
I think you will see my name in the credits of most of those. But Im hoping for something that will work in linux, text mode, and can be automated as much as possible. DireAussies doesnt seem to work in lynx (text browser) Jacks online version is great and does work in lynx (I was surprised). I hadnt realized that he had added starting provinces. But it would need to be done manually I think. I might do it for the great big maps that I plan to offer very few of. Jacks code seems to be windowsy. The python code in the urrapand map does actually look to be workable. Thanks for mentioning it. DrP's code was the first one I tried and didnt seem to get a result. Im sure its a fluke with my system. I had understood that Ballbarian did one also but I havent found it yet. So far it looks like Urrapand's python code is my best bet |
Re: tool request (terrain math)
GP, this is the script I happened to have lying around - I can modify it to check that the neighbours have a diversity of bitmasks, but this might do your for your purposes.
Arguments are: * Minimum # of neighbors (same land/sea) * Minimum # of neighbors (same land/sea and NOT swamp, wasteland or deep sea) * Bitmask to apply to provinces that don't meet the criterion (presumably you want the bitmask for nostart but I forget what that is.) Made some slight modifications, had a few beers after work can easily make other changes in the morning if this doesn't suit. e.g.: $ perl GandStart.pl.txt 4 3 128 < 390mp_new.map |
Re: tool request (terrain math)
DrP, I get an error trying to grab that file.
|
Re: tool request (terrain math)
Weird.
Well, it's not long. <font class="small">Code:</font><hr /><pre> #!/usr/bin/perl #Arguments are - # minimum # of neighbors, not counting non-matching. # minimum # of neighbours, not counting non-matching, wasteland, deep sea or swamp # bitmask you want to apply. $d_neigh = $ARGV[0]; $d_neigh2 = $ARGV[1]; $apply = $ARGV[2]; $forced = 0; while (<STDIN>) { chomp $_; @line = split (/ /); $pmode = 1; if (/^#terrain/){ $terrain[$line[1]] = $line[2]; if ($line[2] % 8 >= 4){ $type[$line[1]] = -1; } else { $type[$line[1]] = 1; } $cool[$line[1]] = $type[$line[1]]; if ($line[2] % 128 >= 64 || $line[2] % 64 >= 32 || $line[2] % 4096 >= 2048){ $elig[$line[1]] = 2; } # Upshot # - implies sea. # + implies land. # 2 implies a wasteland, swamp or deep sea. $mask[$line[1]] = $line[2]; if ($line[1] > $numprov){$numprov = $line[1];} $pmode = 0; } if (/^#neighbour/){ $adj{$line[1]}{$line[2]} = 1; $adj{$line[2]}{$line[1]} = 1; } if ($pmode == 1){ print "$_\n"; } } # Okay, now we need to know which provinces are eligible start-sites. for ($i = 1; $i <= $numprov; $i++){ $total = 0; $same = 0; $bad = 0; for $j (keys %{$adj{$i}}){ if ($cool[$i] * $cool[$i] == 1) {$same++;} if ($cool[$i] * $cool[$j] * $elig[$j] == 2) {$bad++;} $total++; } # print "$i,$elig\n"; if ($same == 0 && $type[$i] == -1){print "-- $i is a single province lake!\n";} if ($same == 0 && $type[$i] == 0){print "-- $i is a single province island!\n";} if ($total == 0){print "-- $i is an isolated province!\n";} if ($same < $d_neigh){$mask[$i] = $mask[$i] | $apply;} if ($same - $bad < $d_neigh2){$mask[$i] = $mask[$i] | $apply;} print "#terrain $i $mask[$i]\n"; } </pre><hr /> |
Re: tool request (terrain math)
That works great. Thanks. http://forum.shrapnelgames.com/images/smilies/laugh.gif
|
All times are GMT -4. The time now is 04:35 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.