This site requires JavaScript, please enable it in your browser!
Greenfoot back
Tim

Tim

Welcome to my page

Tim's scenarios

This user has not made any scenarios.

Tim's collections

This user has no collections

Recent Comments

Excellent job! Looping through the possible moves is essentially doing a depth first search of the possible positions. Have you considered trying to solve using bit boards? It might be fun for you. If you don't know, a bit board is simply a 64-bit integer that has a 1 or 0 for each square on the board. For this problem you could have a bit board representing the location of all queens currently on the board (1s for squares with queens and 0s for empty squares). You could then have a bit board representing all positions that would be under attack by a queen if placed in a certain square. Performing a bitwise AND between those two bit boards will result in a 0 if no queen would be under attack in that position or a number >0 if at least one queen would be under attack. The advantage of this is that it doesn't require looping and bitwise operations take a single clock cycle on a 64bit processor. Bit boards are very common for game theory in games played on 8x8 grids.