Skip to content

Instantly share code, notes, and snippets.

@cggonzal
Created January 6, 2019 19:34
Show Gist options
  • Save cggonzal/cad0162b656a5a6814bee1fe1d6b05d8 to your computer and use it in GitHub Desktop.
Save cggonzal/cad0162b656a5a6814bee1fe1d6b05d8 to your computer and use it in GitHub Desktop.
for pos in positions: # iterate through all positions of pickedQueen and move to position of minimum conflict
NQ.moveQueen(pickedQueen,pos)
newNumberOfConflicts = NQ.specificQueenConflicts(pos)
if(newNumberOfConflicts < minAttacks ):
minConflictPosition = pos
minAttacks = newNumberOfConflicts
NQ.moveQueen(pos,pickedQueen) # move queen back
NQ.moveQueen(pickedQueen,minConflictPosition)# move queen to least conflict spot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment