The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

NAME

Game::TextMapper::Apocalypse - generate postapocalyptic landscape

SYNOPSIS

my $map = Game::TextMapper::Apocalypse->new->generate_map();
print $map;

DESCRIPTION

This fills the map with random seed regions which then grow to fill the map.

Settlements are placed at random.

Every mountain region is the source of a river. Rivers flow through regions that are not themselves mountains or a deserts. Rivers end in swamps.

ATTRIBUTES

rows

The height of the map, defaults to 10.

my $map = Game::TextMapper::Apocalypse->new(rows => 20)
->generate_map;
print $map;

cols

The width of the map, defaults to 20.

my $map = Game::TextMapper::Apocalypse->new(cols => 30)
->generate_map;
print $map;

region_size

The size of regions sharing the same terrain type, on average, defaults to 5 hexes. The algorithm computes the number of hexes, divides it by the region size, and that's the number of seeds it starts with (rows × cols ÷ region_size).

my $map = Game::TextMapper::Apocalypse->new(region_size => 3)
->generate_map;
print $map;

settlement_chance

The chance of a hex containing a settlement, from 0 to 1, defaults to 0.1 (10%).

my $map = Game::TextMapper::Apocalypse->new(settlement_chance => 0.2)
->generate_map;
print $map;

loglevel

By default, the log level is set by Game::TextMapper from the config file. If you use the generator on its own, however, the log defaults to log level "debug". You might want to change that. The options are "error", "warn", "info" and "debug".

my $map = Game::TextMapper::Apocalypse->new(loglevel => 'error')
->generate_map;
print $map;

METHODS

generate_map

This method takes no arguments. Set the properties of the map using the attributes.