Ludii Forum
Swap rule causing game to end - 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: Swap rule causing game to end (/showthread.php?tid=123)



Swap rule causing game to end - AlekErickson - 08-11-2020

I have posted the game Trike.lud to the "upload new games" subforum, but there is a really strange bug where if P2 decides to invoke the swap rule, they automatically lose. I tried to circumvent this with an "(and" to check if it is not the first turn before triggering endgame, but the problem I suspect is that there are no LinesOfSight coming from a Swap. Is there a way to make "last To" not include Swap, or if it doesn't, a way to tell the computer that Swap is actually a Move, so it shouldn't trigger endgame. Here is my attempt to fix this , but it didn't work. 

(game "Trike"
(players 2)
(equipment
{
(board (hex triangle <Board>))
(piece "Ball" Each)
}
)

(rules
(meta (swap))
(play
(if (= (count Moves) 0)
(move Add (to (sites Empty)))
(move Add (to (sites LineOfSight Empty at:(last To)))
(then
(if
(and
(!= (count Turns) 2)
(= (count Sites in:(sites LineOfSight Empty at:(last To))) 0)
)
(addScore Mover 1)
)

)
)

)
)

(end
(if
(and
(= (count Sites in:(sites LineOfSight Empty at:(last To))) 0)
(!= (count Turns) 2)
)
(byScore
{
(score P1 (+ (score P1) ("Nbors" (last To) P1)))
(score P2 (+ (score P2) ("Nbors" (last To) P2)))
}

)

)
)
)
)


RE: Swap rule causing game to end - Eric Piette - 08-11-2020

I answered to you in the forum where you posted the game :)

Regards,
Eric Piette


RE: Swap rule causing game to end - AlekErickson - 08-11-2020

(08-11-2020, 11:55 AM)Eric Piette Wrote: I answered to you in the forum where you posted the game :)

Regards,
Eric Piette


Thank you Eric! 

Actually, I have tried your code and it still ends the game the moment P2 tries to swap...