Ludii Forum
Issue with count-parameter in (add) - 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: Issue with count-parameter in (add) (/showthread.php?tid=392)

Pages: 1 2


Issue with count-parameter in (add) - Michael - 01-25-2021

I can't understand why this doesn't work. It works fine if I pass a simple integer to the count-parameter in (add), so there is something wrong with my integer function.. Could someone take a look? Nothing happens when I select two sites.


RE: Issue with count-parameter in (add) - cambolbro - 01-26-2021

Hi,

Maybe try the following directions: N, S, WNW, WSW, ENE, ESE.

Regards,
Cameron


RE: Issue with count-parameter in (add) - Michael - 01-26-2021

(01-26-2021, 03:56 AM)cambolbro Wrote: Hi,

Maybe try the following directions: N, S, WNW, WSW, ENE, ESE.

Regards,
Cameron
Thanks! But the directions are not the problem, I think. All the dots marking legal moves are correct. The issue is that nothing happens when I make a move in the player.

The directions you suggest are correct if I rotate the board, but if that fixes things, there is definitively a bug here. I tried using (note) to see what value the integer function I wrote returns, but since the player is not making a move, (note) is useless.

Here is the function that, if I replace it with an integer, everything is fine:
Code:
(-
    (min
        (count Sites
            in:(sites Direction
                from:(last From)
                #1
            )
        )
        (count Sites
            in:(sites Direction
                from:(last From)
                #2
            )
        )
    )
    (min
        (count Sites
            in:(sites Direction
                from:(last To)
                #1
            )
        )
        (count Sites
            in:(sites Direction
                from:(last To)
                #2
            )
        )
    )
)
#1 and #2 stand for opposite directions. It should return the difference between the shortest distance to an edge cell from (last From) and the shortest distance to an edge cell from (last To).


RE: Issue with count-parameter in (add) - Eric Piette - 01-26-2021

You can use the debug mode to know what a specific ludemeplex (or define) is supposed to return in the current state.

Game --> Test Ludeme

Regards,
Eric


RE: Issue with count-parameter in (add) - Michael - 01-26-2021

(01-26-2021, 08:38 AM)Eric Piette Wrote: You can use the debug mode to know what a specific ludemeplex (or define) is supposed to return in the current state.

Game --> Test Ludeme

Regards,
Eric
Thank you! It is impossible to scroll in those windows, though. And it's not that helpful when the player won't make a move, because (last To) and (last From) won't have meaningful values. But I tried to simply type in the values of a move, and the function returned the expected number. I have no idea why I'm unable to make a move..


RE: Issue with count-parameter in (add) - MatthewStephenson - 01-26-2021

Hi Michael,

I'll add scrollbars to these windows for the next release.

Cheers,
Matthew


RE: Issue with count-parameter in (add) - Michael - 01-26-2021

Any hunch on whether this is a problem with the player, with the grammar or with my code?


RE: Issue with count-parameter in (add) - Eric Piette - 01-27-2021

Hi,

Ok, I looked a bit more and I found a rare bug in (sites Direction ...). I just fixed it.
I am not sure if that will fix your game to do what you want, but at least now when I compile it I have some moves when I select 2 sites.

When the next release will be published, can you tell me if that's helped?

Regards,
Eric


RE: Issue with count-parameter in (add) - Michael - 01-27-2021

That was it! Thanks for fixing it :)


RE: Issue with count-parameter in (add) - Michael - 01-30-2021

New issue:
When I have (apply (remove (last From))) in (to) in (add), the evaluation of the function in "count:" changes. I don't understand how that can be. The function, again, is this:
Code:
(-
    (min
        (count Sites
            in:(sites Direction
                from:(last From)
                #1
            )
        )
        (count Sites
            in:(sites Direction
                from:(last From)
                #2
            )
        )
    )
    (min
        (count Sites
            in:(sites Direction
                from:(last To)
                #1
            )
        )
        (count Sites
            in:(sites Direction
                from:(last To)
                #2
            )
        )
    )
)
If I simply have (add (to (last To)) count:("MyFunction") stack:True), then selecting the center cell, then a cell 2 steps away will result in a stack of size 2 at the destination. This is what the function is supposed to do.

But if I have (add (to (last To) (apply (remove (last From)))) count:("MyFunction") stack:True), then the same selection results in a stack of size 4 at the destination. What is happening here?

I have attached a version where the (apply) ludeme is added.