~ubuntu-branches/ubuntu/natty/freecell-solver/natty

« back to all changes in this revision

Viewing changes to fcs_move.h

  • Committer: Bazaar Package Importer
  • Author(s): RISKO Gergely
  • Date: 2009-07-15 17:42:19 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090715174219-2rlyyvse0kezacly
Tags: 2.34.0-1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2000 Shlomi Fish
 
2
 *
 
3
 * Permission is hereby granted, free of charge, to any person
 
4
 * obtaining a copy of this software and associated documentation
 
5
 * files (the "Software"), to deal in the Software without
 
6
 * restriction, including without limitation the rights to use,
 
7
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 
8
 * copies of the Software, and to permit persons to whom the
 
9
 * Software is furnished to do so, subject to the following
 
10
 * conditions:
 
11
 *
 
12
 * The above copyright notice and this permission notice shall be
 
13
 * included in all copies or substantial portions of the Software.
 
14
 *
 
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
16
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 
17
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
18
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 
19
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
20
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
22
 * OTHER DEALINGS IN THE SOFTWARE.
 
23
 */
1
24
/*
2
25
 * fcs_move.h - header file for the move structure and enums of
3
26
 * Freecell Solver. This file is common to the main code and to the
4
27
 * library headers.
5
28
 *
6
 
 * Written by Shlomi Fish ( http://www.shlomifish.org/ ), 2000
7
 
 *
8
 
 * This file is in the public domain (it's uncopyrighted).
9
29
 */
10
30
 
11
31
#ifndef FC_SOLVE__FCS_MOVE_H
12
32
#define FC_SOLVE__FCS_MOVE_H
13
33
 
14
 
/* #define FCS_DEBUG_MOVES */
15
 
#define FCS_COMPACT_MOVES
16
 
 
17
34
#ifdef __cplusplus
18
35
extern "C" {
19
36
#endif
20
37
 
21
 
enum fcs_move_types
 
38
enum
22
39
{
23
40
    FCS_MOVE_TYPE_STACK_TO_STACK,
24
41
    FCS_MOVE_TYPE_STACK_TO_FREECELL,
34
51
    FCS_MOVE_TYPE_SEQ_TO_FOUNDATION,
35
52
    FCS_MOVE_TYPE_CANONIZE,
36
53
    FCS_MOVE_TYPE_SEPARATOR,
37
 
    FCS_MOVE_TYPE_NULL,
38
 
};
39
 
 
40
 
#ifdef FCS_DEBUG_MOVES
41
 
struct fcs_move_struct
42
 
{
43
 
    /* The index of the foundation, in case there are more than one decks */
44
 
    int foundation;
45
 
    /* Used in the case of a stack to stack move */
46
 
    int num_cards_in_sequence;
47
 
    /* There are two freecells, one for the source and the other
48
 
     * for the destination */
49
 
    int src_freecell;
50
 
    int dest_freecell;
51
 
    /* Ditto for the stacks */
52
 
    int src_stack;
53
 
    int dest_stack;
54
 
    /* The type of the move see the enum fcs_move_types */
55
 
    int type;
56
 
};
57
 
 
58
 
#define fcs_move_set_src_stack(move,value)         (move).src_stack = (value);
59
 
#define fcs_move_set_src_freecell(move,value)      (move).src_freecell = (value);
60
 
#define fcs_move_set_dest_stack(move,value)        (move).dest_stack = (value);
61
 
#define fcs_move_set_dest_freecell(move,value)     (move).dest_freecell = (value);
62
 
#define fcs_move_set_foundation(move,value)        (move).foundation = (value);
63
 
#define fcs_move_set_type(move,value)              (move).type = (value);
64
 
#define fcs_move_set_num_cards_in_seq(move,value)  (move).num_cards_in_sequence = (value);
65
 
 
66
 
#define fcs_move_get_src_stack(move)               ((move).src_stack)
67
 
#define fcs_move_get_src_freecell(move)            ((move).src_freecell)
68
 
#define fcs_move_get_dest_stack(move)              ((move).dest_stack)
69
 
#define fcs_move_get_dest_freecell(move)           ((move).dest_freecell)
70
 
#define fcs_move_get_foundation(move)              ((move).foundation)
71
 
#define fcs_move_get_type(move)                    ((move).type)
72
 
#define fcs_move_get_num_cards_in_seq(move)        ((move).num_cards_in_sequence)
73
 
 
74
 
#elif defined(FCS_COMPACT_MOVES)
75
 
struct fcs_move_struct
 
54
    FCS_MOVE_TYPE_NULL
 
55
};
 
