Hi Danny,
On Tue, 25 Dec 2012 00:23:19 -0000
"dannyjones183" <dannyjones183_at_yahoo.com> wrote:
> Hello Shlomi,
>
> I'm sorry to say that I couldn't follow your routine. What I saw was numerous
> calls to external routines/def's for data structures that were unfamiliar. In
> particular, I didn't notice anything similar to the calculations/tests that I
> perform.
>
> In my solver, I perform a move and pass the data structure to either my
> Horne() routine or my WKR() routine. They performs all automoves appropriate
> for the routine called, and then return the data structure. I then check to
> see if the deal/game is solved or if I need to perform another move.
>
> Note: my WKR() routine is written as a super-set of the Horne() routine, so I
> don't need to make a separate call for those automoves.
>
> I have a terrible memory anymore, but I seem to recall that my solver ran
> slightly faster with WKR() over Horne() because the former routine advanced
> the solution faster because I needed to perform fewer manual moves.
>
Oh sorry, I've copy+pasted the wrong function here. Most of the heavy lifting in
determining whether the foundation should be moved is done in the
CALC_FOUNDATION_TO_PUT_CARD_ON() macro which in turn calls this code:
<<<CODE>>>
#define CALC_FOUNDATION_TO_PUT_CARD_ON__STATE_PARAMS() pass_new_state.key, card
#define CALC_FOUNDATION_TO_PUT_CARD_ON()
calc_foundation_to_put_card_on(soft_thread,
CALC_FOUNDATION_TO_PUT_CARD_ON__STATE_PARAMS())
#ifdef FCS_FREECELL_ONLY
#define SEQS_ARE_BUILT_BY_RANK() FALSE
#else
#define SEQS_ARE_BUILT_BY_RANK() (sequences_are_built_by ==
FCS_SEQ_BUILT_BY_RANK) #endif
static GCC_INLINE int calc_foundation_to_put_card_on(
fc_solve_soft_thread_t * soft_thread,
fcs_state_t * my_ptr_state,
const fcs_card_t card
)
{
#ifndef FCS_FREECELL_ONLY
fc_solve_instance_t * instance = soft_thread->hard_thread->instance;
#endif
tests_define_seqs_built_by();
for (int deck = 0 ; deck < INSTANCE_DECKS_NUM ; deck++)
{
if (fcs_foundation_value(*my_ptr_state, (deck<<2)+fcs_card_suit(card))
== fcs_card_rank(card) - 1) {
int ret_val = (deck<<2)+fcs_card_suit(card);
/* Always put on the foundation if it is built-by-suit */
#ifndef FCS_FREECELL_ONLY
if (sequences_are_built_by == FCS_SEQ_BUILT_BY_SUIT)
{
return ret_val;
}
#endif
int other_suit_idx;
int min_other_color_val = FCS_MAX_RANK+1, min_same_color_val =
FCS_MAX_RANK+1; for (other_suit_idx = 0 ; other_suit_idx < (INSTANCE_DECKS_NUM
<< 2) ; other_suit_idx++) {
if (( other_suit_idx & (4-1)) != fcs_card_suit(card))
{
if (SEQS_ARE_BUILT_BY_RANK())
{
min_other_color_val = min(min_other_color_val,
fcs_foundation_value(*my_ptr_state, other_suit_idx)); }
else if (
((other_suit_idx&0x1) == (fcs_card_suit(card)&0x1))
)
{
min_same_color_val = min(min_same_color_val,
fcs_foundation_value(*my_ptr_state, other_suit_idx)); }
else
min_other_color_val = min(min_other_color_val,
fcs_foundation_value(*my_ptr_state, other_suit_idx)); {
}
}
}
if (
(min_other_color_val+1 < fcs_card_rank(card))
&&
(SEQS_ARE_BUILT_BY_RANK()
? TRUE
:
(
(min_other_color_val+1 == fcs_card_rank(card))
&&
(fcs_card_rank(card) <= min_same_color_val+(2+1))
)
)
)
{
return ret_val;
}
}
}
return -1;
}
<<< / CODE>>>
You can also view it online here:
https://bitbucket.org/shlomif/fc-solve/src/2a9c72e4ad2957a2cbdc3b827e15b7fb71c0f66a/fc-solve/source/freecell.c?at=correcting_raymonds_prune#cl-1942
(Short URL :
http://is.gd/kUR1q4 ).
Regards,
Shlomi Fish
> Regards, Danny
[SNIPPED]
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
List of Text Processing Tools - http://shlom.in/text-proc
To have bugs is human; to fix them — divine.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
Received on Tue Dec 25 2012 - 03:01:55 IST