1
0
Fork 0
Commit Graph

320 Commits (riscv64-cartesi)

Author SHA1 Message Date
Marco Costalba aed542d74c When generating checks add possibly under-promotions
In qsearch at depth 0 we generate only captures and checks.
Queen promotion moves are generated among the captures, but
under-promotion moves (both captures and non-captures) are
never generated even if they could give a discovery check.

This patch fixes this limitation extending generate_pawn_noncaptures()
to generate also check moves when required.

Apart for adding the (rare) case of an under-promotion that gives
discovery check, the patch is also a good cleanup because removes
generate_pawn_checks() altoghter.

This patch does the code clean-up but not enables the functional
change so to allow an easier debug.

No functional change and no performance change (actually a very
very small speed increase).

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-22 07:07:17 +01:00
Marco Costalba aaffcf973e Fix a bug in generate_piece_checks()
We are generating also king moves that give check !

Of course these moves are illegal so are in any case
filtered out in MovePicker. Neverthless we should avoid
to generate them.

Also simplify a bit the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-22 07:07:16 +01:00
Marco Costalba 746bcb348f Small micro optimization in generate_evasions()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-22 07:07:16 +01:00
Marco Costalba e4277c06bf Rename piece_attacks_from() in attacks_from()
It is in line with attackers_to() and is shorter and
piece is already redundant because is passed as template
parameter anyway.

Integrate also pawn_attacks_from() in the attacks_from()
family so to have an uniform attack info API.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 14:55:28 +01:00
Marco Costalba 84d6fe0f31 Retire attackers_to(Square s, Color c)
Use the definition in the few places where is needed.

As a nice side effect there is also an optimization in
generate_evasions() where the bitboard of enemy pieces
is computed only once and out of a tight loop.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 10:47:59 +01:00
Marco Costalba 6845397c5c Rename piece_attacks() in piece_attacks_from()
It is a bit longer but much easier to understand especially
for people new to the sources. I remember it was not trivial
for me to understand the returned attack bitboard refers to
attacks launched from the given square and not attacking the
given square.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 10:26:54 +01:00
Marco Costalba f74f42b298 Cleanup piece_attacks_square() functions
Most of them are not required to be public and are
used in one place only so remove them and use its
definitions.

Also rename piece_attacks_square() in piece_attacks()
to be aligned to the current naming policy.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 10:12:56 +01:00
Marco Costalba 0e0adfe2e1 Rename attacks_to() in attackers_to()
These functions return bitboard of attacking pieces,
not the attacks themselfs so reflect this in the name.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 09:31:48 +01:00
Marco Costalba 049139d025 Change pawn_attacks() API
Instead of pawn_attacks(Color c, Square s) define as
pawn_attacks(Square s, Color c) to be more aligned to
the others attack info functions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 09:09:27 +01:00
Marco Costalba 62a8f393f1 Clean up API for attack information
Remove undefined functions sliding_attacks() and ray_attacks()
and retire square_is_attacked(), use the corresponding definition
instead. It is more clear that we are computing full attack
info for the given square.

Alos fix some obsolete comments in move generation functions.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-20 08:48:10 +01:00
Marco Costalba 9f28d8a854 Second take at unifying bitboard representation access
This patch is built on Tord idea to use functions instead of
templates to access position's bitboards. This has the added advantage
that we don't need fallback functions for cases where the piece
type or the color is a variable and not a constant.

Also added Joona suggestion to workaround request for two types
of pieces like bishop_and_queens() and rook_and_queens().

No functionality or performance change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-04 08:21:06 +01:00
Marco Costalba 76bed11f7b Templetize functions to get pieces by type
Use a single template to get bitboard representation of
the position given the type of piece as a constant.

This removes almost 80 lines of code and introduces an
uniform notation to be used for querying for piece type.

No functional change and no performance change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-09-04 08:21:05 +01:00
Marco Costalba 17c5119222 Retire pieces_of_color_and_type()
It is used mainly in a bunch of inline oneliners
just below its definition. So substitute it with
the explicit definition and avoid information hiding.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-08-31 16:23:04 +02:00
Marco Costalba 9e4befe3f1 Use pointers instead of array indices in MovePicker
This avoids calculating the array entry position
at each access and gives another boost of almost 1%.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-08-29 06:48:31 +01:00
Tord Romstad ae49677446 Fixed a bug in PV extraction from the transposition table: The
previous used move_is_legal to verify that the move from the TT
was legal, and the old version of move_is_legal only works when
the side to move is not in check. Fixed this by adding a separate,
slower version of move_is_legal which works even when the side to
move is in check.
2009-08-06 18:07:32 +02:00
Marco Costalba 3849beb979 Introduce SERIALIZE_MOVES_D() macro and use it for pawn moves
This is another moves serialization macro but this time
focused on pawn moves where the 'from' square is given as
a delta from the 'to' square.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-07-14 10:28:41 +01:00
Marco Costalba 20ed03fc0b Micro optimize pawn moves generation
It is very rare we have pawns on 7(2) rank, so we
can skip the promotion handling stuff in most cases.

