Coding The Knight's Tours

There is absolutely no way anyone could hardcode in all the solutions. The sheer number of possible moves makes it a ridiculous idea to begin with, and the limit to how many lines of DragonSpeak you can have makes it flat-out impossible.

What is possible is to use DragonSpeak to determine:

  1. where you may go from any specific point,
  2. where you've been already
  3. the number of moves you've made/have left

Also, the number of squares on the board would be hardcoded into the DragonSpeak and when the number of moves the player made equalled how many squares their were, then obviously the board had been solved. If you made a mistake, you found yourself with no legal moves left to make and had to reset the puzzle by making an illegal one.

In its original incarnation, changing floors was used to track the moves made; a bit of patching was used to create floors that looked identical but had different floor numbers (effects did not yet exist).

Intro For The Player

So, we started out by letting the player know what the dream was all about, and also the size of the various boards:

(0:3) When somebody moves into object type #358,
 (5:200) emit message {Turn every tile on each board to blue by placing the Knight on that tile...*} to the triggering furre.

(0:3) When somebody moves into object type #271,
(1:183) and the spot they moved to isn't in region #1,
(1:183) and the spot they moved to isn't in region #3,
(0:3) When somebody moves into object type #272,
(1:183) and the spot they moved to isn't in region #1,
(1:183) and the spot they moved to isn't in region #3,
(5:351) set variable %sign to the X,Y position the triggering furre moved to.
(5:320) set variable %size to the region number (%sign) is part of.
(5:200) emit message {Board Size: %size X %size} to the triggering furre.

(0:3) When somebody moves into object type #271,
(1:83) and the spot they moved to is in region #1,
(0:3) When somebody moves into object type #272,
(1:83) and the spot they moved to is in region #1,
        (5:200) emit message {The 1X1 board was added for sheer giggles. #SA} to the triggering furre.

(0:3) When somebody moves into object type #271,
(1:83) and the spot they moved to is in region #3,
(0:3) When somebody moves into object type #272,
(1:83) and the spot they moved to is in region #3,
        (5:200) emit message {Board Size: 3X4.  This is the smallest board that has a meaningful tour... } to the triggering furre.
		
Instruction Book
Signposts

Basically, bumping into the book (Object #385) gives you an overview of the entire dream, while the signs (Objects #271 and #272) let you know how large each board is.

Board Size

There is some math that shows how many squares each board has, which is the maximum number of moves one might do on the board.

**SECTION**  Enter/Begin Puzzle
(0:68) When a furre moves from object 553,
(1:2) and they move into floor type 180,
(0:68) When a furre moves from object 554,
(1:2) and they move into floor type 180,
(0:68) When a furre moves from object 555,
(1:2) and they move into floor type 180,
(0:68) When a furre moves from object 556,
(1:2) and they move into floor type 180,
(0:17) When somebody picks up object type 312,
(5:350) set variable %tile to the X,Y position the triggering furre (moved from/is standing at).
(5:320) set variable %board to the region number (%tile) is part of.
(5:301) copy the value of variable %board into variable %checkscore.
(5:306) multiply variable %checkscore by %checkscore.
(5:167) allow getting and dropping items in region %board.

(0:68) When a furre moves from object 553,
(1:2) and they move into floor type 180,
(1:85) and the triggering furre (moved from/is standing in) region 3,
(0:68) When a furre moves from object 554,
(1:2) and they move into floor type 180,
(1:85) and the triggering furre (moved from/is standing in) region 3,
(0:68) When a furre moves from object 555,
(1:2) and they move into floor type 180,
(1:85) and the triggering furre (moved from/is standing in) region 3,
(0:68) When a furre moves from object 556,
(1:2) and they move into floor type 180,
(1:85) and the triggering furre (moved from/is standing in) region 3,
(0:17) When somebody picks up object type 312,
(1:85) and the triggering furre (moved from/is standing in) region 3,
(5:302) take variable %checkscore and add 3 to it.
		

The extra programming involving region 3 deals with the fact that region 3 is a 3×4 board, not 3×3.

Open Gates
The Knight

Objects 553 through 556 are gates (which close when a furre is in the board) and Object 312 is the Knight being moved around.

(0:68) When a furre moves from object 553,
(1:2) and they move into floor type 180,
(0:68) When a furre moves from object 554,
(1:2) and they move into floor type 180,
(0:68) When a furre moves from object 555,
(1:2) and they move into floor type 180,
(0:68) When a furre moves from object 556,
(1:2) and they move into floor type 180,
(5:301) copy the value of variable %board into variable %score.
(5:306) multiply variable %score by %score.
(5:316) set the triggering furre's entry code to %score.
(3:5) where the triggering furre was at,
(5:5) change object type 553 to type 557.
(5:5) change object type 554 to type 558.
(5:5) change object type 555 to type 559.
(5:5) change object type 556 to type 560.
(5:11) play sound 4 to every furre who can see the triggering furre.

(0:68) When a furre moves from object 553,
(1:2) and they move into floor type 180,
(1:83) and the spot they moved to is in region 3,
(0:68) When a furre moves from object 554,
(1:2) and they move into floor type 180,
(1:83) and the spot they moved to is in region 3,
(0:68) When a furre moves from object 555,
(1:2) and they move into floor type 180,
(1:83) and the spot they moved to is in region 3,
(0:68) When a furre moves from object 556,
(1:2) and they move into floor type 180,
(1:83) and the spot they moved to is in region 3,
(5:302) take variable %score and add 3 to it.
(5:316) set the triggering furre's entry code to %score.
		
Closed Gates

Begin The Puzzle

When the furre enters the puzzle, the gate closes behind him (these are objects 557, 558, 559, and 560). The furre is now ready to begin.

* Check for puzzle beginning.
(0:17) When somebody picks up object type 312,
(1:90) and the triggering furre's entry code is %checkscore,
(3:30) in region %board,
(5:2) change floor type 180 to type 183.
		
Red Floor
Green Floor>

Only green tiles can have Knights placed on them. Since you may place the Knight anywhere for your first move, all tiles turn green when you first pick up the Knight.

Making And Tracing Moves

**SECTION**  Move The Knight
(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 183,
(5:8) play sound 52 to the triggering furre.
(5:350) set variable %placetile to the X,Y position the triggering furre (moved from/is standing at).
(5:320) set variable %furreboard, to the region number (%placetile) is part of.
(3:30) in region %furreboard,
(5:2) change floor type 183 to type 180.
(3:60) 1 step(s) NE & 2 step(s) NW from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:60) 2 step(s) NE & 1 step(s) NW from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:61) 1 step(s) NE & 2 step(s) SE from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:61) 2 step(s) NE & 1 step(s) SE from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:62) 1 step(s) SW & 2 step(s) SE from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:62) 2 step(s) SW & 1 step(s) SE from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:63) 1 step(s) SW & 2 step(s) NW from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:63) 2 step(s) SW & 1 step(s) NW from where the triggering furre (moved from/is standing),
(5:2) change floor type 180 to type 183.
(3:5) where the triggering furre was at,
(5:1) set the floor to type 184.
(5:315) set variable %update_score to the triggering furre's entry code.
(5:304) take variable %update_score and subtract 1 from it.
(5:316) set the triggering furre's entry code to %update_score.
		
