Games JavaScript

Bishops Swap Game

The Bishops Swap Game is a classic puzzle from the 7th Guest. Here is the start position of it:

The end position is the same, except that the black and white bishops have swapped: the black bishops are on the top row, the white bishops are on the bottom row. Move the bishops to get the end position, according to the following rules.

  • The bishops move like they do in chess: diagonally only.
  • There can be at most one bishop on a square.
  • You may not put a bishop on a diagonal on which there is already a bishop of the opposite color.

Decades ago when someone described the puzzle to me, I couldn’t solve it I’m afraid and wrote a little program in JavaScript to figure it out. Down below you’ll find the output of that program, but you may want to try to solve the puzzle first.

I can’t remember if I couldn’t find a solution because I didn’t realize you don’t have to alternate between white and black moves or I just was not as clever as I thought I was.

Alternative view

All bishops move on squares of the same color. The other squares don’t play a role in the puzzle. Maybe the puzzle is easier when those squares are left out? This would lead to a Rooks Swap Puzzle:


Is a chessboard necessary at all? No, the problem can be described too in terms of graphs. The graph consists of ten nodes, neighboring nodes correspond with squares that can be reached in one move.

I thought this would be a good opportunity to get better acquainted with Vue.js. The model (or state, or data) would deal with the graph, while the chessboard with bishops or rooks would be two alternative views of it.

To solve the puzzle visit Bishops and Rooks Swap Game.

Brute force solution

The output of the script I mentioned above (from 2005) is below. Along with part of the script. Most of it is dutch!