Ludii Forum
Mixing up Cell and edge indexes - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Ludii Player Problems (https://ludii.games/forums/forumdisplay.php?fid=6)
+--- Thread: Mixing up Cell and edge indexes (/showthread.php?tid=662)



Mixing up Cell and edge indexes - dale walton - 08-01-2021

On a 4x4 square grid default Cell board

In N-Meshed game - used to scan to remove unneeded markers stacked on edges after Cell placements


this compiles and works: (but not how it needs to for my purpose)
(forEach Site
 (sites Incident Edge of:Cell at:(last To))
 (apply if:(= (mover) (who Edge at:(site)))
  (remove Edge (site) level:(where Level (id "Line" Mover) Edge at:(site)))
))



This gives an index out of bounds error when compiling  (- due to mixing up Cell and Edge indexes)
(forEach Site
 (sites Incident Edge of:Cell at:(last To))
 (apply if:(= (mover) (who Edge at:(site) level:0))
  (remove Edge (site) level:0)
))


java.lang.ArrayIndexOutOfBoundsException: Index 18 out of bounds for length 16
at game.functions.ints.state.Who.eval(Who.java:92)
at game.functions.booleans.math.Equals.eval(Equals.java:114)
at game.rules.play.moves.nonDecision.effect.Apply.eval(Apply.java:90)
at game.rules.play.moves.nonDecision.operators.foreach.site.ForEachSite.eval(ForEachSite.java:82)
at game.rules.play.moves.nonDecision.operators.logical.Or.eval(Or.java:152)
at game.rules.play.moves.nonDecision.operators.logical.Or.eval(Or.java:152)
at other.move.Move.apply(Move.java:501)
at game.rules.play.moves.nonDecision.effect.requirement.Do.movePassesCond(Do.java:275)
at game.rules.play.moves.nonDecision.effect.requirement.Do.eval(Do.java:110)
at game.Game.moves(Game.java:2596)
at other.context.InformationContext.moves(InformationContext.java:334)
at app.views.tools.buttons.ButtonPass.isEnabled(ButtonPass.java:65)
at app.views.tools.ToolButton.getButtonColour(ToolButton.java:206)
at app.views.tools.buttons.ButtonPass.draw(ButtonPass.java:44)
at app.views.tools.ToolView.paint(ToolView.java:117)
at app.display.MainWindowDesktop.paintComponent(MainWindowDesktop.java:184)
at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074)
at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5255)
at java.desktop/javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:246)
at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1323)
at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5203)
at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5013)
at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:865)
at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:848)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:848)
at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:823)
at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:772)
at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1890)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Note:
(apply if:(<= 0 (where Level (id "Line" Mover) Edge at:(site)))
Did not detect the condition correctly, which is why I tried with (who


RE: Mixing up Cell and edge indexes - dale walton - 08-01-2021

I also tried this and got a syntax error....?

Unexpected syntax 'level:Top' in '(remove Edge (site) level:Top)'.


RE: Mixing up Cell and edge indexes - Eric Piette - 08-18-2021

What is N-Meshed game ? It is not in our library as far I can tell?