With this patch pawn moves generation is almost 20% faster.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-07-14 10:28:29 +01:00
Marco Costalba a5fce1958b Fix generation of check blocking promotion
A promotion move is not considered a possible evasion as it could be.

Bug introduced by patch

Convert also generate_pawn_blocking_evasions() to new API (7/5/2009)

Bug spotted by Kenny Dail.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-07-06 09:41:22 +01:00
Marco Costalba 3a4d6e2034 Micro optimize and rename move_promotion()
Rename to move_is_promotion() to be more clear, also add
a new function move_promotion_piece() to get the
promotion piece type in the few places where is needed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-06-20 09:04:32 +01:00
Marco Costalba 8bec65029d Better clarify why recent generate_pawn_checks() works
We can have false positives, but these are filtered out
anyhow by following conditions so they are harmless.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-06-12 13:12:42 +02:00
Marco Costalba 3d0b60b065 Merge hardware POPCNT detection and use
Tests on Joona luxury iCore7 QUAD show that speed increase
against standrd 64bit routine is between 3% and 4%.

So it seems a good thing to have. Also the user feedback at
startup regarding the compile and the hardware detection can
be an useful debug tool.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-25 07:56:26 +01:00
Marco Costalba bdb1bfecfb Split killer moves from non-captures
In MovePicker consider killer moves as a separate
phase from non-capture picking.

Note that this change guarantees that killer1 is always
tried before killer2. Until now, because scoring difference
of the two moves was just 1 point, if psqt tables of killer1
gave a lower value then killer2, the latter was tried as first.

After 999 games at 1+0 we have
Mod vs Orig: +245 =527 -227 +6 ELO

Not a lot but patch is anyhow something worth to have.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-25 07:49:50 +01:00
Marco Costalba f1591447cf Revert _BitScanForward64 support
It shows almost no improvment and adds a good
bunch of complexity.

So remove for now. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-25 07:28:55 +01:00
Marco Costalba d63ff85a43 Add a bit more pop_1st_bit<HasBSF> conversions
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-24 10:25:59 +01:00
Marco Costalba 76024ac40e Use compiler name lookup to simplify code
We don't need different names between a function and a
template. Compiler will know when use one or the other.

This let use restore original count_1s_xx() names instead of
sw_count_1s_xxx so to simplify a bit the code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-24 10:18:31 +01:00
Marco Costalba 6c9a64124a Enable _BitScanForward64 in move generation
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-24 10:07:03 +01:00
Marco Costalba f90f810ac4 Enable _BitScanForward64 at runtime
Only add infrastructure, still disabled.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-24 09:46:43 +01:00
Marco Costalba 628f844c11 Fix compile errors under MSVC
Fallback from previous patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-21 17:08:34 +01:00
Marco Costalba 980124c609 Fix some Intel compilers warnings
Also a compile fix due to Makefile missing new
application.cpp file.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-09 12:09:25 +02:00
Marco Costalba 5f7d37273c Micro optimize generate_pawn_checks()
Use a better condition to find candidate direct check pawns.
In particular consider only pawns in the front ranks of the
enemy king, this greatly reduces pawns candidates bitboard
that now is empty more then 90% of the time so that we
can early skip further tests.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-08 10:56:59 +02:00
Marco Costalba be4ee0729d Convert also generate_pawn_blocking_evasions() to new API
New compact parameter passing API.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 17:08:55 +02:00
Marco Costalba 9fbe9af0a0 Better dscovery check condition in generate_pawn_checks()
Be more strict, is not enough dc bitboard is not empty, but
needs to inclde also at least one pawn.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 17:01:52 +02:00
Marco Costalba 1d15b38cd8 Further parametrize generate_pawn_captures
We can parametrize for the capture direction too.

Also use a single template parameter and calculate (at
compile time) remainin parameters directly in the function.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 16:41:36 +02:00
Marco Costalba 5c81602d14 Update copyright year
We are well in 2009 already.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-07 14:54:40 +02:00
Marco Costalba 46bb6c6dc3 Fix missing pawn color check in move_is_legal()
In case we have a correct white pawn move but pawn
is black (or the contrary) we fail to detect the
move as illegal.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-05-05 13:10:29 +02:00
Marco Costalba 7c267587fc Greatly speedup has_mate_threat()
Instead of loop across all legal moves to find a mate
loop across possible check moves only.

