NAME
Game::TextMapper::Command::random
SYNOPSIS
text-mapper random [algorithm] [options]
text-mapper random help
DESCRIPTION
This prints a random map description to STDOUT.
text-mapper random | text-mapper render > map.svg
OPTIONS
help
prints the man page.
The algorithm can be any module that Perl can load using require
. By default, these are the ones:
Game::TextMapper::Schroeder::Alpine (needs role)
Game::TextMapper::Schroeder::Island (needs role)
The default algorithm is Game::TextMapper::Smale.
Valid options depend on the algorithm. If an algorithm needs a role, you can provide it using the --role
option.
text-mapper random Game::TextMapper::Schroeder::Alpine \
--role Game::TextMapper::Schroeder::Hex
If you don't do this, you'll get errors such as:
Can't locate object method "random_neighbor" via package ...
That's because random_neighbor
must differ depending on whether we are looking at a hex map (6) or a square map (4).
The two roles currently used:
DEVELOPING YOUR OWN
The algorithm modules must be classes one instantiates using new
and they must provide a method called generate_map
that returns a string.
Assume you write your own, and put it in the ./lib directory, called Arrakis.pm. Here is a sample implementation. It uses Mojo::Base to make it a class.
package Arrakis;
use Modern::Perl;
use Mojo::Base -base;
sub generate_map {
for my $x (0 .. 10) {
for my $y (0 .. 10) {
printf("%02d%02d dust desert\n", $x, $y);
}
}
say "include gnomeyland.txt";
}
1;
Since the lib directory is in @INC when called via text-mapper, you run it like this:
text-mapper random Arrakis | text-mapper render > map.svg
Any extra arguments are passed along to the call to generate_map
.