This is just a kludge to not need separate recursion code for the revealed and unrevealed case. In the revealed case (be it for the mover or the victim) the do-while loops are started at the piece itself, wan will never do more than that. This makes the weight immaterial, as weights are only relative: the score is multiplied by w, but nr will also end at w, so after the loops the w will be divided out again.Daniel Shawul wrote:I have question about the weights. Why does the mover's unrevealed count go to the weight formula? If I understand correctly , that would mean that we prefer to capture with a our revealed pieces that have counts of 255. If we take a simple example where the opponent have a hidden Rook and Pawn, and then we made a capture of one of them the probabilities are 0.5 for each, and scores +5 and +1, for an average of 3. With 2 hidden rooks and 1 pawn, the probabilties will be 2/3 and 1/3, which again does not depend on the mover's type.
I thought unreveiled[] was a type for unrevealed[] but I see it is not.
So it really doesn't matter what the weigth of an outcome is when there is only a single outcome. This would also happen when all remaining unrevealed pieces are of the same type (e.g. 3 Pawns). As long as the weight is not 0, then w*score/w will just be score. The reason I wanted to set it to 255 was that it would be decremented before recursing, and you want it to stay safely away from 0.
This might be a stupid idea: for efficiency the division score/nr would probably have to be done through a lookup table for 1/nr, so it would be important to keep the range that nr can attain small. With all pieces unrevealed, nr could potentially sum to 15x15=225 (unrevealed pseudo-Cannon captures unrevealed pseudo-Horse as first move). A table of 226 inverses is afordable. But when revealed x revealed would lead to w=255^2, that would be nasty. So it would probably better to in the initial if(pieceType & UNREVEALED) test put an else-clause that would set unrevealed[pieceType] = 2;
