Ludii Forum
Stacks capturing stacks. - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Ludii Player Problems (https://ludii.games/forums/forumdisplay.php?fid=6)
+--- Thread: Stacks capturing stacks. (/showthread.php?tid=220)



Stacks capturing stacks. - ccxvii - 10-27-2020

I've run into an issue where I have a stack of pieces that moves and want to capture an enemy stack.

It appears that if I have a move rule with both a (to ... (apply (remove (to)))) and stack:true, the removal isn't executed.

    (move Step Orthogonal (to if:(or (is Empty (to)) (is Enemy (who at:(to)))) (apply (remove (to)))) stack:true)


RE: Stacks capturing stacks. - Eric Piette - 10-28-2020

Hi,

Can you send us a .lud with that rule used and if possible a trial showing the problem?

Thank you.
Regards,
Eric


RE: Stacks capturing stacks. - ccxvii - 10-30-2020

Here is a minimal example:

  (game "StackExample"
        (players 2)
        (equipment {
                (board (square 4))
                (piece "Disc" Each
                        (move Step Orthogonal
                                (to
                                        if:(or
                                                (is Empty (to))
                                                (is Enemy (who at:(to)))
                                        )
                                        (apply (remove (to)))
                                )
                                stack:true
                        )
                )
        })
        (rules
                (start {
                        (place Stack "Disc1" 0 count:2)
                        (place Stack "Disc1" 1 count:2)
                        (place Stack "Disc1" 2 count:2)
                        (place Stack "Disc1" 3 count:2)
                        (place Stack "Disc2" 12 count:2)
                        (place Stack "Disc2" 13 count:2)
                        (place Stack "Disc2" 14 count:2)
                        (place Stack "Disc2" 15 count:2)
                })
                (play (forEach Piece))
                (end (if (no Moves Next) (result Mover Win)))
        )
  )


RE: Stacks capturing stacks. - Eric Piette - 11-02-2020

Hi,

In your description you do not specify that's the enemy stack has to be removed but just the top enemy piece.
the "stack:true" in the (move Step ...) means that your stack can step on the top of the other stack.
And the (remove (to)) means you remove the top site of the stack of the (to) target site.

If you want to remove all the pieces in the stack before to move in it you have to add the count parameter to the (remove ...) ludeme to specify the number of pieces you want to remove before to move there.

So here for example

(remove (to) count:(size Stack at:(to)))

BUT, if you do not want to remove all the pieces in the stack but only one and be able to move that stack only if the top piece is owned by a specific player you can use

(forEach Piece top:true)

Regards,
Eric