Ludii Forum
Strange behavior with Back to Start - 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: Strange behavior with Back to Start (/showthread.php?tid=677)



Strange behavior with Back to Start - Quentin Cohen-Solal - 08-16-2021

Hello,

I noticed some strange behaviors (which causes crashes with my Ludii Player).

Pressing "Back to Start" makes a call to closeAI then initAI then closeAI then again initAI. What is the reason for this redundancy?

My current problem is not here, however.


Then press "Player / Pause", do a closeAI again, then do an initAI, followed by a selectAction with my program (it is first player), then the opponent plays (which is Ludii AI) then does a closeAI, followed by a new initAI followed of another selectAction.

Why is the Ludii Player closes my IA then init it again after each player has make a move?



Thank you for your help.


RE: Strange behavior with Back to Start - MatthewStephenson - 08-16-2021

Hi Quentin,

Thanks, we are aware of the fact that we frequently close and init the AI within different GUI functions. This is mostly to make sure that we never miss out on calling these when needed.

For the time being we would advise not running the AIs in the GUI is this is going to cause problems for you.

However, I will look into the pause/play issue specifically and see if I can determine the cause.

Cheers,
Matthew


RE: Strange behavior with Back to Start - MatthewStephenson - 08-16-2021

Hi Quentin,

I'm afraid I haven't been able to replicate your play/pause issue.

If I set up two UCT agents on Chess and click "Play", each agent is initialised once.
If I click the "Back to Start" button then both agents are closed and initialised twice (this is more than needed but is the same as what you said).
However, if I think click "Play" again, the agents are just each initialised once with no further calls to close the AI.

If you'd like us to look into this further, please send us your agent code and the name of the game where you experience this problem.

Cheers,
Matthew


RE: Strange behavior with Back to Start - Quentin Cohen-Solal - 08-16-2021

It is going to be complicated if I cannot use Ludii for the Olympiad. So that I know if this can cause me real problems for the Olympiad: at what times initIA and closeIA are called?

Apparently the strange behavior I'm talking about only arises with Biaised MCTS and MCTS (Biaised Selection) as an opponent, I tested with UCT, Alpha-Beta, Human and and almost all the others as an opponent and the problem does not arise. Can an AI (or just a base ludii AI) can trigger an init / close for each opponent? Or, Is only the ludii graphical interface that can? (but in this case, I do not understand the influence of the choice of AI on the occurence of the "bug").


RE: Strange behavior with Back to Start - DennisSoemers - 08-16-2021

Different AI objects really should be completely isolated, they should not have any references to each other. Certainly on of our AI classes (like our MCTS) should not be able to have a reference to your own custom AI classes, and I can't really envision how they would be able to trigger such method calls on your AI. Any such calls should happen through the GUI, and like you said, then the issue should be consistent regardless of which opponent AI there is.

We cannot replicate any such issue on our end, though there might be a possibility that some of our changes in the past few weeks (after our latest release) changed something there, so either way it'd be good to test again when we release a new version.

Just to be sure: how are you determining that these methods are being called on your specific AI? Are you doing it in a way that ensures that you only see if when there are calls really on your AI object, for example by putting prints in the overridden method in your own new, custom class? Or are you checking in some other way, like just counting how many initAI() / closeAI() calls there are on *any* AI object? Because in that case, you could definitely see more calls than you'd expect. Our Ludii AI is a wrapper around another AI object, so calls on a LudiiAI object will always get "duplicated" by it calling the same methods on its nested/inner AI. The Biased MCTS objects have SoftmaxPolicy objects inside them, which they in turn also call init/close methods on.


RE: Strange behavior with Back to Start - Quentin Cohen-Solal - 08-16-2021

When initIA is called, a log file is created. When closeIA is called, "close" is written in the log (using the overridden method in my own new, custom class).

The problem occurs in Canadian Draughts and Gomoku, I have not test with other games.


RE: Strange behavior with Back to Start - Quentin Cohen-Solal - 08-16-2021

I think I understood why you couldn't reproduce the problem. If my program receives a call from initIA when there has not previously been a corresponding call from closeIA, it calls closeIA. However, this does not explain everything, as there is always an initIA that is called during the game, for no apparent reason (after the first move has been made).

I made a reproducible example (use the ludii player in Attachment).

Load Game: Gomoku
Player 1 From jar [choose "ZEmptyPlayer"]
Player 2 Biased MCTS (Uniform Playouts))

Close and relaunch the Ludii application.
The log file contains "" "
nullZEmptyPlayer
"" "

Press "Player / Pause".
The log file contains "" "
supportsGame

initAI
selectAction
supportsGame

initAI
supportsGame
selectAction
supportsGame
supportsGame
selectAction
supportsGame
supportsGame
selectAction
supportsGame
supportsGame
selectAction

"" "

Press "Back to Start".
The log file contains "" "
closeAI

initAI
closeAI

initAI

"" "

Press "Player / Pause".
The log file contains "" "
supportsGame

initAI
selectAction
supportsGame

initAI
supportsGame
selectAction
supportsGame
supportsGame
selectAction
supportsGame
supportsGame
selectAction
supportsGame
supportsGame
selectAction

"" "

We can see here that there is an initIA during the game without any interaction with the ludii interface (with or without pressing "Back to Start"). I do not understand why I did not have a problem without the "Back to Start" with my Ludii Player.


RE: Strange behavior with Back to Start - DennisSoemers - 08-18-2021

That issue should be fixed in the next release (or, if you're working with code from github rather than the official JAR builds, it should already be fixed in our current dev branch).


RE: Strange behavior with Back to Start - Quentin Cohen-Solal - 08-18-2021

Thank you.