NAME

Game::Gin::Meld - the sets and runs that can be made from a hand

VERSION

Version 0.01

SYNOPSIS

use Game::Gin::Meld qw(melds_in is_meld is_set is_run);

my @candidates = melds_in(\@cards);   # every meld, sub-melds included

is_set([ $s7, $h7, $d7 ]);            # 1
is_run([ $s5, $s6, $s7 ]);            # 1
is_run([ $sq, $sk, $sa ]);            # 0, the ace is low

DESCRIPTION

A meld is three or more cards: a set of one rank in different suits, or a run of consecutive ranks in one suit.

The ace is low and only low

A-2-3 is a run and Q-K-A is not. This module gets that from Game::Gin::Card, which holds ranks as 1 to 13 with no wraparound, rather than by testing for it.

Sub-melds are enumerated on purpose

melds_in returns the four-card set and each of its triples, and a run of five and every shorter window inside it. Listing only the longest meld of each kind is the obvious implementation and gives the wrong answer, because a shorter meld can release a card that is worth more elsewhere. The candidate lists stay small enough that Game::Gin::Deadwood can search them exactly.

FUNCTIONS

Nothing is exported by default.

melds_in

my @melds = melds_in(\@cards);

Every meld that can be formed, as arrayrefs of card ids, sub-melds included. Order is not significant.

is_meld

Whether these cards form a set or a run.

is_set

Three or four cards of one rank, no suit repeated.

is_run

Three or more cards of one suit in consecutive ranks. The cards need not be given in order.

MIN_MELD

3.

SEE ALSO

Game::Gin::Deadwood, which chooses between these; Game::Gin::Card.

AUTHOR

LNATION, <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under the Artistic License 2.0.