summaryrefslogtreecommitdiff
path: root/lib/GridFiller/Status.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/GridFiller/Status.pm')
-rw-r--r--lib/GridFiller/Status.pm8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/GridFiller/Status.pm b/lib/GridFiller/Status.pm
index bf5e9e6..bccb20f 100644
--- a/lib/GridFiller/Status.pm
+++ b/lib/GridFiller/Status.pm
@@ -62,8 +62,8 @@ sub _build_words_to_use {
given ($mode) {
when ('random') { return [ shuffle uniq @$words ] }
when ('given') { return [ uniq @$words ] }
- when ('longest') { return [ sort {$l->($b) <=> $l->($a)} uniq @$words ] }
- when ('shortest') { return [ sort {$l->($a) <=> $l->($b)} uniq @$words ] }
+ when ('longest') { return [ sort {$l->($b,$HORIZONTAL) <=> $l->($a,$HORIZONTAL)} uniq @$words ] }
+ when ('shortest') { return [ sort {$l->($a,$HORIZONTAL) <=> $l->($b,$HORIZONTAL)} uniq @$words ] }
default { croak "Unknown mode $mode" }
}
}
@@ -87,12 +87,12 @@ sub place_word_at {
$self->log->debug("Marking <$word> occupied at ${x}:${y} ($dir)");
if ($dir == $HORIZONTAL) {
- for my $i (0..$self->length->($word)+$space-1) {
+ for my $i (0..$self->length->($word,$dir)+$space-1) {
$self->_mark_occupied($x+$i,$y);
}
}
elsif ($dir == $VERTICAL) {
- for my $i (0..$self->length->($word)+$space-1) {
+ for my $i (0..$self->length->($word,$dir)+$space-1) {
$self->_mark_occupied($x,$y+$i);
}
}