56
 
 
57
typedef struct
76
58
{
77
59
    unsigned char c[4];
78
 
};
 
60
} fcs_move_t;
79
61
 
80
62
#define FCS_MOVE_TYPE                0
81
63
#define FCS_MOVE_SRC                 1
83
65
#define FCS_MOVE_NUM_CARDS_IN_SEQ    3
84
66
#define FCS_MOVE_NUM_CARDS_FLIPPED   3
85
67
 
86
 
#define fcs_move_set_src_stack(move,value)        (move).c[FCS_MOVE_SRC] = (value);
87
 
#define fcs_move_set_src_freecell(move,value)     (move).c[FCS_MOVE_SRC] = (value);
88
 
#define fcs_move_set_dest_stack(move,value)       (move).c[FCS_MOVE_DEST] = (value);
89
 
#define fcs_move_set_dest_freecell(move,value)    (move).c[FCS_MOVE_DEST] = (value);
90
 
#define fcs_move_set_foundation(move,value)       (move).c[FCS_MOVE_DEST] = (value);
91
 
#define fcs_move_set_type(move,value)             (move).c[FCS_MOVE_TYPE] = (value);
92
 
#define fcs_move_set_num_cards_in_seq(move,value) (move).c[FCS_MOVE_NUM_CARDS_IN_SEQ] = (value);
93
 
#define fcs_move_set_num_cards_flipped(move,value) (move).c[FCS_MOVE_NUM_CARDS_FLIPPED] = (value);
 
68
#define fcs_move_set_src_stack(move,value)        (move).c[FCS_MOVE_SRC] = ((unsigned char)(value));
 
69
#define fcs_move_set_src_freecell(move,value)     (move).c[FCS_MOVE_SRC] = ((unsigned char)(value));
 
70
#define fcs_move_set_dest_stack(move,value)       (move).c[FCS_MOVE_DEST] = ((unsigned char)(value));
 
71
#define fcs_move_set_dest_freecell(move,value)    (move).c[FCS_MOVE_DEST] = ((unsigned char)(value));
 
72
#define fcs_move_set_foundation(move,value)       (move).c[FCS_MOVE_DEST] = ((unsigned char)(value));
 
73
#define fcs_move_set_type(move,value)             (move).c[FCS_MOVE_TYPE] = ((unsigned char)(value));
 
74
#define fcs_move_set_num_cards_in_seq(move,value) (move).c[FCS_MOVE_NUM_CARDS_IN_SEQ] = ((unsigned char)(value));
 
75
#define fcs_move_set_num_cards_flipped(move,value) (move).c[FCS_MOVE_NUM_CARDS_FLIPPED] = ((unsigned char)(value));
94
76
 
95
77
#define fcs_move_get_src_stack(move)              ((move).c[FCS_MOVE_SRC])
96
78
#define fcs_move_get_src_freecell(move)           ((move).c[FCS_MOVE_SRC])
99
81
#define fcs_move_get_foundation(move)             ((move).c[FCS_MOVE_DEST])
100
82
#define fcs_move_get_type(move)                   ((move).c[FCS_MOVE_TYPE])
101
83
#define fcs_move_get_num_cards_in_seq(move)       ((move).c[FCS_MOVE_NUM_CARDS_IN_SEQ])
102
 
#define fcs_move_get_num_cards_flipped(move,value) ((move).c[FCS_MOVE_NUM_CARDS_FLIPPED])
103
 
#endif
104
 
 
105
 
typedef struct fcs_move_struct fcs_move_t;
106
 
 
107
 
struct fcs_move_stack_struct
 
84
 
 
85
typedef struct
108
86
{
109
87
    fcs_move_t * moves;
110
 
    int max_num_moves;
111
88
    int num_moves;
112
 
};
113
 
 
114
 
typedef struct fcs_move_stack_struct fcs_move_stack_t;
115
 
 
 
89
} fcs_move_stack_t;
116
90
 
117
91
#ifdef __cplusplus
118
92
}