| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | package | ||
| 5 | Games::Sudoku::Trainer::Priorities; | ||
| 6 | |||
| 7 | use version; our $VERSION = qv('0.02'); # PBP | ||
| 8 | |||
| 9 | # globals | ||
| 10 | my @strategies; # strategies arranged by current priorities | ||
| 11 | |||
| 12 | # build the strategy names and strategy functions arrays | ||
| 13 | |||
| 14 | my @default_strats = ( # arranged by default priorities | ||
| 15 | 'Hidden Single', | ||
| 16 | 'Naked Single', | ||
| 17 | 'Block-Line Interaction', | ||
| 18 | 'Line-Block Interaction', | ||
| 19 | 'Naked Pair', | ||
| 20 | 'Hidden Pair', | ||
| 21 | 'Bivalue Universal Grave', | ||
| 22 | # 'Remote Pair', | ||
| 23 | 'X Wing', | ||
| 24 | 'Skyscraper', | ||
| 25 | 'Turbot Fish', | ||
| 26 | 'Unique Rectangle Type 1', | ||
| 27 | 'Two-String Kite', | ||
| 28 | 'Unique Rectangle Type 2', | ||
| 29 | 'XY Wing', | ||
| 30 | 'BLI and LBI', | ||
| 31 | ); | ||
| 32 | |||
| 33 | # array of strategy function names, ordered by current priorities | ||
| 34 | my @strat_funcs; | ||
| 35 | |||
| 36 | set_strats( \@default_strats ); | ||
| 37 | |||
| 38 | # define array of current priorities | ||
| 39 | # and array of strategy function names | ||
| 40 | # | ||
| 41 | sub set_strats { | ||
| 42 | my $strats_ref = shift; | ||
| 43 | |||
| 44 | @strategies = @$strats_ref; | ||
| 45 | |||
| 46 | # replace upper by lower, special by '_'; prepend by '_' | ||
| 47 | @strat_funcs = @strategies; | ||
| 48 | @strat_funcs = map { tr/- A-Z/__a-z/; '_' . $_ } @strat_funcs; | ||
| 49 | return; | ||
| 50 | } | ||
| 51 | |||
| 52 | # return ref to array of strategy function names | ||
| 53 | # my $strats_ref = Games::Sudoku::Trainer::Priorities::strat_funcs_ref(); | ||
| 54 | # | ||
| 55 | sub strat_funcs_ref { return \@strat_funcs } | ||
| 56 | |||
| 57 | # return copy of current priority array | ||
| 58 | # | ||
| 59 | sub copy_strats { return @strategies } | ||
| 60 | |||
| 61 | # return copy of default priority array | ||
| 62 | # | ||
| 63 | sub copy_default { return @default_strats } | ||
| 64 | |||
| 65 | 1; |