![]() |
Conditional movement - Printable Version +- Ludii Forum (https://ludii.games/forums) +-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13) +--- Forum: About the Ludii Grammar (https://ludii.games/forums/forumdisplay.php?fid=15) +--- Thread: Conditional movement (/showthread.php?tid=532) |
Conditional movement - Enrique - 04-04-2021 I just started with ludii and I'm learning how the language works. Now I'm struggling with a conditional clause for movement. The setup is a square board with checkers pieces on it. I want to move the pieces in any direction through empty spaces until they reach the farthest location. I've managed to accomplish this with: Code: (piece "Disc" Each But I want to allow this movement only if the piece ends it next to an Enemy piece in the same direction. I've tried to add somewhere an if clause similar to the following one Code: if:(not (is Friend (who at:(sites LineOfSight Piece at:(from))))) but I don't know how to make it work. Do you know any examples I can look at? RE: Conditional movement - cambolbro - 04-04-2021 Hi, You could try directionCapture, something like: Code: (directionCapture See Fanorona.lud and Vela.lud. Regards, Cameron RE: Conditional movement - Enrique - 04-04-2021 Thanks! I will take a look at it to see how it works. RE: Conditional movement - Eric Piette - 04-06-2021 Hi, If I understand correctly what you are trying to do, this is not a capturing move, but just moving a piece in the farthest empty sites next to an enemy piece in the same direction. In that case the correct description is Code: (do That's just the move you described inside a (do ...) ludeme checking if the piece after your move is an enemy piece. Regards, Eric RE: Conditional movement - Enrique - 04-06-2021 Yes! That's exactly what I wanted. Thanks. But now I have a compilation error: Unexpected syntax '(directions Cell from...' in 'at:(ahead (last To) (directio...'. Is it because Cell is not defined? RE: Conditional movement - Eric Piette - 04-06-2021 Are you using the last version? 1.1.16. Because that works perfectly here. Eric RE: Conditional movement - Enrique - 04-06-2021 Yes, 1.1.16 The complete code I'm using is: Code: (game "Collider" Thanks, Enrique RE: Conditional movement - Eric Piette - 04-06-2021 Hi, Your description works perfectly fine here. So I guess you will have to wait our next release. Regards, Eric RE: Conditional movement - Enrique - 04-06-2021 Glad to know. I'll wait and then I'll come back with more questions to complete the game ;-) RE: Conditional movement - Enrique - 04-24-2021 I've just tried it with the new version (1.1.17) and works like a charm. Thanks! |