Skip to content
Advertisement

Heuristic function ivalidating iterative deepening

For a Mancala game, I’m writing an iterative deepening algorithm. This is the code:

JavaScript

I also supply a heuristic function, given by board.scoreHeuristic(). This is essentially the players differnce in score divided by the total amount possible to win with. In this version of Mancala, this should be 72 (12 pits, 6 ambos in each pit). I understand that this is impossible, but almost, anyway.

My code occassionally runs into an infinite loop, and I believe that the issue is the heuristic, which some times returns 0. I cannot understand why this infinite loop happens.

Advertisement

Answer

Turns out, as many Java programmers know, that clone() is not the same as assigning arrays in a clone… For other programmers out there who are not aware (such as myself..):

This

JavaScript

Is supposed to be this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement