Ludii Forum
Is there a way to detect a loop that is connected via the edge of the board? - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Suggestions (https://ludii.games/forums/forumdisplay.php?fid=10)
+--- Forum: Ludii Features / Services (https://ludii.games/forums/forumdisplay.php?fid=11)
+--- Thread: Is there a way to detect a loop that is connected via the edge of the board? (/showthread.php?tid=257)



Is there a way to detect a loop that is connected via the edge of the board? - dale walton - 11-15-2020

I was wondering if there is a way to detect a board-dividing path of pieces using loop or some other ludeme.  Basically such a path is equivalent to a loop that is connected via the board edges if they are considered all mutually connected.


RE: Is there a way to detect a loop that is connected via the edge of the board? - Eric Piette - 11-16-2020

Hi,

With the ludeme (is Loop ...), I do not think no and I am not sure if we want that ludeme to do that. Because considering the edges of the board to be part of the pieces looping sites is a really specific case and that's technically not a loop of your pieces but of your pieces and of the edges of the board. Consequently that's not a loop created with pieces.

However, the move ludeme (enclose ...) is computing such sites enclosed by pieces (and including the edges of the board because here we do speak about loop, just about enclosing sites).
To translate a move ludeme to a boolean condition you can use (can Move ...)
so something like (if (can Move (enclose ...)) ...) should do what you expect I guess.

Regards,
Eric


RE: Is there a way to detect a loop that is connected via the edge of the board? - dale walton - 11-16-2020

is Loop checks for the enclosure of at least one SITE without specifying where, can enclose do the same?

On a square grid, Loop Diagonal is like enclose Orthogonal, and Loop Orthogonal like enclose Adjacent, right?

Also I want to test if the enclosure has already occurred, not whether it is possible to occur - how can that be done eg for a game end condition.


RE: Is there a way to detect a loop that is connected via the edge of the board? - Eric Piette - 11-17-2020

The BooleanFunction (is loop ...) or the Move (enclose ...) starts from a specific site (not anywhere on the board). In general checking the (last To) site is enough in the consequence of the move adding/moving a piece.

Loop and enclose are not equivalent. Loop tries to find a loop of pieces with at least a site in the middle. Enclose applies a move to all the sites enclosed because of the last move (Here, sites enclosed mean they have no escape to go outside of the pieces enclosing them).

If you do a (can Move (enclose ....)) in the ending condition with your condition in the enclose ludeme that should do what you expect.

Regards,
Eric


RE: Is there a way to detect a loop that is connected via the edge of the board? - dale walton - 11-19-2020

Thanks, I'll try that.

Attached is a different approach, (essentially building my own connection function using group)  and I would like to know, when the do is activated, why all the spaces don't get filled?

If it worked, I could use it with an (if (can ... (then (triggered ...

PS. I tried your suggestion, as I understood it, but it doesn't seem to work, please check what I did wrong.


RE: Is there a way to detect a loop that is connected via the edge of the board? - Eric Piette - 11-19-2020

Hi,

Which file I am supposed to look?
Please, one file and one question at time, more is too complex for us to follow.

Regards,
Eric


RE: Is there a way to detect a loop that is connected via the edge of the board? - dale walton - 11-19-2020

Sorry. it was intended as a separate post, but it got concatenated.

The first file is a demonstration of what I believe to be a bug that prevents an alternative approach.

The final file is the one using the approach you recommended, and the trials show games reaching positions that should have activated the enclosed end condition but didn't.


RE: Is there a way to detect a loop that is connected via the edge of the board? - dale walton - 11-21-2020

And I downloaded 1.1.1 (Thanks for the All ludeme, and the remember values - maybe I can use them in this script later on)

My trial with enclose also has positions that end which shouldn't...  see attached lud file and trial.  (same result if  "Orthogonal" is omitted.) 

I can't find my error.


RE: Is there a way to detect a loop that is connected via the edge of the board? - dale walton - 11-21-2020

Re the other question:
Regarding the other file ( Test of fill.lud (Size: 1.06 KB / Downloads: 0) ) which tries to fill in the board conditionally - I now understand why that is not working: The ifAfterwards is filtering each added piece, nor filtering the result of adding all possible pieces. -- Is there a way to "(do..." an add to multiple sites and then filter the entire operation pass/fail, instead of filtering each individual add?


RE: Is there a way to detect a loop that is connected via the edge of the board? - Eric Piette - 11-23-2020

Hi,

Yes the (enclose ...) ludeme to make a loop in using the edge of the board is not really adapted if you can also enclose an empty site after trying that. So for the moment, that's a bit hard to describe an enclosing of empty sites in using the edge of the board. When in the future I will make modification to have an easy way to do that I will come back to you.

Regards,
Eric