Game::Battleship::Grid
version 0.0602
use Game::Battleship::Grid; my $grid = Game::Battleship::Grid->new( fleet => \@fleet, dimension => [$width, $height], );
A Game::Battleship::Grid object represents a Battleship playing surface complete with fleet position references and line intersection collision detection.
fleet => [$CRAFT_1, $CRAFT_2, ... $CRAFT_N]
Optional array reference of an unlimited number of Game::Battleship::Craft objects.
Game::Battleship::Craft
If provided, the fleet will be placed on the grid with random but non-overlapping positions.
Naturally, it is required that the combined sizes of the ships be less than the area of the grid.
dimension => [$WIDTH, $HEIGHT]
Optional array reference with the grid height and width values.
If not provided, the standard ten by ten playing surface is used.
($orientation, $x1, $y1) = _tail_coordinates($x0, $y0, $span);
Return a vector for the craft. That is, hand back the vertical or horizontal line segment orientation and the tail coordinates based on the head coordinates and the length of the segment (i.e. the craft).
$intersect = _segment_intersection( p_x0, p_y0, p_x1, p_y1, q_x0, q_y0, q_x1, q_y1 );
Return zero if there is no intersection (or touching or overlap).
Each pair of values define a coordinate and each pair of coordinates define a line segment.
Allow diagonal craft placement.
Allow placement restriction rules (e.g. not on edges, not adjacent, etc.) as an arrayref of boundary equations or regular expressions.
Allow some type of interactive craft re-positioning.
Allow > 2D playing spaces.
Game::Battleship, Game::Battleship::Craft
Segment intersection:
http://www.meca.ucl.ac.be/~wu/FSA2716/Exercise1.htm
Gene Boggs <gene@cpan.org>
This software is copyright (c) 2020 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Game::Battleship, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::Battleship
CPAN shell
perl -MCPAN -e shell install Game::Battleship
For more information on module installation, please visit the detailed CPAN module installation guide.