Tasnu Arakun
2006.08.24, 03:59 PM
I've written a, for the time being, very simple AI for the game of Chinese chess (XiangQi) in Cocoa/Obj-C. It uses iterative deepening with alpha-beta pruning.
The game board representation is stored within an object "board". At first I cloned the board every time it was to be changed, i.e. for every move calculated by the AI. It worked but was terribly slow. Now I use only one object which instead keeps a stack of previous moves.
Now for some reason the game crashes when it reaches the 3rd ply (not immediately but after about 40 evaluations). Then Xcode loads the program into the debugger to show me where it failed. But the thing is, I simply cannot figure it out. The line is within my evaluation code where it calls the board asking for pieces. Before the crash this method has been called about 600 - 800 times. The board object is retained and stays in memory all time. I've tried making other method calls but with the same result.
Why would a normal method call suddenly and unexpectedly cause a crash? I'd be happy if someone could give me a clue as to where I should start looking.
The game board representation is stored within an object "board". At first I cloned the board every time it was to be changed, i.e. for every move calculated by the AI. It worked but was terribly slow. Now I use only one object which instead keeps a stack of previous moves.
Now for some reason the game crashes when it reaches the 3rd ply (not immediately but after about 40 evaluations). Then Xcode loads the program into the debugger to show me where it failed. But the thing is, I simply cannot figure it out. The line is within my evaluation code where it calls the board asking for pieces. Before the crash this method has been called about 600 - 800 times. The board object is retained and stays in memory all time. I've tried making other method calls but with the same result.
Why would a normal method call suddenly and unexpectedly cause a crash? I'd be happy if someone could give me a clue as to where I should start looking.