if (gX==0) { if (gY==0) addG=14; ...
You're permitting 9 successor nodes from the current node (gX=(-1,0,1),gY=(-1,0,1)), with the (gX=0,gY=0) equating to the current node. Thus, you're permitting a node to be a child of itself in your search tree. That's fine, except that you're adding a movement cost of 14 to this 'null move'. If you're going to permit not moving as a valid move, then it should have a 'g' cost of 0. Personally, I'd simply omit this move form the action set.
There may be more problems, but I haven't gotten that far into the code yet.
Cheers,
Timkin