Hi Neil,

Thanks for sending the code. I've only had chance to have a brief look so far, but i've found a point you may want to look at:

In your QTk descriptions for the board size box and the select column box,

numberentry(
         min:0
         max:16
         init: 0
         handle:E
         return:R
         bg:white
         )

are you sure the minimum value is 0? Do you want your program to attempt to display a board size of 0?

Regards
Mark

Neil Munro wrote:
I have a few more issues with my n queens program but I have been making progress :)

First On an 8x8 board The program can discover what the missing elements are, but for some reason does not add the final element to the list, which it should then return.

Secondly I have a limit on the expected size of the board the upper limit is 16x16 board but when I enter 16 in the board selection dialog box, the n-queens algorithm will only run to a maximum of 12 queens, I do not know if this is linked to my first problem.

Further testing shows on an 8x8 grid with 7 of the queens provided the program cant find the final element, yet increase the board size to 16 (and although it will only run to 12) you will get the 8th queen position. Below are my functions if anyone could help me work out where my last few issues are, I would be grateful.

fun {Queens L N}
   if {GetLengthOfList L} == N then
      {Browse L}
       L
   else
      {Browse L}
      {Queens {Revise 0|L} N}
   end
end

fun {GetLengthOfList L}
   case L of H|T then
      1+{GetLengthOfList T}
   else
      0
   end
end

fun {Revise L}
   case L of H|T then     
      if H == BoardSize then {Revise T}
      else N = {GetLengthOfList L} in
     if {Threaten {BuildList T} H+1#N} then {Revise H+1|T}
     else {AddToList H+1#N T}
     end
      end
   else nil
   end
end

fun {BuildList L}
   case L of H|T then
      %{Browse H.1#{GetLengthOfList L}}
      H.1#{GetLengthOfList L}|{BuildList T}
   else
      nil
   end
end

_________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users


-- 
Mark Richardson
Final year undergraduate
University of Teesside 


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to