Ludii Forum
Trying to define a cooperative game using set Team. - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Grammar Problems (https://ludii.games/forums/forumdisplay.php?fid=24)
+--- Thread: Trying to define a cooperative game using set Team. (/showthread.php?tid=1643)



Trying to define a cooperative game using set Team. - dale walton - 08-14-2023

In order to cooperatively test for cycles in a 2 player game, I used:


(rules
  (start (set Team 1 {P1 P2}))

....
 
(end
  {
   (if
    (or
      (is Connected at:(last To) Orthogonal Mover)
      (is Connected at:(last From) Orthogonal Next)
    )
    (result Team1 Loss)
   )
   (if (is Repeat Situational) (result Team1 Win))
  }
)


However, the game did not end when the connection was detected even thought it was highlighted on the connecting turn (-- and the AI did not appear to be trying to avoid connecting.)  
Instead it continued until no moves were left and declared no winners or losers.
Since you do puzzle solving, in Ludii why doesn't this way of creating a cooperative game work?


RE: Trying to define a cooperative game using set Team. - fuerchter - 08-14-2023

Hi dale,
this is just a blind guess, but could this be related with what was discussed here, mainly (is Connected Next) only working in very specific circumstances?


RE: Trying to define a cooperative game using set Team. - dale walton - 09-07-2023

I think the issue may be how Next is defined at the end of a game.  If there is a moveAgain next has already been updated to Mover, and the same might also happen for a forced pass.  (- 3 (mover)) solves this problem, but (is Connected) only takes a role - and I doubt it accepts  NonMover or Enemy They cause runtime index errors
Exception in thread "Thread-16" java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 3
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at game.functions.booleans.is.connect.IsConnected.eval(IsConnected.java:175)
at game.functions.booleans.math.Or.eval(Or.java:82)
at game.rules.end.If.eval(If.java:78)
at game.rules.end.End.eval(End.java:93)
at game.Game.applyInternal(Game.java:3060)
at game.Game.apply(Game.java:3003)
at game.Game.apply(Game.java:2947)
at search.minimax.AlphaBetaSearch.iterativeDeepening(AlphaBetaSearch.java:354)
at search.minimax.AlphaBetaSearch.selectAction(AlphaBetaSearch.java:228)
at other.ThinkingThread$ThinkingThreadRunnable.run(ThinkingThread.java:188)
at java.base/java.lang.Thread.run(Thread.java:829)

The following managed to show all the connections, except it ignored the end condition because there was only one team, and then finally stopped showing the connections during the forced double pass ending.


  {
    (if
    (or
      (and
      (is Mover P1)
      (or
        (is Connected at:(last To) Orthogonal P1)
        (is Connected at:(var "LF") Orthogonal P2) // at:(last From)
      ))
      (and
      (is Mover P2)
      (or
        (is Connected at:(last To) Orthogonal P2)
        (is Connected at:(var "LF") Orthogonal P1) //at:(last From)
    )))
    (result Team1 Loss)
    )
    (if (is Repeat Situational) (result Team1 Win))
  }

My main point was to see it a game could be converted into a puzzle to solve for cycle seeking by using an ending defined for a single team that includes both the players.
But the result is  game won by no one, rather than team 1 loses (or wins)  It means it doesn't see a distinction between both players winning and both players losing, so it can't seek to solve the problem this way.

However I finally got this to find a cycle by introducing a third player that always passes and redefining the loss for team 1 as a win for P3 (ie Team2). This caused the AI to find a situational repeat (cooperative cycle) on an order 5 Resolve board.