NAME

AI::Evolve::Befunge::Util - common utility functions

DESCRIPTION

This is a place for miscellaneous stuff that is used elsewhere throughout the AI::Evolve::Befunge codespace.

FUNCTIONS

push_quiet

push_quiet(1);

Add a new value to the "quiet" stack.

pop_quiet

pop_quiet();

Remove the topmost entry from the "quiet" stack, if more than one item exists on the stack.

get_quiet

$quiet = get_quiet();

Returns the topmost entry on the "quiet" stack.

push_verbose

push_verbose(1);

Add a new value to the "verbose" stack.

pop_verbose

pop_verbose();

Remove the topmost entry from the "verbose" stack, if more than one item exists on the stack.

get_verbose

$quiet = get_verbose();

Returns the topmost entry on the "verbose" stack.

push_debug

push_debug(1);

Add a new value to the "debug" stack.

pop_debug

pop_debug();

Remove the topmost entry from the "debug" stack, if more than one item exists on the stack.

get_debug

$quiet = get_debug();

Returns the topmost entry on the "debug" stack.

verbose

verbose("Hi!  I'm in verbose mode!\n");

Output a message if get_verbose() is true.

debug

verbose("Hi!  I'm in debug mode!\n");

Output a message if get_debug() is true.

quiet

quiet("Hi!  I'm in quiet mode!\n");

Output a message if get_quiet() is true. Note that this probably isn't very useful.

nonquiet

verbose("Hi!  I'm not in quiet mode!\n");

Output a message if get_quiet() is false.

v

my $vector = v(1,2);

Shorthand for creating a Language::Befunge::Vector object.

code_print

code_print($code, $x_size, $y_size);

Pretty-print a chunk of code to stdout.

setup_configs

setup_configs();

Load the config files from disk, set up the various data structures to allow fetching global and overrideable configs. This is called internally by "global_config" and "custom_config", so you never have to call it directly.

global_config

my $value = global_config('name');
my $value = global_config('name', 'default');
my @list  = global_config('name', 'default');
my @list  = global_config('name', ['default1', 'default2']);

Fetch some config from the config file. This queries the global config database - it will not take local overrides (for host, generation, or physics plugin) into account. For more specific (and flexible) config, see "custom_config", below.

custom_config

my $config = custom_config(host => $host, physics => $physics, gen => $gen);
my $value = $config('name');
my $value = $config('name', 'default');
my @list  = $config('name', 'default');
my @list  = $config('name', ['default1', 'default2']);

Generate a config object from the config file. This queries the global config database, but allows for overrides by various criteria - it allows you to specify overridden values for particular generations (if the current generation is greater than or equal to the ones in the config file, with inheritance), for particular physics engines, and for particular hostnames.

This is more specific than "global_config" can be. This is the interface you should be using in almost all cases.

If you don't specify a particular attribute, overrides by that attribute will not show up in the resulting config. This is so you can (for instance) specify a host-specific override for the physics engine, and query that successfully before knowing which physics engine you will be using.

Note that you can recurse these, but if you have two paths to the same value, you should not rely on which one takes precedence. In other words, if you have a "byhost" clause within a "bygen" section, and you also have a "bygen" clause within a "byhost" section, either one may eventually be used. When in doubt, simplify your config file.