This thread is hoped-for as a clearing house for useful dominions 3 perl-scripts.
Short-term plans call for a script to convert .csv files (a format accessible from all major spreadsheet programs) into modscript.
Here's a short one I just wrote that automatically selects semi-reasonable start locations on dom3 random maps. Usage:
StartFinder.pl [neighbors] [distance] < foo.map
StartFinder.pl [neighbors] [distance] < foo.map >> copy of foo.map
neighbors = (exactly) how many neighbors each start site will have. ATM the only terrain it cares about is that sea hexes don't count as neighbors for starts in land hexes, but this is easy to change (if people are worried about being stuck next to heavy cavalry hexes, and so forth.)
distance = minimum distance between start sites. The type of the route (through water, etc.) is ignored.
Disclaimer: This is NOT the most efficient way to manipulate a matrix like this! If you are tempted to adapt this code to do multivariate calculus or something, seek help immediately!
[spooiler]
Code:
#!/usr/bin/perl
#Arguments are -
# minimum # of neighbors
# desired distance between start sites
$d_neigh = $ARGV[0];
$d_dist = $ARGV[1];
$max_sea = $ARGV[2];
while (<STDIN>)
{
chomp $_;
@line = split (/ /);
if (/terrain/){
if ($line[2] % 8 >= 4){
$type[$line[1]] = -1;
}
else {
$type[$line[1]] = 0;
}
$dist{$line[1]}{$line[1]} = 0;
if ($line[1] > $numprov){$numprov = $line[1];}
}
if (/neighbour/){
$adj{$line[1]}{$line[2]} = 1;
$adj{$line[2]}{$line[1]} = 1;
$dist{$line[1]}{$line[2]} = 1;
$dist{$line[2]}{$line[1]} = 1;
}
}
# Okay, now we need to know which provinces are eligible start-sites.
for ($i = 1; $i <= $numprov; $i++){
$elig = 0; $same = 0;
for $j (keys %{$adj{$i}}){
if ($type[$i] <= $type[$j]) {$elig++;}
if ($type[$i] == $type[$j]) {$same++;}
}
# print "$i,$elig\n";
if ($elig == $d_neigh){
$elig_list{$i} = 1;
}
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";}
}
# Now we need to extend the adjacency list for each province out to $d_dist.
for ($i = 1; $i <= $numprov; $i++){
for $j (keys %{$adj{$i}}){
for $k (keys %{$adj{$j}}){
if (!exists $dist{$i}{$k}){
$dist{$i}{$k} = 2;
$zone{2}{$i}{$k} = 1;
}
}}}
for ($l = 3; $l <= $d_dist; $l++)
{
for ($i = 1; $i <= $numprov; $i++){
for $j (keys %{$zone{$l-1}{$i}}){
for $k (keys %{$adj{$j}}){
if (!exists $dist{$i}{$k}){
$dist{$i}{$k} = $l;
$zone{$l}{$i}{$k} = 1;
}
}}}
}
for ($i = 1; $i <= $numprov; $i++){
if (exists $elig_list{$i}){
for $j (keys %{$dist{$i}})
{
if (exists $elig_list{$j}){
$clashes{$i}++;
$clashlist{$i}{$j} = 1;
}
}
}
}
@startpriority = sort {$clashes{$a} <=> $clashes{$b}} keys %elig_list;
for $i (@startpriority){
if (!exists $excluded{$i}){
print "#start $i\n";
if ($type[$i] == -1){print "-- sea start\n";}
for $j (keys %{$clashlist{$i}}){
$excluded{$j} = 1;
}
}
}
[/spoiler]