Ludii Forum
Paths built from vertices and edges - Printable Version

+- Ludii Forum (
+-- Forum: Problems (
+--- Forum: Grammar Problems (
+--- Thread: Paths built from vertices and edges (/showthread.php?tid=422)

Paths built from vertices and edges - xenos1984 - 02-07-2021

I just got an idea how to implement Projex without the need of specially adapted board geometries. Essentially, the idea is the following. Normally, Hex-like games such as Projex are played on the cells, and the goal is to connect cells. My idea is to play on the vertices of the dual graph instead, and to build a path by connecting the occupied cells with edges. This makes it easy to just represent the board as the graph where edges represent adjacency between sites, and to mark opposite sides of the Projex board as adjacent by adding edges between them. For Projex, the winning condition is then simply to create a closed path / loop which contains an odd number of edges connecting opposite sides.

For simplicity, I started out with a simplified Projex board which has only 6 sites, where each site represents a pair of opposite faces of a dodecahedron. Turning cells to vertices, this gives a projective icosahedron, where the graph is just a complete graph with 6 vertices. Also the winning condition is very simple: create a loop involving an odd number of "wrap around" edges which connect "almost opposite" vertices (the 5 edges forming the pentagram). On this board, the winning condition is to occupy two non-adjacent sites on the perimeter and one site between them to connect them (either the center site or another perimeter site). So far, so good.

My first attempt is attached. I run into two problems:

First, I try to add edges between if both vertices they connect are occupied by the mover. I thought I could achieve it this way:

(forEach Site # Find all sites around the last position which the mover already owns.
        (sites Around Vertex (last To))
        (sites Occupied by:Mover)
        (to Edge # Occupy the edge between last played and already owned vertex.
                (sites Incident Edge of:Vertex at:(site))
                (sites Incident Edge of:Vertex at:(last To))

However, in the fifth move of the attached trial an edge is added between a red (the last played) and a blue vertex, and I don't see the reason why this happens. Maybe I misunderstand the (sites Incident ...) ludeme, the documentation seems a bit unclear.

Another issue is with the winning condition. I'm still lacking an idea how to count the "wraparound edges" inside a path. A pointer in the right direction would be appreciated. (The attached file contains a "dummy win condition" so that I could focus on the move logic first.)

RE: Paths built from vertices and edges - Eric Piette - 02-08-2021


Your description is correct.
However I looked the code corresponding to: (sites Occupied by:Mover)
And I saw that for the case of a specific player but not specific pieces, the type of the graph elements was not taken in account. Consequently when a game with more than a single SiteType is used, the list returned the indices of all the elements occupied by the mover (so here the indices of the edges and vertices occupied) which obviously is a mistake. I fixed it in our dev version to return only the type in entry (the default is the default of the board, in your example the vertices).

So in the next release, your description should work as expected.


RE: Paths built from vertices and edges - xenos1984 - 02-12-2021

Thanks, that solved it! Now (only) the correct edges are marked.