Andrew Wyllie >
Games-YASudoku >
Games::YASudoku::Board

Games::YASudoku::Board

This module defines the Sudoku board.

**_init**-
initialize a new board The game board is 9 rows by 9 columns, but we will store the board in a one dimensional array - For example, element 9 will map to row 2, column 1 (keep in mind that the first element of the array is 0).

**get_rows/get_row**-
Get rows will return a ref to an array of all the rows. get_row will just return one row - valid row numbers are 1 - 9.

**get_cols/get_col**-
Get cols will return a ref to an array of all the cols. get_col will just return one row - valid col numbers are 1 - 9.

**get_grps/get_grp**-
Groups are defined as a set of nine boxes group in squares, there are three rows of groups and three groups in each row. They are numbered as follows.

1 | 2 | 3 ---|---|--- 4 | 5 | 6 ---|---|--- 7 | 8 | 9

get_grps will return a ref to an array of all the groups. get_grp will just return one group which can be specified by one of the numbers above.

**get_values**-
return a list of all the squares with values set

**get_element_membership**-
This method will return the three groups that the element is a member of. One row, one column and one group.

**show_board**-
This method displays the current state of the board

**show_board_detail**-
This method displays the current state of the board including the possible values for each unsolved square.

**run_board**-
this method solve the board

**pass_one**-
the first pass looks for values and reduces valid_num arrays

**pass_two**-
this pass looks for valid_num arrays which have a unique value and therefore need to have that value assigned to them

Example: Square 1 can be (1,2,3) Square 2 can be (2,3,4,6) Square 3 can be (2,3,4,5) Square 4 can be (5,6) Since square 1 is the only one with a '1', it needs to be 1

Andrew Wyllie <wyllie@dilex.net>

Please send any bugs to the author

The Games::YASudoku moudule is free software and can be redistributed and/or modified under the same terms as Perl itself.

syntax highlighting: