Ludii Forum
Shared piece movement. - 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: Shared piece movement. (/showthread.php?tid=102)



Shared piece movement. - ccxvii - 07-31-2020

I thought I'd try implementing Martian Chess (the pyramid game) in order to experiment with this very fascinating system, but I have run into a stumbling block: how to do movement of shared pieces.

I first tried something like this (equipment ... (piece "Queen" Shared (move Slide)) ... but then the (play (forEach Pieces)) would never show any available moves.

So then I tried coding the moves for each piece in the (play) section, but I'm having trouble getting the movement logic to work. I can't use the Step or Slide ludemes, since they throw null pointer exceptions at me. Maybe they can't handle from:(sites ...) rather than a singular site? The only thing I could get to work is (move <from> <to>) like this:

(move
(from (intersection (sites Mover) (sites Occupied by:Shared component:"Pawn")))
(to (sites Direction from:(from) Diagonal stop:(and (is Occupied at:(to)) (is In (to) (sites Mover))) distance:1)))

In Martian Chess, piece ownership is defined by where on the board they are located. This means I can remove a piece if it is moved into an opposing region, and add a new matching opponent piece at the same location. I feel there must be a more elegant solution hiding somewhere, though.

Are there any consideration of open sourcing the code? It would help immensely in trying to figure out what the ludemes do, since the documentation is a bit lacking in detail at points.


RE: Shared piece movement. - cambolbro - 07-31-2020

Hi,

Have you defined a "Queen" for the Shared player in the equipment? If not, you'll probably need to, otherwise the Game object will have no record for this piece.

You should be able to assign a fromSadsites ...) item so I'm not sure what's going wrong there. Maybe because you don't have a Shared "Queen" defined? 

The best person to advise on the move descriptions would be Eric who wrote most of the movement code, but unfortunately he's on holidays for another week.

Regarding open source, there are no current plans for releasing the core ludeme code, but the AI and features code is publicly available.

Have you tried the Ludii editors? Right click on keywords in the game descriptions to bring up help for the token and a list of replacement selections.

Regards,
Cameron


RE: Shared piece movement. - ccxvii - 07-31-2020

This is my first test program, that defines a "Queen" piece and its moves as Shared, but results in no possible moves:

Code:
(game "Test Shared Pieces"
    (players 2)
    (equipment
        {
            (board (rectangle 8 4))
            (piece "Queen" Shared (move Slide))
        }
    )
    (rules
        (start
            {
                (place "Queen" {"D2" "D1" "C1"})
                (place "Queen" {"A8" "B8" "A7"})
            }
        )
        (play (forEach Piece))
        (end (if (no Moves Next) (result Mover Win)))
    )
)



RE: Shared piece movement. - paulboes - 11-02-2020

(07-31-2020, 03:18 PM)ccxvii Wrote: This is my first test program, that defines a "Queen" piece and its moves as Shared, but results in no possible moves:

Code:
(game "Test Shared Pieces"
    (players 2)
    (equipment
        {
            (board (rectangle 8 4))
            (piece "Queen" Shared (move Slide))
        }
    )
    (rules
        (start
            {
                (place "Queen" {"D2" "D1" "C1"})
                (place "Queen" {"A8" "B8" "A7"})
            }
        )
        (play (forEach Piece))
        (end (if (no Moves Next) (result Mover Win)))
    )
)


Hey, has this ever been cleared up? I have the same problem (wanting to define pieces that each of the players can control in their turn). I tried the above logic with several roletypes (All, Neutral, Shared, Any, Mover) in the Language Reference Document but none of them seems to work.Thanks


RE: Shared piece movement. - Eric Piette - 11-03-2020

Hi,

The description for a such shared piece with moves defined in them is for example


Code:
(piece "Disc" Shared (move Slide))


(play (forEach Piece Shared))


   

Unfortunately, I just notice that they are triggered an exception in the current version, I already fixed it in our dev version and that will be published in the next release.

Regards,
Eric