Reformat max_threat()

Helper function should just know how to find the
biggest piece type in a bitboard. All the threat
logic and data shoud be in evaluate_threats().

This nicely separates the scope of the two functions
in a more consistent way and simplifies the code.

No functional change.
Please check again the logic. In case there is no QUEEN in 'target' loop
condition is false, the loop exits immediately and 'return pt;' is never
executed.


On Sat, Oct 25, 2014 at 4:37 PM, Gary Linscott <notifications@github.com>
wrote:

> In src/evaluate.cpp:
>
> >
> > -    PieceType threat = PAWN;
> > -    if (targets & pos.pieces(Them, KNIGHT))  threat = KNIGHT;
> > -    if (targets & pos.pieces(Them, BISHOP))  threat = BISHOP;
> > -    if (targets & pos.pieces(Them, ROOK))    threat = ROOK;
> > -    if (targets & pos.pieces(Them, QUEEN))   threat = QUEEN;
> > -
> > -    return threat_values[threat];
> > +    PieceType pt;
> > +    for (pt = QUEEN; !(target & pos.pieces(C, pt)); --pt) {}
>
> Why not:
> for (pt = QUEEN; target & pos.pieces(C, pt); --pt) return pt;
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/official-stockfish/Stockfish/pull/74/files#r19375765>.
>