Revert PHQ-2

No clear advantage again standard, possibly we will
retest before to release.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Rearrange structs to avoid internal padding

Found with gcc -Wpadded gcc option.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Remove MSVC debug window hack in bench

Interference with profile-build under mingw

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Introduce and use struct MoveList

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Restore startpos_ply_counter() instead of full_moves()

And pass correct currentPly to TimeManager::init().

This restores old behaviour, in particular now black has
a different timing than white becuase is no more:

currentPly = 2 * fullMoveNumber;

but becomes

2 * (fullMoves - 1) + int(sideToMove == BLACK)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Retire move_is_short_castle() and move_is_long_castle()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use MoveList also in Position::move_is_pl_slow()

And rename it in Position::move_is_legal()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Teach to_fen() about Halfmove and Fullmove number

And also fix the last '/' at the end of the piece placement field.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Fix icc's "unreachable code" warning

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Use std library to sort moves

Functional change due to the fact that now pick_best() is
stable, but should be no change in strenght.

Example code and ideas by Rein Halbersma.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Cleanup handling of Delta enums

Ispired by Rein's code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Fix parametrized direction in pawns generation

It worked by accident because we always called both directions,
but definition was wrong.

Functional change due to different generation order, but
perft numbers are the correct ones.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Fix a warning under MSVC

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
No need to declare default Position c'tor

Pointed out by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Simplify and micro-optimize hidden_checkers()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Simplified discovered check connected_moves()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Change hidden checkers API

After previous patch is no more needed to pass
the color, becuase it is always the side to move.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Don't need to assert for pos.is_ok() when position is constant

It's only necessary to do the checking at the end of every non-const
member (including the constructors and from_fen()) of class Position.
Once the post-condition of every modifier guarantees the class invariant,
we don't need to verify sanity of the position as preconditions for outside
callers such as movegen, search etc. For non-class types such as Move and
Square we still need to assert of course.

Suggested by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Remove some useless include

Spotted by Rein Halbersma.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Validate input UCI moves

Running following command:

  position startpos moves e1e8

Makes SF to assert in debug mode in do_move() but to accept
bad input and continue in release mode where probably it is
going to crash little later.

So validate input before to feed do_move().

Suggestion by Yakovlev Vadim.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>