Ludii Forum
How to make a Nightrider piece (sliding Knight)? - 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: How to make a Nightrider piece (sliding Knight)? (/showthread.php?tid=1568)



How to make a Nightrider piece (sliding Knight)? - RubixOne - 05-09-2023

I have an idea for a game that I might post in the future, but one of the pieces in the game moves as a Nightrider, which makes any number of successive Knight leaps in the same direction, stopping on the first capture or short of a friendly piece (like the sliding pieces in Chess), but ignoring intervening pieces that are not directly in its path. This is demonstrated in the attached diagrams.

In theory, it should be pretty easy:

(piece "Nightrider" "SlideCapture" "Knightwalk")

However, that does not work, as Ludii returns this error message:

Unexpected syntax 'F' in '{F F R F [L]}'.

Any help would be greatly appreciated.


RE: How to make a Nightrider piece (sliding Knight)? - fuerchter - 05-12-2023

Hi,
here's a .lud that seems to be doing what you want. Feel free to tell me if I misunderstood your description. It's not very simple/elegant unfortunately, I had to list all the knight walks twice and since I'm using "(foreach Piece)" the "NextMoves" generate moves for all pieces, not just the one you moved in "FirstMove" (you'll notice this when passing e.g.). If anyone knows how to write a better version of this I'd like to know.


RE: How to make a Nightrider piece (sliding Knight)? - fuerchter - 05-15-2023

I worked on some small changes to the .lud I suggested, here it is. It now only lists the walks once and does not generate "NextMoves" (the "(if (= (from) (last To))" I added). Still feel like there is probably a better way to write this.


RE: How to make a Nightrider piece (sliding Knight)? - RubixOne - 05-15-2023

(05-15-2023, 07:34 AM)fuerchter Wrote: I worked on some small changes to the .lud I suggested, here it is. It now only lists the walks once and does not generate "NextMoves" (the "(if (= (from) (last To))" I added). Still feel like there is probably a better way to write this.

I would agree. In theory, it should be possible to do something like this with just a single move. Something Like:

("SlideWalkCapture" {{F F R F L} {F F L F R}}) 

The current implementation also requires you to pass to finish the move, which is a bit awkward.