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

This Month's Specials

Raging Tiger- Save $9.00
World Supremacy- Save $9.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening > Scenarios, Maps and Mods

Reply
 
Thread Tools Display Modes
  #1  
Old October 18th, 2006, 02:08 AM
DrPraetorious's Avatar

DrPraetorious DrPraetorious is offline
Major General
 
Join Date: Feb 2005
Location: Lake of Hali, Aldebaran, OH
Posts: 2,474
Thanks: 51
Thanked 67 Times in 27 Posts
DrPraetorious is on a distinguished road
Default Dom3 Perl Scripts

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]
__________________
If you read his speech at Rice, all his arguments for going to the moon work equally well as arguments for blowing up the moon, sending cloned dinosaurs into space, or constructing a towering *****-shaped obelisk on Mars. --Randall Munroe
Reply With Quote
  #2  
Old October 18th, 2006, 12:47 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Dom3 Perl Scripts

Since you are arraying neighbors Id like one that can find islands and ponds on a map. That would use arrays of neighbor and terrain (water with all neighbors land equals pond, land with all neighbors water equals island).
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #3  
Old October 18th, 2006, 06:06 PM
DrPraetorious's Avatar

DrPraetorious DrPraetorious is offline
Major General
 
Join Date: Feb 2005
Location: Lake of Hali, Aldebaran, OH
Posts: 2,474
Thanks: 51
Thanked 67 Times in 27 Posts
DrPraetorious is on a distinguished road
Default Re: Dom3 Perl Scripts

I believe I've added the desired functionality - let me know if that is what you meant. Is there a way in the version of BB-code these forums use to collapse something so that it doesn't eat the entire page? I suppose I should probably make the script an attachment instead of just pasteing it inline.
__________________
If you read his speech at Rice, all his arguments for going to the moon work equally well as arguments for blowing up the moon, sending cloned dinosaurs into space, or constructing a towering *****-shaped obelisk on Mars. --Randall Munroe
Reply With Quote
  #4  
Old October 18th, 2006, 06:48 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Dom3 Perl Scripts

I was hoping for a seperate program. Something I could run against a .map and it would tell me islands and lakes
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #5  
Old October 18th, 2006, 09:21 PM
DrPraetorious's Avatar

DrPraetorious DrPraetorious is offline
Major General
 
Join Date: Feb 2005
Location: Lake of Hali, Aldebaran, OH
Posts: 2,474
Thanks: 51
Thanked 67 Times in 27 Posts
DrPraetorious is on a distinguished road
Default Re: Dom3 Perl Scripts

Oh

Attached.
Attached Files
File Type: txt 459675-IslandsandLakes.txt (762 Bytes, 105 views)
__________________
If you read his speech at Rice, all his arguments for going to the moon work equally well as arguments for blowing up the moon, sending cloned dinosaurs into space, or constructing a towering *****-shaped obelisk on Mars. --Randall Munroe
Reply With Quote
  #6  
Old October 19th, 2006, 02:14 PM
Nerfix's Avatar

Nerfix Nerfix is offline
Lieutenant General
 
Join Date: Sep 2003
Location: Hyvinkää, Finland
Posts: 2,703
Thanks: 0
Thanked 1 Time in 1 Post
Nerfix is on a distinguished road
Default Re: Dom3 Perl Scripts

Perl hmmm, is it hard to learn?
__________________

"Boobs are OK. Just not for Nerfix [img]/threads/images/Graemlins/Smile.gif[/img] ."
- Kristoffer O.
Reply With Quote
  #7  
Old October 19th, 2006, 02:31 PM

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 Re: Dom3 Perl Scripts

Quote:
Nerfix said:
Perl hmmm, is it hard to learn?
Not really. Soul-endangering to learn, maybe, but not hard.
__________________
"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
  #8  
Old October 19th, 2006, 02:48 PM
Nerfix's Avatar

Nerfix Nerfix is offline
Lieutenant General
 
Join Date: Sep 2003
Location: Hyvinkää, Finland
Posts: 2,703
Thanks: 0
Thanked 1 Time in 1 Post
Nerfix is on a distinguished road
Default Re: Dom3 Perl Scripts

Perfect. Ftgahn!
__________________

"Boobs are OK. Just not for Nerfix [img]/threads/images/Graemlins/Smile.gif[/img] ."
- Kristoffer O.
Reply With Quote
  #9  
Old October 19th, 2006, 03:33 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Dom3 Perl Scripts

Perl is kindof a cross between basic and C+. With the best of both (altho "best" is an opinion)
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #10  
Old October 19th, 2006, 04:17 PM

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 Re: Dom3 Perl Scripts

Quote:
Gandalf Parker said:
Perl is kindof a cross between basic and C+. With the best of both (altho "best" is an opinion)
And the structure of neither.
__________________
"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 04:31 PM.


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