Ludii Forum
(piece state:<int>) - 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: (piece state:<int>) (/showthread.php?tid=1173)



(piece state:<int>) - Michael - 08-21-2022

It seems to me like the "state:" argument in (piece) simply doesn't work. Or, worse, trying to use it can break the Ludii player.
Trying to make a simple test to show that it does nothing, I modified Tic-Tac-Toe like this:
Code:
(game "Tic-Tac-Toe"
    (players 2)
    (equipment {
        (board (square 3))
        (piece "Disc" P1 maxState:1)
        (piece "Cross" P2 maxState: 1)
    })
    (rules
        (play
            (move Add
                (piece (mover) state:1)
                (to (sites Empty))
            )
        )
        (end ("Line3Win"))
    )
)
But the player simply didn't allow me to input any moves when I compiled it.


RE: (piece state:<int>) - dale walton - 08-21-2022

Hi Michael - did you use State anywhere in the TTT game - the compiler doesn't like you to define anything that doesn't get used, and usually gives a warning to tip you off about it, but not for everything... Dale (because support seems to be slow or on holiday - but they will probably give you a better answer.)


RE: (piece state:<int>) - Michael - 08-22-2022

(08-21-2022, 12:31 PM)dale walton Wrote: Hi Michael - did you use State anywhere in the TTT game - the compiler doesn't like you to define anything that doesn't get used, and usually gives a warning to tip you off about it, but not for everything... Dale (because support seems to be slow or on holiday - but they will probably give you a better answer.)

Not in the TTT game, no. Only modification I made is what you can see in the OP. So that might be why the player broke.
I do use state in the game where I originally encountered the issue, though. I'll try to make some examples to show what I've been struggling with. 

(swap Pieces) does not work like I expected. I suspect one of the problems is that it doesn't preserve state. Or maybe this state problem on applies to shared pieces. I haven't explored it deeply. I only tried three or four different ways of implementing a proprietary (swap Pieces) using other ludemes. I got the same issue with all of them: I wasn't able to set the state of the pieces. Instead of ripping my hair out, I'll try to make some examples, as I said..


RE: (piece state:<int>) - Michael - 08-22-2022

Ok, here is finally some concrete examples of my issue. The basic interaction here is that one swaps the position of the Disc with any one of the colored Squares (select the Disc, then select a Square). The wanted result is that the two selected pieces swap positions and the Square is in the same state as it was before the swap.

In "1-SwapDoesNotPreserveState.lud" I only use swap and do not manage state manually.
"2-SwappingAndLosingState.trl" is a trial showing that the pieces swap positions, but the Square is not in the same state after the swap.

In "3-StateCannotBeManuallySetAfterSwapEither.lud" I try to remedy this by manually keeping track of and setting the state.
"4-ManuallySettingState.trl" is a trial showing that the ludeme that is supposed to set the state explicitly is ignored.


RE: (piece state:<int>) - Eric Piette - 08-22-2022

Hi,

For your issue with the state and the Add ludeme, I found an issue from a code written by Dennis.
He is going to look when he can and let you (and me) know.

Regards,
Eric


RE: (piece state:<int>) - Eric Piette - 08-23-2022

Hi,

Dennis found the problem (detection of the usage of the local state when used only by a add move).
This is now fixed.

When we will release the next version. Please let us know if you still have some issue.

Eric


RE: (piece state:<int>) - Michael - 08-23-2022

Thanks! That's great news :)


RE: (piece state:<int>) - Michael - 09-07-2022

(08-22-2022, 07:45 AM)Michael Wrote: Ok, here is finally some concrete examples of my issue. The basic interaction here is that one swaps the position of the Disc with any one of the colored Squares (select the Disc, then select a Square). The wanted result is that the two selected pieces swap positions and the Square is in the same state as it was before the swap.

In "1-SwapDoesNotPreserveState.lud" I only use swap and do not manage state manually.
"2-SwappingAndLosingState.trl" is a trial showing that the pieces swap positions, but the Square is not in the same state after the swap.

In "3-StateCannotBeManuallySetAfterSwapEither.lud" I try to remedy this by manually keeping track of and setting the state.
"4-ManuallySettingState.trl" is a trial showing that the ludeme that is supposed to set the state explicitly is ignored.

The "state:" argument in (piece) works now, thats great! Thanks :)
However, the issues quoted above are untouched.
I can work around them by using the state-argument in (piece), but you might want to look into it, as there seems to be a big somewhere.
I'm not entirely sure how (swap Pieces) is supposed to work (if it's supposed to preserve state), but the other issue (exemplified in files 3-… and 4-…) definitely seem like a bug.