home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!gatech!destroyer!ncar!csn!qwerty-gw.fsl.noaa.gov!kestrel.fsl.noaa.gov!bear
- From: bear@kestrel.fsl.noaa.gov (Bear Giles)
- Subject: Re: Intersting Data Structure
- Message-ID: <1992Dec30.183452.16715@fsl.noaa.gov>
- Sender: news@fsl.noaa.gov (USENET News System)
- Organization: Forecast Systems Labs, NOAA, Boulder, CO USA
- References: <BzMpBt.2Ip@cmcl2.nyu.edu> <rmartin.725130197@thor>
- Date: Wed, 30 Dec 1992 18:34:52 GMT
- Lines: 48
-
- >reznick@acf3.nyu.edu (Daniel Reznick) writes:
- >
- >>Can anyone suggest a feasable Data Structure/Class Hierarchy to
- >>implement a Rubik's Cube?
-
- What about a list of the rotations? Each node would contain two
- pieces of information: the face (GREEN, WHITE, YELLOW, etc) and the
- rotation (1 to 3). If necessary, you could fit this information into 5 bits!
-
- Solving the cube would be easy -- follow the list backwards and
- reverse each rotation.
-
- Finding the representation of an existing cube would be more complex, but
- not as much as you might expect. You would need an auxillary representation
- of the goal states (e.g., move subcube 4 into position 17; I think that
- uniquely identifies the goals but I'm not certain) and use the techniques
- developed for exchanging subcubes to satisfy all of the goals. (I've seen
- a list of these rotations in "how-to-solve-it" books for the cube).
-
- This will create a fairly long list of rotations, but shouldn't be too hard
- to implement. Then run this list of rotations through a filter which
- optimizes moves. For instance,
-
- GREEN 2
- RED 2
- GREEN 1
-
- could be replaced with
-
- GREEN 3
- RED 2
-
- provided GREEN and RED are on opposite sides of the cube. Obviously, if this
- was
-
- GREEN 2
- RED 2
- GREEN 2
-
- you could drop _both_ GREEN rotations since that has no net effect.
-
- Of course, you can also reduce the list by optimizing your solution of the
- goal states -- you may be able to 'kill two birds with one stone' in many
- cases.
-
-
- Bear Giles
- bear@fsl.noaa.gov
-