- Joined
- Mar 3, 2012
- Posts
- 3,181
- Reaction score
- 1,290
I'm interested to find out if anyone else shares the 'unhealthy' obsession I have with a unifying mathematical theory for solving any amount of n-queens.
For people who aren't familiar it's a simple problem. You take any size board (with more than 4 pieces) and place the same amount of queens as rows on the board. They cannot check each other. So far there doesn't appear to be any mathematical formula that can state what the positions will be and how many solutions there will be. A prize was offered a while ago to prove that this could not be solved via artificial intelligence or genetic algorithms (although as my video date shows) I have been looking into this for a lot longer. Obviously the only way to do that is to prove that there is a formula which you can use without placing any pieces - hence 'brute force' is not a proof. I was in touch with the uni that offered the prize and had some back and forth interesting emails with them. My conclusion is that it can be solved with genetic algorithms but they are slow (here's one I wrote for visual aid and it 'evolves' to the correct answer but only when there is 'mutation' factor to get it out of a stuck position which is really the same as starting from a different random position. ).
They can be quicker solved with simple algorithms. The reason for this is that there is no 'almost right' answer and the algorithm only evolves to a trial and error situation. You can put down all the pieces and one of them could be wrong or all of them could be wrong but they are all EQUALLY wrong. Therefore there is nothing for an AI to improve.
However using a simple algorithm I came up with this:
https://orderdomain.uk/tmpmath/nqueens.php
That will basically give you an array of rows, and the position on the row the queen needs to be for the solution to work. Note sometimes it fails when it finds that the 'best' position is equally as 'good' as the position before and ends up in an infinite loop of swapping 2 positions back and forth.
I have pages of research and mathematical formulas I've been trying and I would love to hear if anyone else has been approaching this.
For people who aren't familiar it's a simple problem. You take any size board (with more than 4 pieces) and place the same amount of queens as rows on the board. They cannot check each other. So far there doesn't appear to be any mathematical formula that can state what the positions will be and how many solutions there will be. A prize was offered a while ago to prove that this could not be solved via artificial intelligence or genetic algorithms (although as my video date shows) I have been looking into this for a lot longer. Obviously the only way to do that is to prove that there is a formula which you can use without placing any pieces - hence 'brute force' is not a proof. I was in touch with the uni that offered the prize and had some back and forth interesting emails with them. My conclusion is that it can be solved with genetic algorithms but they are slow (here's one I wrote for visual aid and it 'evolves' to the correct answer but only when there is 'mutation' factor to get it out of a stuck position which is really the same as starting from a different random position. ).
They can be quicker solved with simple algorithms. The reason for this is that there is no 'almost right' answer and the algorithm only evolves to a trial and error situation. You can put down all the pieces and one of them could be wrong or all of them could be wrong but they are all EQUALLY wrong. Therefore there is nothing for an AI to improve.
However using a simple algorithm I came up with this:
https://orderdomain.uk/tmpmath/nqueens.php
That will basically give you an array of rows, and the position on the row the queen needs to be for the solution to work. Note sometimes it fails when it finds that the 'best' position is equally as 'good' as the position before and ends up in an infinite loop of swapping 2 positions back and forth.
I have pages of research and mathematical formulas I've been trying and I would love to hear if anyone else has been approaching this.
Last edited: