package BDSM::Area::Cave;

use strict;
use warnings;
use include;

use BDSM::Util;

use BDSM::Transform;

# Returns a cave of specified height and width.
sub generate {
  shift;  # We know who we are.
  my ($height, $width) = @_;
  my $map = bdsm_map($height, $width, "#");
  # A cave is a random noisemap deal with cellular automata rules applied.

  # Generate random tiles.
  foreach my $y (1 .. $height - 1) {
    foreach my $x (1 .. $width - 1) {
      $map->{Map}[$y][$x]{_} = CONFIG->CaveWallInit ? "#" : ".";
    }
  }

  cellular($map, CONFIG->CellularIters);

  return $map;
}

42;
