1 /* -*- c++ -*-
2 FILE: Puzzlest.h
3 RCS REVISION: $Revision: 1.13 $
4 
5 COPYRIGHT: (c) 1999 -- 2003 Melinda Green, Don Hatch, and Jay Berkenbilt - Superliminal Software
6 
7 LICENSE: Free to use and modify for non-commercial purposes as long as the
8     following conditions are adhered to:
9     1) Obvious credit for the source of this code and the designs it embodies
10        are clearly made, and
11     2) Ports and derived versions of 4D Magic Cube programs are not distributed
12        without the express written permission of the authors.
13 
14 DESCRIPTION:
15     By Don Hatch 1994
16     Modified in 1996 and objectified 1999 by Melinda Green
17 */
18 
19 #ifndef PUZZLEST_H
20 #define PUZZLEST_H
21 
22 #include "MagicCube.h"
23 #include <stdio.h>
24 
25 class Preferences;
26 
27 class PuzzleState {
28 
29     private:
30 
31         Preferences& preferences;
32         int  length;
33         int  nstickers;
34         int  the_state[MAXSTICKERS];
35         class PolygonManager4D *m_polymgr;
36         int isSane(int state[MAXSTICKERS]);
37 
38     public:
39 
40         PuzzleState(Preferences&, class PolygonManager4D *polymgr);
41 
42         /*
43          * Set the puzzle to the pristine state
44          */
45         // length = -1 means do not change length
46         void reset(int new_length = -1);
47 
48         int isSolved();
49 
50         int idToColor(int id);
51 
52         /*
53          * applyMove below is the method by which the state
54          * is modified. Note that no matter how big you make n, the number
55          * of possible twist axes for the nxnxnxn puzzle is the same.
56          * So it makes sense to come up with a consistent notation that is
57          * the same for all of them. Note that there is a one-to-one
58          * correspondence between the twist axes and the stickers of the
59          * 3x3x3x3 cube, so no matter what n is, imagine a 3x3x3x3 "control
60          * cube" superimposed on the puzzle. The stickers of this 3x3x3x3
61          * cube are called the "grips" by which the user can manipulate the
62          * puzzle. All move notation is specified in terms of "grips" rather
63          * than stickers (for the 3x3x3x3 case, it makes no difference).
64          */
65         void applyMove(struct stickerspec *grip, int dir, int slicesmask);
66 
67         void dump(FILE *fp);
68 
69 
70         /*
71          * Return 1 on success, 0 on error.
72          * FIX THIS-- decide whether we want to also print an error message.
73          */
74         int read(FILE *fp);
75 
getLength()76         int getLength() { return length; }
77 };
78 
79 #endif
80 
81 // Local Variables:
82 // c-basic-offset: 4
83 // c-comment-only-line-offset: 0
84 // c-file-offsets: ((defun-block-intro . +) (block-open . 0) (substatement-open . 0) (statement-cont . +) (statement-case-open . +4) (arglist-intro . +) (arglist-close . +) (inline-open . 0))
85 // indent-tabs-mode: nil
86 // End:
87