Ludii Forum
Problems understanding (is Blocked/Connected - 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: Problems understanding (is Blocked/Connected (/showthread.php?tid=548)

Pages: 1 2


Problems understanding (is Blocked/Connected - dale walton - 04-21-2021

These have many options, but little doumentation. I have never beenable to get this Ludeme to work for me, which could be a mis understanding of its function.

Please explain why the attached lud file doesn't work (errors displaying components)
It is supposed to allow placement iff the placed piece has an open path to any empty perimeter cell.

If this functionality doesn't exist, can it?


RE: Problems understanding (is Blocked/Connected - Eric Piette - 04-21-2021

Hi,

The ludeme (is Blocked ...) is to detect if that's impossible to connect a set of regions with the pieces owned by a player.
The ludeme (is Connected ...) is to detect if a set of regions are connected by pieces owned by a player.

Here what you are trying to do ("to allow placement iff the placed piece has an open path to any empty perimeter cell") is different and should not used these ludemes.

The easiest way is that one:



Code:
(forEach Site (sites Empty)
    (if (!= Infinity (count Steps (step (to if:(is Empty (to)))) (site) (sites Outer)))
        (move Add
           (to
              (site)
           )
       )
    )
)


Unfortunately, that code requires the next release, but it works here (I just tried to be sure).
We still hope to do a release Friday, if the code is enough stable.

Regards,
Eric


RE: Problems understanding (is Blocked/Connected - dale walton - 04-21-2021

Thanks.

I had gotten it to work by adding neutral pieces and checking Each group them by the selected sites to see if they also included perimeter sites. Your above code will be much easier.

(do (forEach Piece
(do ...
ifAfterwards:(not (can Move(...))
)
(then
(
(do (forEach ...
(select
(from (...)
if:(can Move
(do (...)
next:(do
(...)
ifAfterwards:(
<problem in here>
))))))
(<remove pieces>
))
ifAfterwards:(... <but don't, if the site removed was the same site as was added> )
))
I also ran into problems with

My guessing it was too much ifAfterwards for the program to keep straight, and it would not compile. - I will wait for your new release which can simplify many of these steps, and has other bug fixes, and then tell you if I still have any problems.


RE: Problems understanding (is Blocked/Connected - dale walton - 04-24-2021

OK. Downloaded 1.1.17 
Had a couple hangs, including one after clicking pass before the game, in which resizing the window bottom still "worked" leaving black in the new area. And once where the window with the game flashed as if it was repeatedly closing and re-opening, and a few requiring ^C in the terminal to exit, but no errors showing in terminal... - But you warned us about that such glitches were possible, so no problem for now...  The smileys are gone which is OK, the pass button has moved away from the play area, which is inconvenient.

I see 2 useful new features (not highlighted in the release notes in your above code: "Infinity" and The use of a region in Count Steps.  Both I was able to find workarounds for in 1.1.16, but the former hopefully speeds things up, and the latter should simplify the code.

What you present as a code fragment would be needed to be part of an ifAfterwards statement. and for my simple game it does work with a few extra qualifications.
ie After placing a piece, ALL board locations must by connected to an EMPTY edge location.

Unfortunately the game that I couldn't get to work is still a problem: It requires that
1) To be placed, a piece must after placement, AND after the addition of another dummy piece in any location, must still be connected to an empty location at the adge of the board, and
2) After placement, any other piece belonging to either player is simultaneously removed, if a dummy piece can be placed in a way that prevents its connection to an empty edge of the board.

My overall logic for identifying the removal sites was something like the following restriction on a (to) ---
if:(all sites ( sites Empty ) if: (can Move (do ( add (to (site)) ifAfterwards: ( <something like your above code> )))))
And I can't seem to get this to compile (probably need to get the right workaround on the limitation on re-entry of functions / re-use of iterators)
(no specific errors are given)

The purpose is to check for the existence of 2 independent paths from each piece to the edge.


RE: Problems understanding (is Blocked/Connected - dale walton - 04-25-2021

Further to the above:
In 1.1.16 I got a hobbled version (Branch2) to work using replacement and testing based on group's contents of neutrals.
Branch2 doesn't do the proper test of 2 independent connections to edge, it only checks for 2 neighbors.

See Barnch2 Coral - working (but note this 1.1.17 bug:)
In 1.1.17 this can hang at the end in auto play, when the winning AI bot has to pass in order to finish the game that it has won.
If I ^C in the terminal and re-start, the full game comes up with the AI not yet moving, and showing "You must Pass" as before.
Then I can complete the game by manually clicking pass, and it shows the winner, but under the game it reads: "That is not a valid Move"
After a few seconds that warning is replaced by the standard "Choose Game> Restart to play again"

This method is slow, so I tried to replace it.
(For Brain Coral I was able to replace it with your "finite steps to outer" method of testing on a board without neutral pieces.)
However, the attached attempt for "Branch2 Coral bug" does not compile, even though I tried to keep the structure similar.

Finally, the game I am actually trying to script, needs to check for independent paths.  I was unable to get it to work for either system.
In the "Branch Coral bug" the consequence part does not compile but I had the part above it compiling without it.

It seems the problem is in the (do(can Move()ifAfterwards()) when it is part of a consequence. but there might be other problems as well.

Please test it out.


RE: Problems understanding (is Blocked/Connected - Eric Piette - 05-03-2021

Hi,

For the non compilation of the first file, that's because you have
(sites Occupied)
but should be
(sites Occupied by:All)
Because the by: parameter is not optional, see grammar.

Now that it is compiling, I got no legal moves for both players, so something is probably wrong in the description.

And I can see that you use pretty weirdly the define "ConnectionRule" I wrote last time.
What is the exact condition to place a piece in that game? Just on an empty site which has at least a path of empty sites between that position and an empty location of the perimeter? Nothing else?


RE: Problems understanding (is Blocked/Connected - dale walton - 05-03-2021

In Brain Coral, it additionally may not block any other piece's connection to the edge either.

In Branch Coral there must be two non-overlapping connections to the edge, and afterwards any pieces without two non-overlapping connections to the edge are removed.


RE: Problems understanding (is Blocked/Connected - dale walton - 05-05-2021

Another problem with your code was that it always allowed placement on a perimeter location, -- But the rule is that it must be connected to EMPTY perimeter locations, so just being on the perimeter doesn't necessarily count as a legal move.


RE: Problems understanding (is Blocked/Connected - dale walton - 05-06-2021

OK,
I cleaned it up a lot, so it should be easy for you to tell me what is still wrong....

Here is my output upon compiling:
Compiled Brain Coral successfully.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=0], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=1], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=4], [SetScore:player=1,score=6], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=5], [SetScore:player=1,score=9], [SetScore:player=2,score=-1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=6], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=7], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=8], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=9], [SetScore:player=1,score=7], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=10], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
WARNING: Move [[Add:type=Cell,to=4,level=0,what=1,decision=true], [Add:type=Cell,to=11,level=0,what=1,decision=true], [Add:type=Cell,to=10,level=0,what=1,decision=true], [Add:type=Cell,to=9,level=0,what=1,decision=true], [Add:type=Cell,to=8,level=0,what=1,decision=true], [Remove:type=Cell,to=11], [SetScore:player=1,score=8], [SetScore:player=2,score=1]] has multiple decision actions. If you see this in an official Ludii game, please report it to us.
Player 1 to move.


RE: Problems understanding (is Blocked/Connected - dale walton - 05-08-2021

I changed the game for other reasons - so this bug is no longer a priority. - but please do explain it.