Game::TextMapper::Command::random
text-mapper random [algorithm] [options] text-mapper random help
This prints a random map description to STDOUT.
text-mapper random | text-mapper render > map.svg
help prints the man page.
help
The algorithm can be any module that Perl can load using require. By default, these are the ones:
require
Game::TextMapper::Apocalypse
Game::TextMapper::Gridmapper
Game::TextMapper::Schroeder::Alpine (needs role)
Game::TextMapper::Schroeder::Island (needs role)
Game::TextMapper::Smale
Game::TextMapper::Traveller
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.
--role
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).
random_neighbor
The two roles currently used:
Game::TextMapper::Schroeder::Hex
Game::TextMapper::Schroeder::Square
The algorithm modules must be classes one instantiates using new and they must provide a method called generate_map that returns a string.
new
generate_map
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.
To install Game::TextMapper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::TextMapper
CPAN shell
perl -MCPAN -e shell install Game::TextMapper
For more information on module installation, please visit the detailed CPAN module installation guide.