1 // This file is part of Freecell Solver. It is subject to the license terms in
2 // the COPYING.txt file found in the top-level directory of this distribution
3 // and at http://fc-solve.shlomifish.org/docs/distro/COPYING.html . No part of
4 // Freecell Solver, including this file, may be copied, modified, propagated,
5 // or distributed except according to the terms contained in the COPYING file.
6 //
7 // Copyright (c) 2000 Shlomi Fish
8 
9 // fc_pro_iface_pos.h - generate solutions in standard notation, with
10 // implicit (and not included) Horne/Raymond prune moves.
11 #pragma once
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #include "freecell-solver/fcs_cl.h"
18 #include "state.h"
19 
20 typedef struct
21 {
22     fcs_move_t move;
23     bool to_empty_stack;
24 } fcs_extended_move;
25 
26 typedef struct
27 {
28     size_t next_move_idx;
29     size_t num_moves;
30     fcs_extended_move *moves;
31 } fcs_moves_processed;
32 
33 void fc_solve_moves_processed_gen(fcs_moves_processed *,
34     fcs_state_keyval_pair *, int, const fcs_moves_sequence_t *);
35 void fc_solve_moves_processed_render_move(fcs_extended_move, char *);
36 
fc_solve_moves_processed_get_moves_left(const fcs_moves_processed * const moves)37 static inline size_t fc_solve_moves_processed_get_moves_left(
38     const fcs_moves_processed *const moves)
39 {
40     return moves->num_moves - moves->next_move_idx;
41 }
42 
fc_solve_moves_processed_get_next_move(fcs_moves_processed * const moves,fcs_extended_move * const move)43 static inline bool fc_solve_moves_processed_get_next_move(
44     fcs_moves_processed *const moves, fcs_extended_move *const move)
45 {
46     if (moves->next_move_idx == moves->num_moves)
47     {
48         return true;
49     }
50     *move = moves->moves[moves->next_move_idx++];
51     return false;
52 }
53 
fc_solve_moves_processed_free(fcs_moves_processed * const moves)54 static inline void fc_solve_moves_processed_free(
55     fcs_moves_processed *const moves)
56 {
57     free(moves->moves);
58     moves->moves = NULL;
59 }
60 
61 #ifdef __cplusplus
62 }
63 #endif
64