Hi Neil,

This sounds suspiciously like my University of Teeside ICA for this year?

Anyway, a few comments that might help hopefully (With a bit of luck, they should be in italics!).

fun {Attack U V}
  R
in
  case U of XI#YI then
case V of XII#YII then if U.1 == V.1 then % Horizontal line. /you've already decomposed or 'split' U into XI and YI, and V into XII and YII
               so the line above should read
                        if  XI == XII then true
               and the line below should be
                        if YI == YII then true
/ true elseif U.2 == V.2 then % Vertical line.
       true
    elseif ( XI - XII ) == ( YI - YII) then      % Diagonal lines.
       true
/i'm struggling a bit here to decide what exactly is being checked in the lines above and below here, but i would suggest these two lines should be
                        elseif (XI-YI) == (XII-YII) then true
                        elseif (XI+YI) == (XII+YII) then true
you need to do both the + and - to test for diagonals in each direction.
///     elseif ( XI - XII ) == ( YII - YI ) then
       true
    else
       false
    end
     end
  end
end

/All in all, I would suggest something like this might be a lot clearer for you:

fun {Attack U V}
  case U of XI#YI then
     case V of XII#YII then
    (XI==XII) orelse  /% /(XI == XII) will equate to either true or false/
/     (YI==YII) orelse  % ditto
    ((XI-YI)==(XII-YII)) orelse
    ((XI+YI)==(XII+YII)) else
    false
     end
  end
end

Your {Threaten} function looks fine.

/
fun {Revise L}
     case L of H|T then
          if {Length L} == BoardSize then {Revise L}
          else N = {Length L} in
          {Threaten T H} then
          {Revise H.1+1#H.2+1|T}
          else H.1+1#H.2+1|T
          end
     end
end

I know this function does not work and if anyone could provide any help as to why it does not work I'd appreciate it, I have neither a mathematics nor engineering background so explanations may have to be quite simplistic.
/I could go into a number of reasons why this won't work, one of which is you're creating a local variable N which you need but you're not using it. You said the tutor gave you the {Revise} function, trust him, it works perfectly as it is.
It is a case of using the function properly.
I would therefore stick with your original version:

/fun {Revise L}
  case L of H|T then
     if H == BoardSize then {Revise T} % Never gonna reach this point
/you WILL reach this point! This function should be being called by another function which is attempting to create a completed list of un-threatened coords. / else N = {GetLengthOfList L} in % since H is X#X, boardsize is an int. /L at this point is a list of column numbers ie. integer values, therefore H is also going to be an integer. It is the {BuildList} function which makes the list into a
            X#X form.
/     if {Threaten {BuildList T} H+1#N} then {Revise H+1|T}
    else H+1|T
    end
     end
  else nil
  end
end/


Hope this helps.
Also, if you have time , I think you'd get better marks if you make the QTk part into just one window.
If you need any more help, post a question again.

For anyone that is trying to help you, they won't know that you have been restricted to using certain functions. It would be so much simpler to use Finite-domain programming as Torsten suggested. I tried it that way to see
and it is soooo much simpler.
But.....good luck anyway!

Regards


/Mark Richardson
Final year degree student
University of Teeside
/

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

Reply via email to