![]() |
tool request (terrain math)
I COULD look at the how the terrain tools that have already been done managed the math, but I thought Id ask instead. For scenario creation could someone whip out a tool that will take a range of province numbers and mark them all nostart?
Yes I know the #nostart command but Id rather avoid making the .map file that large if I can avoid it. Yes I know the #specstart command but that wont divide the map between AI territory and human player territory. YaBasic preferred but anything that will run on linux or windows will work. For ease of scenario planning I am presently choosing maps which look good for scenarios based on a "the whole top of the map" or "the whole bottom of the map". But IF someone really wanted to.... having the utility do something like 20% of the right side, or 20% of the left side, might be nice (not necessary if its a hassle) Gandalf Parker |
Re: tool request (terrain math)
Linux *or* windows or linux *and* windows?
I've touched this up for legibility. First, copy these scripts into textfiles (hence, "scriptfile"). <font class="small">Code:</font><hr /><pre> BEGIN{low=ARGV[2]; high=ARGV[3]; mask=ARGV[4]; ARGC-=3;} {pmode = 1;} /#terrain/ && ($2 >= low && $2 <= high){print $1 " " $2 " " or($3,mask); pmode = 0;} (pmode == 1){print;} </pre><hr /> usage: awk -f <scriptfile> <mapfilename> <min> <max> <mask> ex: awk -f makemask.awk 390_mp.map 1 12 1 The output will be a version of 390_mp.map where provinces 1-12 are now large. You can use this to set any province mask you want on any range of provinces you want - I forget what the bitmask is for nostarts but you can use this to add ocean, for example. If you want to strip out a bitmask, use this: <font class="small">Code:</font><hr /><pre> BEGIN{low=ARGV[2]; high=ARGV[3]; mask=ARGV[4]; ARGC-=3;} {pmode = 1;} /#terrain/ && ($2 >= low && $2 <= high){print $1 " " $2 " " and($3,compl(mask)); pmode = 0;} (pmode == 1){print;} </pre><hr /> Identical usage. |
Re: tool request (terrain math)
wow, thats cool. I didnt think to mention awk or sed.
That will work fine. Thanks. |
Re: tool request (terrain math)
Does it check to see if the bit is already set?
|
Re: tool request (terrain math)
Oh, yeah, both of those are awk scripts. You could do it with sed as well, of course, but I don't know the bitwise operators in sed.
No, it doesn't check - but it's a bitwise or, so nothing should change if the bit is set already (or isn't set already, depending.) If you add something like: <font class="small">Code:</font><hr /><pre> if (and($3,mask)==mask){print mask " already set at " $2;} </pre><hr /> It'll check bitmasks as well. |
Re: tool request (terrain math)
1 Attachment(s)
I see the problem is already fixed, but here goes anyway...
I whipped up a small Perl script for this, I thought it would make a fun exercise (I haven't done Perl for some time). It became a lot bigger than I originally thought because I added some functionality to it. I wrote it in windows, so if you want to use it in Unix open it with nano or pico or something to change the line endings. Just run the thing, it'll tell you what to do. I even tested the thing, so it shouldn't contain too many bugs. http://forum.shrapnelgames.com/images/smilies/wink.gif K. |
Re: tool request (terrain math)
I love both the Awk and the Perl versions of this. And reading them I SHOULD be able to figure out my next request but I wasnt able to. (I HATE bitmath)
The problem is that the nostarts are hidden in the terrain bits now. If I generate a map for a 10 player game, then everyone joins, then it tries to generate the game. Only after everyone has joined will it blow up because there is no way to fit that many players on the map. Can someone whip me out a simple script (yabasic, bash, awk, sed, perl) which will tell me how many nostarts I have. All it has to do is count them so I know how many players to limit the game to. Gandalf Parker |
Re: tool request (terrain math)
Change "mask" to the actual bitmask you want.
<font class="small">Code:</font><hr /><pre> awk '/#terrain/ && (and($3,mask)==mask){print; i++;} END{print i " start locations";}' map.mp </pre><hr /> I'm at my folks place so I can't check to see if it works. |
Re: tool request (terrain math)
It works great. Thanks again. http://forum.shrapnelgames.com/images/smilies/happy.gif
|
Re: tool request (terrain math)
OK I thought we had this but so far I found a perl script that doesnt seem to work for me, and an online one that I cant use in lynx.
I want to package up some of the wrapped maps from PH's map generator but I notice that it has no nostarts. Can I get something (basic, awk, sed, whatever) that will nostart any province with fewer than 4 neighbors? |
All times are GMT -4. The time now is 07:23 PM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.