AI-Evolve-Befunge

 view release on metacpan or  search on metacpan

example.conf  view on Meta::CPAN

# NORMAL OPERATING PARAMETERS

# Select the physics engine for this instance.  This is "othello", "ttt",
# or any other module under the AI::Evolve::Befunge::Physics:: namespace.
physics: ttt

# The number of CPUs (or cores) this node has.  This affects the number of
# worker child processes.
cpus: 1

# The number of critters alive in each generation.
popsize: 40


# NETWORKING

# Hostname or IP address to connect to.  See tools/migrationd for more info.
migrationd_host: quack.glines.org

# TCP port to connect to.
migrationd_port: 29522

lib/AI/Evolve/Befunge/Migrator.pm  view on Meta::CPAN



=head1 NAME

    AI::Evolve::Befunge::Migrator - connection to migration server


=head1 SYNOPSIS

    my $migrator = AI::Evolve::Befunge::Migrator->new(Local => $socket);
    $migrator->spin() while $migrator->alive();


=head1 DESCRIPTION

Maintains a connection to the migration server, migrationd.  This
module is meant to run in a child process, which will die when the
Local socket is closed.

It provides a non-blocking, fault tolerant adaptation layer between
migrationd (which may be somewhere across the internet) and the

lib/AI/Evolve/Befunge/Migrator.pm  view on Meta::CPAN

    }

    close($sock1);
    for my $fd (0..sysconf(_SC_OPEN_MAX)-1) {
        next if $fd == $sock2->fileno();
        next if $fd == STDERR->fileno();
        POSIX::close($fd);
    }
    $sock2->blocking(0);
    my $migrator = AI::Evolve::Befunge::Migrator->new(Local  => $sock2);
    $migrator->spin() while $migrator->alive();
    exit(0);
}


=head1 METHODS

=head2 spin

    $migrator->spin();

lib/AI/Evolve/Befunge/Migrator.pm  view on Meta::CPAN

            $$self{dead} = 1;
        }
        if($socket == $$self{sock}) {
            debug("Migrator: closing socket due to select exception\n");
            undef $$self{sock};
        }
    }
}


=head2 alive

    exit unless $migrator->alive();

Returns true while migrator still wants to live.
=cut

sub alive {
    my $self = shift;
    return !$$self{dead};
}

=head2 try_connect

    $migrator->try_connect();

Try to establish a new connection to migrationd.



( run in 1.334 second using v1.01-cache-2.11-cpan-39bf76dae61 )