Ludii Forum
How to save multiple Cells to Pending? - 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 save multiple Cells to Pending? (/showthread.php?tid=89)



How to save multiple Cells to Pending? - JayCoskey - 07-23-2020

I've implemented several versions of Chess in which I've chosen a seemingly flexible means of implementing the en passant feature. I store the last Pawn moved into Var, and the Cell or Cells jumped over by the previous Pawn into Pending. This looks something like:


Code:
(then (and
        (set Pending (ahead (last To) Backward))
        (set Var (last To))
))


This works when implementing en passant following a two-space Pawn advancement. But in a variant with a three-space Pawn advancement (specifically, Shafran Chess), I have not found a version that works. The most promising seems to be something like:


Code:
(then (and  
        (set Pending
            {
            (ahead (last To) steps:1 Backward)
            (ahead (last To) steps:2 Backward)
            }
        )
        (set Var (last To))
))



However, this is not valid Ludii syntax. The (ahead) ludeme returns an item of type Site, while Pending expects an argument of type "moves". I've made several attempts, but haven't a combination that works. Any ideas?

Thanks,
Jay


RE: How to save multiple Cells to Pending? - DennisSoemers - 07-23-2020

You can take a look at "Double Chess.lud" for an example. I think that one features En Passant with a four-space Pawn advancement actually. The relevant part is in the following snippet (note: I took this from our current development version, so it might still be slightly different from the current public release; this will soon be included in a new public release though):

Code:
(define "JumpOfPawn"
    (move
        Hop
        (from)
        Forward
        (between
            (range 1 3)
            if:(is Empty at:(between))
            (apply (set Pending (between)))
        )
        (to if:(is Empty at:(to)))
        "SetEnPassantLocation"
    )
)

Note that you were basically trying to set pending on a larger region at once, which doesn't work. This sort of "inverts" the idea, and essentially uses multiple set pendings on individual sites.


RE: How to save multiple Cells to Pending? - JayCoskey - 07-24-2020

Thanks, Dennis. I tried some variations based on your suggest, but didn't get en passant to work after 3-space Pawn advancement. I ended up submitting a 0.9.4 version of Shafran Chess to the "Submit Your Games" sub-forum, together with a mention of the bug present.