Ludii Forum
(and causing duplication? - 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: (and causing duplication? (/showthread.php?tid=445)



(and causing duplication? - dale walton - 02-21-2021

In a version of Equi I am now getting:

WARNING: Move [[SetScore:player=1,score=-10,add=true], [SetPending:value=28], [Move:typeFrom=Cell,from=27,typeTo=Cell,to=29,decision=true], [RememberValue:name=nullvalue=28], [SetPending:], [SetNextPlayer:player=2], [Remove:type=Cell,to=28], [SetPending:], [SetNextPlayer:player=2], [Add:type=Cell,to=28,what=4], [SetPending:], [SetNextPlayer:player=2], [SetScore:player=2,score=10,add=true], [SetPending:], [SetNextPlayer:player=2]] is duplicated in the legal moves.

When a second hop is taken. It appears to be coming from the (moveAgain) at the bottom of this define:

(define "GeneralHop"  // argument where from, who's sites, piece type hopped, piece typ replaced
(forEach Piece "Disc"
  (move Hop #1
  (between
    if:(is
    In
    (between)
    (difference
      (intersection
      #2
      (sites Occupied by:All component:#3)
      )
      (sites (values Remembered))
    ))
    (apply
    (and
      (addScore (player (who at:(between))) (- #5))
      (set Pending (between))
  )))
  (to if:(is Empty (to)))
  )
  (then
    (and
    {
      (remember Value (value Pending))
      (remove (value Pending))
      (if #7
      (and
        (add (piece (id #4 Mover)) (to (value Pending)))
        (addScore Mover #6)
      ))
    }
    (then
    (and
      (set Pending)
      (moveAgain)
))))))


When I change to:

  (then
    (set Pending
     (then (moveAgain))

The moveAgain does not execute.

When I change to
   (then
     (moveAgain (then (set Pending)))

I get a syntax error.

I have seen before that (and () () (then ...) causes duplicated execution of the contents in the then.  Usually this doesn't matter (except for slowing things down, but sometimes it does.  In this case, your new warning has detected it.

Is it executing the (then  as both an element of the (and, and as a proper (then) ?
Or, as I suspect is it executing one copy of the (then) for each of the moves in the (and) 9in this case there are 3 or 4 moves under the and, depending how the (and) nested inside the (if) is treated. - and there are 4 executions of the (set Pending)+(moveAgain)


RE: (and causing duplication? - dale walton - 02-21-2021

A separate issue for the same define...

While using the AI, I suddenly got 6 identical warnings in a row:
WARNING: Move [[SetScore:player=1,score=-10,add=true], [SetPending:value=49], [Move:typeFrom=Cell,from=50,typeTo=Cell,to=48,decision=true], [RememberValue:name=nullvalue=49], [Remove:type=Cell,to=49], [Add:type=Cell,to=49,what=4], [SetScore:player=2,score=10,add=true], [SetPending:], [SetNextPlayer:player=2]] is duplicated in the legal moves.

After I had changed the code to read:

(define "GeneralHop"  // arguments where from, who's sites, piece type hopped, piece typ replaced, value hopped, value replaced, True if replaced.
(forEach Piece "Disc"
  (move Hop #1
  (between
    if:(is
    In
    (between)
    (difference
      (intersection
      #2
      (sites Occupied by:All component:#3)
      )
      (sites (values Remembered))
    ))
    (apply
    (and
      (addScore (player (who at:(between))) (- #5))
      (set Pending (between))
  )))
  (to if:(is Empty (to)))
  (then
    (and
    {
      (remember Value (value Pending))
      (remove (value Pending))
      (if #7
      (and
        (add (piece (id #4 Mover)) (to (value Pending)))
        (addScore Mover #6)
      ))
    }
  )))
  (then
  (and
    (set Pending)
    (moveAgain)
))))

I am attaching a cut/paste copy from the Ludeme tab of the player for your reference.

Separate? issue, after loading the trial back in, the tabs at the top of the main window didn't show and the controls for the game were mis-behaving, after clicking a few things the tabs came back and I tried restarting the game. the status tab window showed in progress but the game still showed the final position. restarting again cleared this up.

There are a lot of these scattered through the terminal oup put, but the output is long:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

I am most suspicious of the pair:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0

Here is the last many lines from my terminal that hopefully cover this period:

at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1889)
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)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.desktop/javax.swing.text.View.setParent(View.java:337)
at java.desktop/javax.swing.text.CompositeView.setParent(CompositeView.java:136)
at java.desktop/javax.swing.text.FlowView.setParent(FlowView.java:297)
at java.desktop/javax.swing.text.html.ParagraphView.setParent(ParagraphView.java:75)
at java.desktop/javax.swing.text.CompositeView.replace(CompositeView.java:192)
at java.desktop/javax.swing.text.BoxView.replace(BoxView.java:182)
at java.desktop/javax.swing.text.View.updateChildren(View.java:1130)
at java.desktop/javax.swing.text.View.removeUpdate(View.java:750)
at java.desktop/javax.swing.text.View.forwardUpdateToView(View.java:1239)
at java.desktop/javax.swing.text.View.forwardUpdate(View.java:1172)
at java.desktop/javax.swing.text.BoxView.forwardUpdate(BoxView.java:241)
at java.desktop/javax.swing.text.View.removeUpdate(View.java:756)
at java.desktop/javax.swing.plaf.basic.BasicTextUI$RootView.removeUpdate(BasicTextUI.java:1720)
at java.desktop/javax.swing.plaf.basic.BasicTextUI$UpdateHandler.removeUpdate(BasicTextUI.java:1980)
at java.desktop/javax.swing.text.AbstractDocument.fireRemoveUpdate(AbstractDocument.java:261)
at java.desktop/javax.swing.text.AbstractDocument.handleRemove(AbstractDocument.java:628)
at java.desktop/javax.swing.text.AbstractDocument.remove(AbstractDocument.java:596)
at java.desktop/javax.swing.JEditorPane.setText(JEditorPane.java:1422)
at app.display.views.tabs.TabPage.clear(TabPage.java:224)
at app.display.views.tabs.pages.MovesPage.reset(MovesPage.java:188)
at app.display.views.tabs.TabView.resetTabs(TabView.java:247)
at app.game.GameRestart.resetUIVariables(GameRestart.java:125)
at app.game.GameRestart.clearBoard(GameRestart.java:114)
at app.display.views.tools.ToolView.jumpToMove(ToolView.java:203)
at app.display.views.tools.buttons.ButtonStart.press(ButtonStart.java:95)
at app.display.views.tools.ToolView.clickAt(ToolView.java:150)
at app.display.MainWindow.checkPointOverlapsButton(MainWindow.java:334)
at app.display.MainWindow.mousePressed(MainWindow.java:350)
at java.desktop/java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:287)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6632)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
at java.desktop/java.awt.Component.processEvent(Component.java:6400)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4544)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
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.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
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:742)
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)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0
at java.desktop/javax.swing.plaf.basic.BasicHTML.getHTMLBaseline(BasicHTML.java:91)
at java.desktop/javax.swing.plaf.metal.MetalToolTipUI.paint(MetalToolTipUI.java:126)
at java.desktop/javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
at java.desktop/javax.swing.JComponent.paintComponent(JComponent.java:797)
at java.desktop/javax.swing.JComponent.paint(JComponent.java:1074)
at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
at java.desktop/javax.swing.JComponent.paint(JComponent.java:1083)
at java.desktop/javax.swing.JLayeredPane.paint(JLayeredPane.java:590)
at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:907)
at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5262)
at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(RepaintManager.java:1643)
at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1618)
at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1556)
at java.desktop/javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:262)
at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1323)
at java.desktop/javax.swing.JComponent.paint(JComponent.java:1060)
at java.desktop/java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
at java.desktop/sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
at java.desktop/sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
at java.desktop/java.awt.Container.paint(Container.java:2002)
at java.desktop/java.awt.Window.paint(Window.java:3940)
at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:876)
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)


RE: (and causing duplication? - Eric Piette - 02-22-2021

Hi,

I am not sure what to test for you here. Do you have a .lud?

Regards,
Eric


RE: (and causing duplication? - dale walton - 02-23-2021

OK for the last one see attached,


and I will try to reconstruct the earlier problems, since despite my working around them they are generally affecting other code.

----------------------------------
For the one above it in the same mail, converting the txt file to a .lud file should give you what you need.
OK, I have tried to reproduce it using that method, but it doesn't reproduce, so when I see it again I will send gain with better documentation...


RE: (and causing duplication? - dale walton - 02-23-2021

So in 1.1.15 I just re-ran the txt file from #2 post problem and here is the trial.  See attached .lud , .trl, and picture.

Hope you can reproduce.

I got the same problem. I am running A/B against A/B at 1s and the problem occurred more than once in the game. The particular  error shown here was early inthe game, but there were more as well.

Hope you can reproduce it.
Perhaps it is due to using both forms of set Pending in a move? - but they are not in the same action level.

BTW, this bug is not the bug in post#1 and thus not related to the title of the thread.


RE: (and causing duplication? - Eric Piette - 02-24-2021

Hi,

I run your .lud with the .trl and I do not get any exception or any problem with it.
So still not sure what to look here.

Regards,
Eric


RE: (and causing duplication? - dale walton - 02-24-2021

OK, I tried with the trial and don't see it either. But my experience is it happens frequently when running the AI. So it may be an AI problem as opposed to a script problem?

When I rerun it again using the AI it generates a new case.
Please try loading the game and setting the A/B AI to 1s each and seeing if the error shows up during the game.


RE: (and causing duplication? - DennisSoemers - 02-24-2021

I see several different problems/errors/warnings being described in several of the posts above, so I'm not 100% sure what you're referring to exactly twith "it" or "the error". Are you referring to actual problems or bugs in the game logic or AI behaviour, or just those exception traces being printed to the console?


RE: (and causing duplication? - dale walton - 02-24-2021

Take it as referring to exception traces to the status window when the AI is playing.  You know your code and why those traces are there. And I am assuming that they are there so that we can tell you when we see them...

As to the other bugs (post#1). It looks like you won't have time to figure out what they are, and  I have worked around them but when I have time aand think about it again, I'll try to send you a clear tested sample.

Basically I'm saying that (and (moveA) (moveB) (then (consequence))) executes the consequence twice, but the (then consequence) should be independent and occur after both moves A & B have finished. 

In comparison: -- With (or) if internally you translate that as moveA+then OR moveB+then it is OK,

but it is NOT OK to translate when using (and), to MoveA+then AND moveB+then,  precisely because the results of the (consequence) would occur twice with potentially different values at the same time! Both legs of the (and) must first be completed, before a consequence can be applied, as the consequence could independently depend on both of the legs..

If the system can't handle this, you need to remove (then) as an allowed part of (and) in the documentation. - But it would be useful if it worked.