Ludii Forum
"stack"-parameter bug - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Grammar Problems (https://ludii.games/forums/forumdisplay.php?fid=24)
+--- Thread: "stack"-parameter bug (/showthread.php?tid=260)



"stack"-parameter bug - Michael - 11-17-2020

I have come upon some sort of scope confusion when I have several moves inside an (or) operator that have stack-parameters. An example:
Code:
(or
    (move
        (from (sites Outer))
        (to (sites Board))
        stack:true
    )
    (move
        (from (sites Inner))
        (to (sites Board))
        stack:false
    )
)
As long as one of these has "stack:true" the pieces will stack whether I move from (sites Outer) or (sites Inner). This happens even when I explicitly set "stack" to false in one of them, as in the example. You can try for yourself in the attached .lud.

To be explicit: What I would have expected is that a piece that is moved from the outer ring of cells will stack on top of a piece if it is moved to an occupied cell, while a piece that is moved from the inner cells would replace a piece if moved to an occupied cell.

I first came upon this in the context of (add), but tried to replicate it with a different ludeme with a stack-parameter. This is the fruit of that attempt.


RE: "stack"-parameter bug - Eric Piette - 11-18-2020

Hi,

Unfortunately, that does not work like that.
If any ludeme activates the stack mode of Ludii, the default of moving a piece will put that piece on top of other occupied sites (because all the sites are seen as a stack (an empty stack for empty sites, a stack of one piece for sites occupied by a single piece or a stack of n > 1).

For what you describe in your post the correct description is


Code:
(game "StackParameterTest"
    (players 2)
    (equipment
        {
            (board (hex 5))
            (piece "Disc" Each)
        }
    )
    (rules
        (start
            {
                (place "Disc1" (forEach (sites Board) if:(is Even (site))))
                (place "Disc2" (forEach (sites Board) if:(is Odd (site))))
            }
        )
        (play
            (or
                (move
                    (from (difference (sites Outer) (sites Empty))
                    (to (difference (sites Board) (sites Empty)))
                    stack:true
                )
                (move
                    (from (difference (sites Inner) (sites Empty)))
                    (to (sites Board)
                    (apply if:(not (is Empty (to)))
                    (remove (to))
                    )
                    )
                )
            )
        )
        (end
            (if
                (no Moves Next)
                (result Mover Win)
            )
        )
    )
)

Regards,
Eric


RE: "stack"-parameter bug - Michael - 11-18-2020

Thank you for that solution!

I must say, though: It is beyond strange that the correct behavior of a move where the stack-parameter is set to false is to stack nonetheless.

If stacking is a global property, it should be set in a global context, no?


RE: "stack"-parameter bug - Eric Piette - 11-18-2020

That can be weird yes but in reality not really. Because when you put the parameter to stack:false, you did not remove the piece at (to) position, so in that sense if you see the model of the state as a stack for each site, that's pretty logical. The "stack:false" just mean that ludeme does not activate the state to be a stack model, but the other one does.

But which is weird is for a game state for flat game (non stack) when the piece of the (to) is removed even if that's not specified, but that is forced by the model of the state for non stack games in which the "what" data of a site can correspond to only one piece.

That's maybe a bit technical but that's forced by the models ;)

Regards,
Eric


RE: "stack"-parameter bug - Michael - 11-18-2020

Good point. I guess in the real world «stack» is always set to true. At least in the sense that it never happens that a piece disappears when I try to put another piece on top of it.


RE: "stack"-parameter bug - Michael - 11-18-2020

The solution you gave removes the moved piece instead of the piece at the to-location.. (and there was a missing close-bracket, which I added in the attached .lud).

Edit: Sorry, my brainfart. I wasn't able to apply this to my project, but it works fine here. I got confused.