Ludii Forum
<layers> and <layer> ludemes - 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: <layers> and <layer> ludemes (/showthread.php?tid=251)

Pages: 1 2


<layers> and <layer> ludemes - QuaGamer - 11-11-2020

Do you have an example .lud file that uses the <layers> ludeme? 
Is this correct, incomplete, syntax for a 27 cell 3x3x3 game board?:
(game "Qua"  
    (players 3)  
    (equipment { 
        ( board (layers 3 (square 3)) )
        (piece "Disc" P1)
        (piece "Square" P2)
        (piece "Triangle" P3)
        }
    ) 
)
?
Do the absolute directions U and D refer to the direction between layers? 

How do I specify regions that cross layers that belong to the three players in "Qua"?
Would this work:
     (regions P1 { (sites N) (sites S) } )
     (regions P2 { (sites E) (sites W) } )
     (regions P3 { (sites U) (sites D) } )
?

Are the cells in adjacent layers that are in the same location adjacent to each other? 

If I want to prefill cells in a layer with a player's piece, how do I reference those locations? I would like to do something similar to what was done for Gale:
(start
            {
            (place "Disc" (forEach (sites Board) if:(and (and (is Even (column of:(site))) (is Odd (row of:(site))) ) (or (is layer of:1) (is layer of:3) ) ))
            (place "Square" (forEach (sites Board) if:(and (and (is Even (row of:(site))) (is Odd (column of:(site))) ) (or (is layer of:1) (is layer of:3) ) ))
            (place "Triangle" (forEach (sites Board) if:(and (and (is Odd (row of:(site))) (is Odd (column of:(site))) ) (is layer of:2) ) ))
            }
        )


Also, what does the <makeFaces> ludeme do? Can this be used to create faces across layers?


RE: <layers> and <layer> ludemes - QuaGamer - 11-12-2020

I am reading the just published Ludii Game Logic Guide, which is answering most of my questions. Thank you! I will be submitting a draft Qua.lud file soon, and may need additional help understanding the <layers> and <layer> ludemes.


RE: <layers> and <layer> ludemes - cambolbro - 11-12-2020

Hi,

Yes that syntax is correct. Here's a 3x3x3 version of Tic-Tac-Toe using layers:

(game "Graph Test - Layers (Square, 3x3)"
(players 2)
(equipment {
(board
(layers 3 (square 3))
)
(piece "Disc" P1)
(piece "Cross" P2)
})
(rules
(play (move Add (to (sites Empty))))
(end (if (is Line 3) (result Mover Win)))
)
)

U refers to the site directly above (same x and y value but greater z value).
D refers to the site directly below (same x and y value but smaller z value).

Then you have UN, UE, UNE, ..., DN, NE, DNE, ... for the angled adjacencies between layers.

The "Upward" direction matches any site with greater z value.
The "Downard" direction matches any site with smaller z value.

The adjacency between sites in different layers depends on the packing. If using the (layers ...) ludeme then yes same (x,y) on layer above and below are adjacent. But if you use a square pyramidal packing (e.g. (square 4 pyramidal:true) as in Spline.lud) then the diagonal neighbours on consecutive layers are adjacent, i.e. spheres that would touch in a full packing are considered adjacent.

The (makeFaces <graph>) ludeme creates all non-overlapping faces within the given graph. So for 3D graphs this will include 3D faces (which may not necessarily be planar polygons!). It might make sense to have an option to only find "flat" faces within each layer of 3D games.

Not sure about the layer regions or specific placement of pieces in layers... Eric can you advise?

To be honest, the (layers ...) mechanism is largely untested, please let us know if you find any glitches or ways to improve it.

Regards,
Cameron


RE: <layers> and <layer> ludemes - QuaGamer - 11-12-2020

Thanks for the example. I will test out (layers ...) on a 3x3x3 version of Qua and let you know what I learn. I will see if I can understand the Debug print outs :-)


RE: <layers> and <layer> ludemes - Eric Piette - 11-12-2020

Hi,

for

"How do I specify regions that cross layers that belong to the three players in "Qua"?
Would this work:
(regions P1 { (sites N) (sites S) } )
(regions P2 { (sites E) (sites W) } )
(regions P3 { (sites U) (sites D) } )
?"

I am not sure nether of what you are trying to do? Can you give me more details?

Regards,
Eric


RE: <layers> and <layer> ludemes - QuaGamer - 11-12-2020

(11-12-2020, 10:45 AM)Eric Piette Wrote: Hi,

for

"How do I specify regions that cross layers that belong to the three players in "Qua"?
Would this work:
    (regions P1 { (sites N) (sites S) } )
    (regions P2 { (sites E) (sites W) } )
    (regions P3 { (sites U) (sites D) } )
?"

I am not sure nether of what you are trying to do? Can you give me more details?

Regards,
Eric
I am trying to create two regions for each of three players that need to be connected to win. They are opposite faces on a 3D cube, e.g., 3 layers of a 3x3 square. I want something like:
    (regions P1 { (sites Top) (sites Bottom) } ) -- across all three layers, probably using the (layer of: <int> [<siteType>]) ludeme with (and ...) for both Top and Bottom. This would be the y1 and y3 sites of the 3x3x3 cube.
I want the two regions corresponding to opposite faces of the 3D cube identified as the regions to be connected.

    (regions P2 { (sites Left) (sites Right) } ) -- same as for Top and Bottom, indicating the x1 and x3 sites of the 3x3x3 cube
    (regions P3 { (layer of: 1) (layer of: 3) } ) -- indicating the z1 and z3 sites of the 3x3x3 cube

Does this make sense?


RE: <layers> and <layer> ludemes - Eric Piette - 11-12-2020

Hi,

yes I never tried that with a 3D games, but I checked and we do not have a (sites Layer ...) ludeme. 
So with the current version you can not. I am going to add that to our dev version to publish it with the next release.

Regards,
Eric


RE: <layers> and <layer> ludemes - QuaGamer - 11-12-2020

Thanks Eric!

To use words similar to Top, Bottom, Left and Right, I suggest
“High” and “Low” if you don’t already have names for these layers.

Also, please make sure when layers are used for the Board graph, 
that Top, Bottom, Left and Right include sites that are the side cells 
in all the layers.


RE: <layers> and <layer> ludemes - QuaGamer - 11-12-2020

Regarding names of sites for cell regions, ideally "Top" would correspond to Up instead of North and "Bottom" would correspond to Down instead of South. If you ever want to change this, I recommend doing it sooner rather than later, when fewer .lud files are affected.

If you do make a change in the meaning of "Top" and "Bottom" I suggest "Front" for South and "Back" for North.


RE: <layers> and <layer> ludemes - QuaGamer - 11-13-2020

(11-12-2020, 10:09 AM)cambolbro Wrote: Here's a 3x3x3 version of Tic-Tac-Toe using layers:

(game "Graph Test - Layers (Square, 3x3)" 
    (players 2) 
    (equipment {
        (board
            (layers 3 (square 3))
        )
        (piece "Disc" P1)
        (piece "Cross" P2)
    }) 
    (rules
        (play (move Add (to (sites Empty))))
        (end (if (is Line 3) (result Mover Win)))
    )
)

<snip>

To be honest, the (layers ...) mechanism is largely untested, please let us know if you find any glitches or ways to improve it.

Regards,
Cameron
I loaded this test of the (layers ...) ludeme .lud file.
It compiles ok but doesn't play well.
There is no way to pick the layer for your move. It plays on layer 0 if the location on the 3x3 square is blank. You can then play over it, but only on layer 1. If a piece is on layer 0 and layer 1, then you can play on layer 2 at that location.
Random will play on Random layers.

There needs to be an isometric view of the 3D game board, and a way to keyboard enter a move.

In playing the game, I created a diagonal win on A3/0 + B3/1 + C/2 but the Ludii player didn't recognize the win. It looks like the (is Line 3) boolean function only looks at lines within a layer and does not consider lines going UW, DE, etc.

So, yes, the implementation of the (layers ...) ludeme needs work. Please let me know if there is something I can do to help. I understand if this is a "back burner" low priority item since your focus is on historic games, which did not use 3D game boards.