Ludii Forum
The "else-clause" in (if) - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Game Problems (https://ludii.games/forums/forumdisplay.php?fid=17)
+--- Thread: The "else-clause" in (if) (/showthread.php?tid=831)



The "else-clause" in (if) - Michael - 02-16-2022

I have run into a situation where it seems to me that the ludeme in the else-clause of my if-statement is called, even though the condition of the statement is true.

Here is the relevant part of the script:
Code:
("Remove" Enemy
    (then
        (if
            (no Pieces Enemy in:(sites Board)) //CONDITION
            (set Var "Winner" (mover))         //DO THIS
            ("Remove" Mover                    //ELSE THIS
                (then
                    (if
                        (no Pieces Mover in:(sites Board))
                        (set Var "Winner" (+ 1 (% (mover) 2)))
                    )
                )
            )
        )
    )
)

It seems to me that the the action described in the ludeme I have marked with "ELSE THIS" – namely ("Remove" Mover …) – should not be performed if, after ("Remove" Enemy) is performed, (no Pieces Enemy in:(sites Board)) evaluates to True. As far as I can see, this should have the following effect on the behavior of the game: If ("Remove" Enemy) removes all enemy pieces from the board, then friendly pieces should not be removed. 

To spell it out:
If after the action described by ("Remove" Enemy) is performed, (no Pieces Enemy in:(sites Board)) evaluates to True, the action described by the following part of the ludeme should not be performed:
Code:
            ("Remove" Mover
                (then
                    (if
                        (no Pieces Mover in:(sites Board))
                        (set Var "Winner" (+ 1 (% (mover) 2)))
                    )
                )
            )

Yet, in the trial I have attached, after White captures the last remaining black stones, White's own stones are also removed. Thus, the game ends with no pieces on the board. The winner is determined correctly, but the board is never supposed to end up empty at the end of the game.

My script has many other issues besides this, btw. In general, I am unable to perform two conditional actions in order. When I use (do next:), the first action isn't performed if the second action isn't performed. I often get in trouble when a rule has this structure:

First, if condition C1 holds, do A. Secondly (whether or not A was done), if condition C2 now holds, do B.

In this case the structure of the rule is more like:

First, go through all enemy groups and remove those that meet "the condition". Secondly (whether or not any enemy group was removed), go though all friendly groups and remove those that meet "the condition".


RE: The "else-clause" in (if) - Michael - 03-03-2022

I no longer need to fix this particular problem. But I will probably (at some time or another) make a thread about the general problem of performing two conditional nondecision actions in order.