Freecell-App

 view release on metacpan or  search on metacpan

bin/freecell-solver  view on Meta::CPAN

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
The algorithm is simple.
 
=over 4
 
=item * Start with 64.
 
=item * Subtract the rank of all the top home cards.
 
=item * Subtract 1 for each empty freecell and empty column.
 
=item * Add 1 for each sequence break in the cascade
        e.g. 6C 5H 4S 2C KD QS TH has 3 sequence breaks,
        one major at 2C because the KD is greater than
        the 2C.
 
=back
 
Before the search of the next level, the nodes to be search are sorted by
their score and only the top maxnodes qualify for the next search and all
the remaining nodes are deleted from the position hash.

lib/Freecell/App/Tableau.pm  view on Meta::CPAN

454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
none.
 
=head1 SUBROUTINES/METHODS
 
=head2 new()
 
Initializes the Tableau with 8 columns and 21 rows of 0's
 
    columns 0 .. 3 row 0 are the freecells
    columns 4 .. 7 row 0 are the homecells D, C, H, S
    columns 0 .. 7 rows 1 .. 20 are the cascades
 
=head2 from_token()
 
This creates a Tableau from the Key and Token built in C<to_token()>.
 
=head2 to_token()
 
The key for position is created with C<to_token()> which also creates a
token array. The token array is needed to rebuild the Tableau from the key.
The key is the chr() of each integer in the Tableau.

lib/Freecell/App/Tableau.pm  view on Meta::CPAN

529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
The algorithm is simple.
 
=over 4
 
=item * Start with 64.
 
=item * Subtract the rank of all the top home cards.
 
=item * Subtract 1 for each empty freecell and empty column.
 
=item * Add 1 for each sequence break in the cascade
        e.g. 6C 5H 4S 2C KD QS TH has 3 sequence breaks,
        one major at 2C because the KD is greater than
        the 2C.
 
=back
 
=head2 helper subroutines
 
=over 4



( run in 0.298 second using v1.01-cache-2.11-cpan-bb97c1e446a )