This reduces more then 10 times the number of moves to
check for a possible mate.

Also rename generate_checks() in generate_non_capture_checks()
so to better clarify what the function does.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-04-26 13:40:26 +01:00
Marco Costalba 24485c96ec Micro optimize generate_piece_checks() take 2
Add some missing bits of this patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-04-19 21:09:53 +02:00
Marco Costalba a52ab2afbf Micro optimize generate_piece_checks()
Avoid calculating piece attacks if there aren't
available check sqaures for the given piece.

About 15% of cases. Not a biggie but still something
especially in the middle game where king is well covered
inside his castle.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-04-18 16:28:12 +01:00
Marco Costalba e7f03913ea Introduce move_pawns() helper in movegen.cpp
This let us to have more readable code keeping the
same speed.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-04-18 09:13:31 +01:00
Marco Costalba c02613860a Revert hidden checkers rework
It is slower the previous uglier but faster code.

So completely restore old one for now :-(

Just leave in the rework of status backup/restore in do_move().

We will cherry pick bits of previous work once we are sure
we have fixed the performance regression.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-03-02 16:20:00 +01:00
Marco Costalba 1b0fee9b17 Remove two useless calls to pinned_pieces()
Are obsoleted by new pinned caching code.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:17:44 +01:00
Marco Costalba 734941672e Do not pass pinned argument in Position::pl_move_is_legal()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-19 16:48:57 +01:00
Marco Costalba 0a0ea36e25 Cleanup pinned and friends in movegen.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-19 16:37:03 +01:00
Marco Costalba c45818e9f8 Remove xxx_of_color() for real
Remove also from assert expressions. Was hidden
in release mode.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-17 17:26:15 +01:00
Marco Costalba 7013efce4e Change piece_attacks_square() API
An extra argument let us simplify some code.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-17 12:00:05 +01:00
Marco Costalba 2c955f25de Remove xxx_of_color() helpers
They hide the underlying uniform function call with
no benefit.

A little bit more verbose but now is clear what happens.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-17 10:54:47 +01:00
Marco Costalba 8365f8ac1e Remove square_is_attacked()
Use attacks_to() instead. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:53:58 +01:00
Marco Costalba 68d36b6f59 Rename generate_piece_blocking_evasions()
In generate_piece_moves() to be more uniform with other
functions. Unfortunatly the different number of calling arguments
do not allow us to easily integrate in generate_piece_moves()
template family.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:53:39 +01:00
Marco Costalba 33c608e140 Final touches to generate_evasions()
Small code tidy up and a little optimization
to avoid calling generate_piece_blocking_evasions()
when blockSquares is empty (30% of cases).

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:53:13 +01:00
Marco Costalba ff60dafe8d Simplify legality check in generate_evasions()
Now that we have removed sliders checkers attacks
from evasion's set we can simplyfy legality check.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:52:52 +01:00
Marco Costalba 214f9dcc27 generate_evasions() avoid an usless check for enpassant case
Remove ugly and useless code.
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-11 19:01:26 +01:00
Marco Costalba 1dc1cecf01 Optimize generate_piece_blocking_evasions()
Rewrite as in generate_piece_moves() using a for
loop instead of the slower serializing of the
bitboard with pop_1st_bit()

This will allow also to merge with generate_piece_moves()
when we will drop legality constrain on generate_evasions()

Generated moves are not changed, but are generated in a
different order, this changes the number of nodes at fixed
depth test.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-11 19:01:06 +01:00
Marco Costalba 67535711e8 generate_evasions() avoid to calculate pinned pieces
Pass as function argument.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-11 19:00:52 +01:00
Marco Costalba 56f607fe0f Drop a double semicolon
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-11 19:00:35 +01:00
Marco Costalba 9d044cf4ee Last touches to movegen.cpp
Of course no functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:51 +01:00
Marco Costalba 769f2fdecb Remove special case of pawn checks generation
Also additional renaming.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:49 +01:00
Marco Costalba 9bffe811c4 Remove special case of pawn move generatation
Code cleanup. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:47 +01:00
Marco Costalba 3e20c6c07d Simplify generate_evasions()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:45 +01:00
Marco Costalba 4f5f97107e Simplify generate_checks()
Also rearrange signatures to be uniform.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:43 +01:00
Marco Costalba 151d47dc85 Micro-optimize do_generate_pawn_checks()
Discovery check candidates are normally empty, so
avoid discovery checks generation in that common case.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:41 +01:00
Marco Costalba 33ddeec5e0 Templetize generate_piece_checks_king()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-10 19:01:39 +01:00
Marco Costalba 4573d618e4 Small optimization in generate_evasions()
Find squares attacked by slider checkers, we will
remove them from king evasions set so to avoid a couple
of cycles in the slow king evasions legality check loop.

Not a biggie, but now generate_evasions() is faster then
generate_non_captures(), before was slower.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-07 13:26:57 +01:00
Marco Costalba 1156eb865b Simplify newly introduced castling_is_check()
Use bit_is_set() instead of open coding.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-07 13:26:50 +01:00
Marco Costalba 76381cbd69 Small code style tidy up
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-07 13:26:42 +01:00
Marco Costalba ee6e8851be Templetize generate_castle_moves()
Cleanup the code and remove lines.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-06 07:14:38 +01:00
Marco Costalba 03211296f1 Add generation of castling checks
When we generate checks one case is missing: generation
of castling moves that give check to the opponent king.

This is a very rare case but anyway it is a case
and we can do this without slowing down the common
case of no castling checks.

So this is the patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-06 07:14:16 +01:00
Marco Costalba 8a0dd93c56 Generate moves for powerful pieces first
This seems to reduce searched nodes by a
surprising 2.5%

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-24 20:43:29 +01:00
Marco Costalba 5e2fc2aa16 Fix a bug in generate_evasions()
Introduced in the patch "movegen: prefer (*mlist++) to mlist[n++]"

This was nasty because due to a mismerge the repo in one PC had the bug,
but the testing one did not, so I had non reproducible results according
to which machine I used for testing.

This hopefully closes a more then one week regression that made me go crazy!

It was found by accident comparing, for other reasons, the sources of the
two PC's.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-01 12:46:51 +01:00
Marco Costalba 74f1efee26 Manual merge 2008-10-26 21:44:58 +01:00
Marco Costalba 4397e6c03e Better naming of pseudo-legality and legality testing
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-26 10:11:13 +01:00
Marco Costalba ad956ef00a Space inflate position until do_promotion_move()
We will end some day ;-)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:05 +02:00
Marco Costalba d155cd88d1 Start to space inflate position.cpp
It's a big file!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:05 +02:00
Marco Costalba 2aebf8eb55 Fix a performance bug in generate_move_if_legal
Use the pinned argument in pos.move_is_legal()

