09-07-2023, 07:58 AM
(This post was last modified: 09-07-2023, 08:36 AM by dale walton.)
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.
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.