Games::Go::Cinderblock::NodeSet
my $rulemap = Games::Go::Cinderblock::Rulemap::Rect->new ( h => 19, w => 19 ); #initialize two empty nodesets my $ns1 = $rulemap->nodeset; my $ns2 = $ns1->copy; #add two opposite corners. $ns1->add([0,0], [18,18]); # add 4 nodes to $ns2, each adjacent to the 2 nodes in $ns1 $ns2->add($ns1->adjacent); # let ns2 have the original 2 corners. $ns2->add($ns1); # split ns2 into its 2 connected subsets my @foo = $ns2->disjoint_split; # compare equality my $false = $ns1 == $ns2;
A set of nodes :|
NodeSets are typically initiated with $rulemap->nodeset(@nodes). NodeSets may be empty. Nodesets are independant of State, but heavily dependant on Rulemap.
$rulemap->nodeset(@nodes)
insertion, lookup, removal of a single node is O(1). Nodesets are mutable, but union & intersect do not affect the invocant. Nodes are topology-implementation-dependent. In ::Rect instances, nodes are defined as a [$row,$col] array ref. In future instances, a node may be defined as a number, with an entry in an adjacency matrix.
[$row,$col]
Set operations unclude union, intersect, ==, count, add, remove, copy, has_node, disjoint_split
==
Returns the number of nodes in the nodeset.
add & remove each may take either a nodeset or a list of nodes
add
remove
$set->add([3,3]) my $true = $set->has_node([3,3]) $set->remove([3,3]) my $false = $set->has_node([3,3])
my $result = $set1->union($set2)
Return the set of nodes in either the invocant or operand.
my $result = $set1->intersect($set2)
Return the set of nodes in both invocant and operand.
Compare two sets. Returns true or false.
Returns a nodeset of nodes adjacent to the nodes of the invocant. The result excludes any nodes of the invocant.
Return an arrayref of disconnected regions. Use this with Games::Go::Cinderblock::State's grep functionality to uncover distinct, disconnected regions of a particular attribute (color, etc.)
To install Games::Go::Cinderblock, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Games::Go::Cinderblock
CPAN shell
perl -MCPAN -e shell install Games::Go::Cinderblock
For more information on module installation, please visit the detailed CPAN module installation guide.