1
/* Copyright (c) 2000 Shlomi Fish
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
12
* The above copyright notice and this permission notice shall be
13
* included in all copies or substantial portions of the Software.
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.
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
6
* Written by Shlomi Fish ( http://www.shlomifish.org/ ), 2000
8
* This file is in the public domain (it's uncopyrighted).
11
31
#ifndef FC_SOLVE__FCS_MOVE_H
12
32
#define FC_SOLVE__FCS_MOVE_H
14
/* #define FCS_DEBUG_MOVES */
15
#define FCS_COMPACT_MOVES
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,
40
#ifdef FCS_DEBUG_MOVES
41
struct fcs_move_struct
43
/* The index of the foundation, in case there are more than one decks */
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 */
51
/* Ditto for the stacks */
54
/* The type of the move see the enum fcs_move_types */
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);
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)
74
#elif defined(FCS_COMPACT_MOVES)
75
struct fcs_move_struct
77
59
unsigned char c[4];
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
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));
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])
105
typedef struct fcs_move_struct fcs_move_t;
107
struct fcs_move_stack_struct
109
87
fcs_move_t * moves;
114
typedef struct fcs_move_stack_struct fcs_move_stack_t;
117
91
#ifdef __cplusplus