Ludii Forum
(can ("definedmove" gives syntax error, but "definedmove" works - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Game Problems (https://ludii.games/forums/forumdisplay.php?fid=17)
+--- Thread: (can ("definedmove" gives syntax error, but "definedmove" works (/showthread.php?tid=276)



(can ("definedmove" gives syntax error, but "definedmove" works - dale walton - 11-23-2020

I have a game in which individual pieces have an alternative move if they cannot make a standard move.

I attempted a structure of :

(forEach Piece (if (can ("StdMove")) ("StdMove") ("AltMove")))

This produced a syntax error in the "StdMove" define.
However, when the (can ("StdMove")) condition was replaced with an always true, or with an always false condition the program compiled and ran in a consistent manner.
I also tried using a separate define for the (can which used a non-decision version - but that did not help.

See attached file. Note: to compile the file, you will need to change the condition to (= 1 1) or (= 1 2) - as it stands, it does not compile.

I believe that if a move can be made, then it should also work with can.  If not, please supply documentation of when and why it cannot be used.

(PS. I also tried to solve this using a construct with  "(results" in the condition calculation instead of using a conditional move, but that just blew up with no understandable message, and it presented far more questions of what might be wrong than this method)


RE: (can ("definedmove" gives syntax error, but "definedmove" works - cambolbro - 11-23-2020

Hi,

The syntax is (can Move <MOVE_DESCRIPTION>) as can be seen in Chess:

   (can Move ("DoCastle" "RookLeft" E 3 (is Empty (to))))

Regards,
Cameron


RE: (can ("definedmove" gives syntax error, but "definedmove" works - dale walton - 11-23-2020

Thanks. Somehow I missed that... :-) Works now... Just need to add the capture. and probably a noRepeat ;-(