I need help to my tic-tac-toe code, which is meeting error when try to run test
Hi everyone, I'm new here. I'm here now for asking help to my project. I want to finish it to add it to my resume/CV. It's a project about tic tac toe game, and I trying to develop the logic code for computer to analyze and suggest the next best location for computer to play against human. I'm finished the code for logic and has designed a test to verify whether that analyze method work or not but I'm encouter an error I met for the first time when try to run that test:"A new guard page for the stack cannot be created". This error was raised when I run VerifyAnalyzerWorkAsExpected test method. This is the link to my github repository:https://github.com/SparrowWithBrokenWing/Tic-Tac-Toe-game . Please help.
GitHub
GitHub - SparrowWithBrokenWing/Tic-Tac-Toe-game: Tic Tac Toe game
Tic Tac Toe game. Contribute to SparrowWithBrokenWing/Tic-Tac-Toe-game development by creating an account on GitHub.
21 Replies
this is the image when I try to debug the test
does anyone know anything about this?
Look at the call stack at the bottom right. It shows there's a function being called a ton, hinting at a recursion issue
Though typically the stack overflow would occur during the recursion, regardless, going 894 levels deep for tictactoe doesn't seem right
Also prefer not to use recursion, everything can be replaced with a while loop.
That way you also do not get a stackoverflow exception
Thanks so much, I actually found where the error come from. I'm still trying to fix it because it come from how I have design the code
Yes, that is because I have called in get property the value of that property itself which became endless loop. Now I'm struggeling with this bug and don't know how should I fix thit.
What does the property look like?
Should I send you the file?
It's hard to describe
so this is the file
I have made some change yesterday, and now when I run this test it don't look like to complete and I don't know the reason.
Just the bits that are relevant
And to describe the situation, you can imagine like this: "
public abstract class AbstractTest {
public AbstractTest() {
AbstractMethod();
}
public abstract void AbstractMethod();
}
public class Implement1 {
public Implement1(object obj) { Obj = obj; }
protected object Obj {get; set;}
public override void AbstractMethod() { // do something that require Obj property here }
}"
What lines are these on?
the problem is in PredictedNextMoves property in AbstractTree class (Line 99)
it may relevant with other code, I don't know. Maybe.
The previous problem I have solved like that but it's strange that the code won't work...
I think visual studio have live code which can connect between people on a project
Can you help me at this please? We can connect via live test and try to find what's the issue?
sorry, live share
not live test
Sadly it's getting late here I can try looking at it again tomorrow
No it's ok. Thanks for your look at my code.
I hope I can find what is the issue to solve it.
Thanks a lot!
Also worth posting the exact stack frames that are getting repeated for reference
I'm very fresh so I don't understand what are you trying to say for me but I will search on google and update information to ask help soon
From the call at the bottom like before where it says frames are getting repeated 894 times, you can get the frame info from there. Whenever a function is called, it gets pushed to the call stack, creating a frame that in debug, appear with the function name in it
Hence the stackoverflow. The stack is finite so entering a recursive loop can lead to too many stacks, eceeding the stack limit
Yes, i see that too. I realize that in the old code, the get method of property PredictedNextMoves have call to another method call Growth which call to get method of PredictedNextMoves property. This is the reason why the old code meet the stackoverflow error.
In the new code, I design it so that the Growth method only be called iff _predictedNextMoves field is null which also mean _predictedNextMove isn't completely initialized. (Sr, my eng is bad)
Now when I try to run the test, i get blue screen window with code about memory management. In my calculation, the tree will be expanded with 543 node because there is 4 moves was played and for each played move, the next possible move reduce by 1 and I only design so that the height of tree won't pass (3-2)*2+1=2 height which 3 is the number of moves need to complete a line and that formula is needed move to look ahead to block any fork move in future. I design the computer so it can only look that far.
I'm still finding what is the issue here. I hope you can help me find that issue too. Please ask if you want to know anything.
It seems very complex, you should maybe reconsider your architecrure
I'm also struggling to wrap my head around it to find the issue
Yes, i understand. For new, i have fixed the error that i posted. Now I struggling with an other error, not runtime but the semantics, I think. The code don't give me expected result.
So can I ask for some 30 minutes of you?
I really need help at this point.
At this point, I'm thinking about give up. I don't know what really the issue here. I think i will add it to my cv and note that it isn't complete. Hope the recruiter will accept that.
I will try to explain evreything in the wiki of repository. I hope it will help my project a little better in my CV.
Although I'm in Vietnam and don't follow any religion, but I hope god bless you. Thanks for your help to this point. I'm really appreciate that.
I want to keep this post a little longer, until I think I know someone will share what am I feeling right now. It's hard to accept that you cannot complete what you have done. My heart feel so strange at this point. Future is so dark and calm. Hope you don't read this message.