home *** CD-ROM | disk | FTP | other *** search
- Path: cs.ruu.nl!usenet
- From: wsldanke@cs.ruu.nl (Wessel Dankers)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: scramble game algorithm?
- Date: 27 Mar 96 20:21:39 +0100
- Organization: Dept of Computer Science, Utrecht University, The Netherlands
- Message-ID: <1710.6660T1221T1979@cs.ruu.nl>
- References: <3157B388.3F20@sapiens.com> <3159875F.7951@p3.enzian.com>
- NNTP-Posting-Host: anx1p5.cc.ruu.nl
- X-Newsreader: THOR 2.22 (Amiga TCP/IP)
-
- Jude Anthony <jude@p3.enzian.com> wrote:
- > Avi L. wrote:
- >> Hi there, i'm trying to figure out an algorithm for solving the
- >> famous scramble game, i've succeeded in solving most of the game
-
- > You need a different algorythm, I think. Forget the logic; this can be
- > easily solved with a simple tree. Since there is no position from which
- > more than four pieces can move into the empty square, you create a tree
- > with four branches at each node. A structure with four pointers will be
- > necessary; I would also include an array specifying the board position
- > after the move has been made and an integer specifying the array index of
- > the piece moved:
-
- > Write a recursive function to tranverse this tree. Every step, move each
- > possible tile into the space and create a new node for the new board
- > position. Compare the node to previous board configurations to make sure
- > you're not duplicating your work. Stop and return when there are no
- > non-repetetive board configurations, or you reach a node with a solved
- > board.
-
- > If you actually create the entire tree (instead of stopping when you
- > reach your first solve), this algorythm gives you the added bonus of
- > being able to find the fewest moves necessary to solve the board.
-
- This just *begs* for dynamic programming. I just wouldn't know how. :-)
-
- --
- Wessel Dankers _\\|//_ <wsldanke@cs.ruu.nl>
- ///|\\\
- ----------------------------oOO--(_)---OOo----------------------------
- `Never imagine yourself not to be otherwise than what it might appear
- to others that what you were or might have been was not otherwise than
- what you had been would have appeared to them to be otherwise.'
-
-