No functional change, simply use pos.move_is_legal() as
was meant to be.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:05 +02:00
Marco Costalba 2f8961beef movegen: add SERIALIZE_MOVES and hides a bunch of loops
Only syntactic sugar, perhaps we should leave as is, anyhow...

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:04 +02:00
Marco Costalba af5743837d Another generate_piece_moves() micro optimization
This time on the for loop.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:04 +02:00
Marco Costalba 5e768e4b0a Fix another template conversion bug in movegen
Hopefully the last one.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:09:51 +02:00
Marco Costalba 2d867109d9 movegen: prefer (*mlist++) to mlist[n++]
Teoretically faster, practically it helps to
removes some more lines.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-23 07:17:04 +02:00
Marco Costalba b145e99559 Fix a bug in generate_pawn_captures()
Introduced in "movegen: Introduce generate_pawn_captures()"
when unifiying black and white functions.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-23 07:17:04 +02:00
Marco Costalba 8f2c1c59eb Fully templetize pawn move generators
A little bit more syntax heavuer but surely faster.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-23 07:17:04 +02:00
Marco Costalba c40249e9d2 Micro optimize generate_piece_moves()
It is a time critical path. The biggest in move generation.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-21 00:10:27 +02:00
Marco Costalba ce93a202b5 Another Intel warning sqeezed
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:57:13 +02:00
Marco Costalba af6571856e Shrink arguments in move generation functions
Perhaps no speedup, but it is more readable.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:21 +02:00
Marco Costalba 0c8659721f Fix a bug in king discoveries checks
Introduced in "Add a generate_piece_checks() specialization for the king"

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:20 +02:00
Marco Costalba 5dc2312121 Update copyright info
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:20 +02:00
Marco Costalba aa94f2f4c2 Last little touches to movegen
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:19 +02:00
Marco Costalba d7161c1ce6 Rename PawnOffsets in PawnParams
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:19 +02:00
Marco Costalba e2af0e775b Pawn move generator: dispatch at compile time
Instead of function pointers use templates to
dispatch shift operations.

