# Thread: Bishops on the chess board, I need help

1. ## Bishops on the chess board, I need help

I need to write a program which finds the places on a chess board, where 8 bishops should be placed that the lines of their movement would cover whole chess board. Maybe someone could help me and suggest some algorithm for this task?
Thanks

2. Vaguely thinking, the most plain cases are the two diagonals.
When either diagonal of the board is lined with bishops, then they cover the whole board.
But, permuting the bishops along their movement on the board would also cover the whole board.
So your algorithm might look like all the permutations of bishops positioned along either the right or the left diagonal when allowed to move on their movement path.
eg.
[.......B]
[......B.]
[.....B..]
[....B...]
[...B....]
[..B.....]
[.B......]
[B.......]
Start from something like this, and starting moving them around and i think it should do the job.

3. I think he means cover every possible square. If they are on a diagonal, that only covers one color.

4. I would code up a scan of the search space, (brute force), where no two bishops can be on the same diagonal. Also, the individuality of each bishop should be ignored. If the answer is a straight line of bishops right down the middle of the board, it won't matter if the #1 bishop is top of the row of bishops, or if the bishop is really #2, etc.

At the end of every placement, count up the number of squares that the bishops cover (remembering their 4 possible ways of moving: 2, 4, 8, and 10 o'clock), which converts to (say 2 o'clock): row + i, col + i, until the diagonal ray reaches the edge of the board.

When the 4 ways of moving have been taken into consideration, then simply add up every square each bishop has covered. When you reach 64, you're done.

There will be mirrored or rotated answers to this, but that should cause no worries.