Blue Floor
How The Knight Mooves

Once you set the Knight down, the square you are on turns blue and the rest turn red. Certain red squares, however, turn green—these are the ones the Knight may legally move. Blue squares do not turn green, as they mark where you've already placed the Knight.

**SECTION**  Screwup
(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 180,
(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 184,
(5:8) play sound 56 to the triggering furre.
(5:350) set variable %resetboard to the X,Y position the triggering furre (moved from/is standing at).
(5:320) set variable %resetregion to the region number (%resetboard) is part of.
(5:301) copy the value of variable %resetregion into variable %resetscore.
(5:306) multiply variable %resetscore by %resetscore.
(5:316) set the triggering furre's entry code to %resetscore.
(3:30) in region %resetregion,
(5:2) change floor type 184 to type 180.
(5:2) change floor type 183 to type 180.

(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 180,
(5:200) emit message {That is not a legal move.} to the triggering furre.

(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 184,
(5:200) emit message {You've already visited that square.} to the triggering furre.

(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 180,
(1:83) and the spot they moved to is in region 3,
(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 184,
(1:83) and the spot they moved to is in region 3,
(5:302) take variable %resetscore and add 3 to it.
(5:316) set the triggering furre's entry code to %resetscore.

		

If you place the Knight on a red or blue square, you've made a mistake and must restart the puzzle.

Winning The Tour

**SECTION**  Winning
(0:18) When somebody drops object type 312,
(1:17) and the triggering furre (moved from/is standing at) floor type 183,
(1:90) and the triggering furre's entry code is 0,
(5:200) emit message {You win!} to the triggering furre.
(5:8) play sound 62 to the triggering furre.
(5:350) set variable %winboard to the X,Y position the triggering furre (moved from/is standing at).
(5:320) set variable %winregion to the region number (%winboard) is part of.
(3:30) in region %winregion,
(5:5) change object type 560 to type 556.
(5:5) change object type 559 to type 555.
(5:5) change object type 558 to type 554.
(5:5) change object type 557 to type 553.
(5:166) make it impossible to pick up or drop items in region %winregion.
(4:1) only where the floor is type 159,
(5:150) place overlay effect 52.
(4:0) clear all filtering,
(4:1) only where the floor is type 158,
(5:150) place overlay effect 53.
(4:0) clear all filtering,
(4:1) only where the floor is type 156,
(5:150) place overlay effect 54.
(5:446) reset the animation of all copies of effect 52 in the dream.
(5:446) reset the animation of all copies of effect 53 in the dream.
(5:446) reset the animation of all copies of effect 54 in the dream.
(4:0) clear all filtering,
		
Floor turned to blue  You Win.

Of course, the ultimate goal is to turn all the red squares blue. When you've done that, you've won (and get a little fireworks display). The gate automatically opens, and you can no longer pick up the Knight (must keep the dream tidy!).

Losing The Tour

Blue tiles, red tiles, but no green tiles.  You Loose.

If no squares turn green but there are still red squares on the board, then you have made a mistake and there are no legal moves left.

You have two options:

  1. Make a wrong move, which will reset the puzzle.
  2. If you are not holding the Knight, leave the board to reset it.

Sorry, there's no option to retrace your steps.

See For Yourself!

I've provided a ZIP archive of the dream. You'll notice some extras in there as well, such as a place and means for the uploader avatar to hide and DS to keep the Knights on their respective boards. You'll also see some DragonSpeak dealing with the edges of certain boards, as they are right on the edge of the walkable region.

Back to my Dreams page