I searched the net for a map randomizer and didn't come across one... so I put one together. This script basically reads the contents of the maps folder to create a master file..call it what you want. This master file is then randomized and the output is written to mapcycle.txt.
#!/usr/bin/perl #i############################################# # Dave K 1/17/02 # # # # Use this script to randomize a HL map cycle # ############################################### # # This should be the path to your halflife maps directory $mapsdir = "/Path/to/HL/maps/directory/"; # # let's assign our master map list # $master = "/Path/to/place/master/file/"; # # Cycle should be the map list configured for HL, default is mapcycle.txt # $cycle = "/Path/to/mapcycle.txt"; # # we'll need to remove the previously randomized mapcycle and master file # unlink $cycle; unlink $master; # # we need a routine to randomize the values in an array # sub shuffle { my $array = lines; my $i = scalar (@$array); my $j; foreach $item (@$array) { --$i; $j = int rand ($i+1); next if $i == $j; @$array [$i,$j] = @$array[$j,$i]; } return @$array; } # # read the maps dir using the readdir function and create an array # opendir(MAPSDIR, $mapsdir) || die "Can not open file: $1\n"; @maps = readdir(MAPSDIR); closedir(MAPSDIR); foreach $bsp (@maps) { unless ( ($bsp eq ".") || ($bsp eq "..") ) { open (MASTERLIST, ">>$master"); print MASTERLIST "$bsp\n"; close (MASTERLIST); } } # # we've created our master list, next we'll prepare it for randomizing # open MASTERLIST, $master || die "Could not open file: $1\n"; while (<MASTERLIST>) { # # go ahead and push the values in our master file into an array # push (@lines, $_); } # # declare our shuffle array # @reordered = shuffle(@lines); foreach (@reordered) { # # Let's print these reordered values to our map cycle file # open (MAPCYCLE, ">>$cycle"); print MAPCYCLE $_; close (MAPCYCLE); }

In reply to Half Life map randomizer by semio

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.