It is more clear and possibly also faster because
branches are removed at compile time.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:19 +02:00
Marco Costalba ad1bb084dd Start to templetize pawn move generators
Still very soft, we will see if compiler is
enough or we need more aggressive templetization.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:18 +02:00
Marco Costalba 7eb290a509 Add a generate_piece_checks() specialization for the king
Also reshuffle the code a bit.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:17 +02:00
Marco Costalba d9e54ceaa1 Prefer template to name decoration
This also allows faster code although bigger.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:16 +02:00
Marco Costalba 6b8a07eccc Fix an assert due to a missing parentesis
Bitwise operators precedence issue here, was
causing an assert.

This is a fallout from recent patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:15 +02:00
Marco Costalba 8e85aa3a65 Final semplification of generate_evasions()
Now it's readable!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:15 +02:00
Marco Costalba 4f18528a1c Introduce generate_piece_blocking_evasions()
Start to simplify generate_evasions

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:15 +02:00
Marco Costalba 4a4d62da13 Space inflate generate_evasions()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:15 +02:00
Marco Costalba d3600c39a7 Update copyright info
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 20:43:33 +01:00
Marco Costalba f664ca41ed Last little touches to movegen
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 20:43:21 +01:00
Marco Costalba b397426785 Rename PawnOffsets in PawnParams
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 20:43:09 +01:00
Marco Costalba 68c78400c8 Pawn move generator: dispatch at compile time
Instead of function pointers use templates to
dispatch shift operations.

It is more clear and possibly also faster because
branches are removed at compile time.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 20:42:12 +01:00
Marco Costalba 1bd1f5a293 Start to templetize pawn move generators
Still very soft, we will see if compiler is
enough or we need more aggressive templetization.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 16:20:21 +01:00
Marco Costalba 305b711ca8 Add a generate_piece_checks() specialization for the king
Also reshuffle the code a bit.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 13:22:03 +01:00
Marco Costalba f036239521 Prefer template to name decoration
This also allows faster code although bigger.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 12:43:09 +01:00
Marco Costalba 00bcc64787 Fix an assert due to a missing parentesis
Bitwise operators precedence issue here, was
causing an assert.

This is a fallout from recent patches.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 10:17:17 +01:00
Marco Costalba f2ead1004a Final semplification of generate_evasions()
Now it's readable!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 09:33:33 +01:00
Marco Costalba 84ce43498a Introduce generate_piece_blocking_evasions()
Start to simplify generate_evasions

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 08:49:26 +01:00
Marco Costalba 987ff3b4b6 Space inflate generate_evasions()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-19 08:27:24 +01:00
Marco Costalba 72289fcfab movegen: Introduce generate_pawn_noncaptures()
This is the last of pawn moves generators converted
to new unified form.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:35 +02:00
Marco Costalba 73d0d2c0b2 movegen: Introduce generate_pawn_captures()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:35 +02:00
Marco Costalba c1257d45b2 movegen: Fix just introduced move counter bug
This is what happens when you don't tests your patches !!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:35 +02:00
Marco Costalba 34a515f20b movegen: Introduce generate_pawn_checks()
This greatly simplify redundant code.

Perhaps slihtly slower. Test needed.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:35 +02:00
Marco Costalba 5abe8a0816 generate_checks: fix a bug in black double pawn push
It was written pos.black_pawn_attacks(ksq) instead of
pos.white_pawn_attacks(ksq)

Updated to the undrlying pos.pawn_attacks(WHITE, ksq)

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:34 +02:00
Marco Costalba 35fd5ce5bc Space inflate generate_castle_moves()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:34 +02:00
Marco Costalba 146bb2dfa7 Unify pieces check generation with generate_piece_checks()
Could be slower: test needed!

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:34 +02:00
Marco Costalba ea16985ea5 Do not special case generate_king_moves()
Teoretically a little slowdown. If after testing we
verify the slowdown has impact on ELO we revert the
change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:34 +02:00
Marco Costalba 3b857d1625 Use a const pointer-to-member array for attacks
Allow the compiler to optimize member
function access.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:34 +02:00
Marco Costalba aa7121297d Use pointer-to-members to remove a bunch of duplicated code
Remove all generate_XXX_moves() functions, use an array
of pointer to members instead.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:34 +02:00
Marco Costalba c852a94009 Movegen: further simplify generate_move_if_legal
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:33 +02:00
Marco Costalba 8be2c483a1 Unify black and white code in generate_move_if_legal()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:33 +02:00
Marco Costalba 158911425b Space inflate movegen.cpp
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-18 21:35:33 +02:00
Marco Costalba f56af8e84d Rename pawn_rank() in relative_rank()
It is more clear, at last for me.

Also cleanup evaluate_rook() and evaluate_queen()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-24 21:02:15 +02:00
Marco Costalba bb751d6c89 Initial import of Glaurung 2.1 2008-09-01 07:59:13 +02:00