Hi all,
I’m writing a board game and currently implementing the AI using the standard Negamax. This algorithm calls itself recursively.
To speed up things I implemented a makemove/undomove within the function and I don’t pass the board object as a parameter to itself. However, due to the nature of Java not passing objects by reference, the changes to the board state when going deeper into the recursion are also reflected into the upper levels.
When I just copy the board state every time, the function works fine because each recursion works on a new copy based on a copy of one level above it. In this case I do have to pass the board state copy as a parameter and this copy copied immediately.
This has serious issues because as I hit a depth of 6 the search slows down considerably. So I’d rather have the move/undo functionality to speed up things.
So my question is: Is it possible in Java, and if yes, how? Or am I restricted to copying the board each and every time with serious performance issues?
Thanks,
C