NAME

Games::Domino - Interface to the Domino game.

VERSION

Version 0.02

DESCRIPTION

This is a very basic Domino game played by two players (computer vs computer) at the moment. I will extend it to make it interactive so that it can be played against human very soon. This is just an initial draft of Proof of Concept. Also to get my head around the game which I have never played in my life before.The two player in this games are named as "Human" & "Computer". Although there is no human interference at this point in time but it will be in future. There is a cheat flag which makes the tiles for "Computer" visible to the other player "Human".Avoid this flag if possible. By the default the cheat flag is turned off. There is a debug switch as well which is turned off by default.They are arranged like here before we shuffle to start the the game.

[0 | 0]
[0 | 1] [1 | 1]
[0 | 2] [1 | 2] [2 | 2]
[0 | 3] [1 | 3] [2 | 3] [3 | 3]
[0 | 4] [1 | 4] [2 | 4] [3 | 4] [4 | 4]
[0 | 5] [1 | 5] [2 | 5] [3 | 5] [4 | 5] [5 | 5]
[0 | 6] [1 | 6] [2 | 6] [3 | 6] [4 | 6] [5 | 6] [6 | 6]

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();

METHODS

draw()

Pick a tile from the current player. If no matching tile found then picks it from the stock until it found one or the stock has only 2 tiles left at that time the game is over.

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();
my $tile = $game->draw();

save()

Saves the given tile and arrange it properly on the board. Also capture the open ends for next move.

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();
my $tile = $game->draw();
$game->save($tile);

is_over()

Returns 1 or 0 depending whether the game is over or not. The game can be declared over in the following circumstances:

  • Any one of the two players have used all his tiles.

  • There are only two (2) tiles left in the bank.

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();
do
{
    my $tile = $game->draw();
    $game->save($tile) if defined $tile;
} until ($game->is_over());

get_winner()

Declares who is the winner against whom and by how much margin.

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();
do
{
    my $tile = $game->draw();
    $game->save($tile) if defined $tile;
} until ($game->is_over());

print "WINNER: " . $game->get_winner() . "\n";

get_board()

Returns all the tiles that were arranged during the game.

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();
do
{
    my $tile = $game->draw();
    $game->save($tile) if defined $tile;
} until ($game->is_over());

print "BOARD :" . $game->get_board() . "\n";

as_string()

Returns all the unused tiles remained in the bank.

use strict; use warnings;
use Games::Domino;

my $game = Games::Domino->new();
do
{
    my $tile = $game->draw();
    $game->save($tile) if defined $tile;
} until ($game->is_over());

print "STOCK : $game\n\n";

AUTHOR

Mohammad S Anwar, <mohammad.anwar at yahoo.com>

BUGS

Please report any bugs or feature requests to bug-games-domino at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Domino.I will be notified,and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Games::Domino

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright 2012 Mohammad S Anwar.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

DISCLAIMER

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.