Results 1 to 10 of 36

Thread: Introduction / my efforts

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Post

    Quote Originally Posted by Redrobes View Post
    I am gonna go and see if I can Perl up your python Elite code.
    Code:
    my $ELITE = 1; # Set to 1 for Elite names, other for random names
    
    my @seed = ($ELITE == 1) ? (0x5A4A, 0x0248, 0xB753)
                             : (int(rand(0xffff)), int(rand(0xffff)), int(rand(0xffff)));
    
    sub tweakseed() {
        push @seed, ($seed[0] + $seed[1] + $seed[2]) % 0x10000;
        shift @seed;
    }
    
    my $digraphs = "..lexegezacebisousesarmaindirea.eratenberalavetiedorquanteisrion";
    
    sub name() {
        my $longnameflag = $seed[0] & 0x40;
    
        my $name = "";
    
        foreach my $n (0 .. 3) {
            my $d = (($seed[2] >> 8) & 0x1f) << 1;
    
            tweakseed();
    
            if ($n < 3 || $longnameflag) {
                $name .= substr($digraphs, $d, 2);
            }
        }
    
        $name =~ s/\.//g;
    
        $name =~ s/^(.)/\U$1/;
    
        return $name;
    }
    Last edited by isomage; 12-06-2008 at 12:19 AM. Reason: Code tweak
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

  2. #2
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    Blog Entries
    8

    Post

    Hah ! Just done mine too...

    Code:
    my $elite = 1;
    
    my @seed;
    my $digraphs = "..lexegezacebisousesarmaindirea.eratenberalavetiedorquanteisrion";
    
    if( $elite )
    {
        $seed[0] = 0x5A4A;
        $seed[1] = 0x0248;
        $seed[2] = 0xB753;
    }
    else
    {
        $seed[0] = rand() & 0xFFFF;
        $seed[1] = rand() & 0xFFFF;
        $seed[2] = rand() & 0xFFFF;
    }
    
    sub tweakseed()
    {
        my $temp = ($seed[0] + $seed[1] + $seed[2]) & 0xFFFF;
        $seed[0] = $seed[1];
        $seed[1] = $seed[2];
        $seed[2] = $temp;
    }
    
    sub name()
    {
        my $longnameflag = $seed[0] & 0x40;
        my $name = "";
    
        for( $n=0; $n<4; $n++ )
        {
            my $d = (($seed[2] >> 8) & 0x1f) << 1;
            tweakseed();
    
            if( $n < 3 || $longnameflag )
            {
                $name .= substr( $digraphs, $d, 2 );
            }
        }
    
        $name =~ s/\.//g;
        return $name;
    }
    
    print name()."\n";
    print name()."\n";
    print name()."\n";
    print name()."\n";
    Lets compare !

  3. #3
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    Blog Entries
    8

    Post

    I can tell your a better Perl programmer than I.

  4. #4

    Post

    Quote Originally Posted by Redrobes View Post
    I can tell your a better Perl programmer than I.
    The code's pretty similar -- I just took a couple of shortcuts. If it works it works!

    For testing, the first eight names generated in Elite mode should be:

    Tibedied
    Qube
    Leleer
    Biarge
    Xequerin
    Tiraor
    Rabedira
    Lave
    Last edited by isomage; 12-04-2008 at 06:16 PM.
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

  5. #5
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,256
    Blog Entries
    8

    Post

    I have plumbed it into my Nov08 challenge star map drawing script. Shame I didn't have this a month ago. Its great that you have given it out now tho.

    Should be the first 50 Elite names now with Lave over on the right.
    Attached Images Attached Images

  6. #6

    Post

    Nice
    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •