So I'm doing a search method and my HashSet<GameBoard> explored
has all the explored states. I need to add more states to "explored" so I don't check the same state over and over again. I need to compare states with a copy of itself and if the VALUE of them are the same, I don't check it again.
I know I have to override the .equals()
method in Obj class for it to do a deep search and I did just that. Below is my equals method.
public boolean equals (GameBoard a){
for(int j = 0;j < a.len;j++){
if(a.boardArr[j] != this.boardArr[j]){
return false;
}
}
return true;
}
I add GameBoard to explored using explored.add(state);
. But this doesn't seem to do anything. I even commented out the equals method completely and the result is the same. It keeps adding the same state to the explored state and hence I have an infinite loop. Really need some help here does anyone know how to solve this?