Page 1 of 1

AI: Couldn't find card in fromZone (Hand)

PostPosted: 31 Jul 2016, 16:26
by ShivaFang
I've started getting this warning repeatedly recently in my Monte Carlo AI when it simulates games. I have the nodes rebuild playable cards in hand each time and the AI was working without it. I'm not entirely sure what I did that caused this.

Is there any way to get a stack trace on it? It keeps popping up as a warning with absolutely no other information I can use.

This warning also seems to correspond with huge spikes in memory use (although that could be normal since Monte Carlo simulates many many games and creates nodes to remember results) it 'feels' like I get bigger spikes when this warning appears than when it doesn't, which is why I'm concerned about resolving it.

Re: AI: Couldn't find card in fromZone (Hand)

PostPosted: 31 Jul 2016, 21:19
by LevelX
Is this the exact test of the message?
I can't find such a text in the source code.

Re: AI: Couldn't find card in fromZone (Hand)

PostPosted: 31 Jul 2016, 23:56
by ShivaFang
I'm sorry, the exact message looks more like this;
Code: Select all
WARN  2016-07-31 17:52:39,728 Couldn't find card in fromZone, card=Anticipate [1b7], fromZone=HAND                       =>[GAME 49ba96a9-6439-47fe-a24e-c5072b9b7d5b] CardImpl.removeFromZone
the card name changes each time.

I suspect the warning is happening because the AI is trying to play a card that it doesn't actually have in hand (it simulates many games and each card it might play is one potential action.) The only time that really should be happening is if the opponent forces a discard, but it happens even when the opponent has nothing like that in their deck. And even then my nodes are 'rebuilding' the nodes available to play each time to account for something like that. This is why I would like a stack trace to try and figure it out.

Also, it used to work fine without the error messages. These just suddenly started happening.

Re: AI: Couldn't find card in fromZone (Hand)

PostPosted: 01 Aug 2016, 08:19
by LevelX
I would set a breakpoint to CardImpl->removeFromZone Line 558 to get at least a stack trace, when this happens. From this you can analyze more deeply, why this is happening.

Should be something like having not the correct game object in the context of AI simulation at that time, so the hand card the AI tries to play is not in hand.

Re: AI: Couldn't find card in fromZone (Hand)

PostPosted: 02 Aug 2016, 14:44
by ShivaFang
LevelX wrote:I would set a breakpoint to CardImpl->removeFromZone Line 558 to get at least a stack trace, when this happens. From this you can analyze more deeply, why this is happening.

Should be something like having not the correct game object in the context of AI simulation at that time, so the hand card the AI tries to play is not in hand.
How would I do that on already compiled code? Or do I have to compile the whole source in order to do that?

Re: AI: Couldn't find card in fromZone (Hand)

PostPosted: 02 Aug 2016, 20:43
by LevelX
Start the server from Netbeans in Debug mode.
Set the line breakpoint to the mentioned line.

As the server execution stops at that line you can look at the call stack and all variables you like.

It's just the common debugging.

LineBreakpoint.jpg