1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00
Commit graph

99 commits

Author SHA1 Message Date
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
5f142ec209 Cache pinned and discovery check bitboards
After have been calculated cache their values
so to avoid another expensive call to hidden_checks()
if pinned_pieces() or discovered_check_candidates() are
called with the same position.

Add also interface to get pinners bitboard, we already have
this value so save it instead of discard.

Now that, after the first call to pinned_pieces() the following
are very cheap we can rewrite and cleanup all the checking handling.

So this patch is a prerequisite for future work.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-19 16:28:35 +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
e71d520758 Add scan for X-ray attacks in piece_attacks_square()
Used to avoid pruning interesting moves.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:56:46 +01:00
Marco Costalba
52ed0e9563 Fix a subtle bug in Position::move_is_capture()
Currently fails if we test with a move that is not of
from the side to move but from the opponent.

This is the typical case of the threat from null move
search. The result is an erroneus prune of the defending
moves, see PruneDefendingMoves in ok_to_prune()

Fix the test to work also with threat moves.

Bug was always in but was unhidden by a patch of 17/12/2008
"Trigger of PawnEndgameExtension if capture is not a pawn"

Until then it was hidden by a tricky check in the prune
conditions instead of the natural move_is_capture()

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:56:26 +01:00
Marco Costalba
30e8f0c9ad Do not manually build endgame functions hash keys
Use Position::compute_material_key() to do the job,
so we are sure there is not key mismatch during
endgame function lookups.

This fixes two endgames hash errors that caused two
endgames to be disabled.

This patch is also a code cleanup because removes a lot
of messy key assignments.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:55:59 +01:00
Marco Costalba
088ecc242f Small code formatting in position.cpp
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:54:56 +01:00
Marco Costalba
a188a047ab Use update_checkers<>() also for PAWN
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:54:37 +01:00
Marco Costalba
1d2247aea3 Introduce update_checkers() to simplify do_move()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-13 20:54:17 +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
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
72ca727b38 SEE: add support for enpassant moves
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-12-21 10:44:41 +01:00
Marco Costalba
aaad48464b Add a see() function that take only destination square
In this case firstlocates the least valuable attacker, if any,
then proceed as usual.

This will be used by next patch.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-12-10 00:13:59 +01:00
Marco Costalba
dc2302b701 Position::move_is_capture() does not handle MOVE_NONE
Actually square 0 can be dirty, so that move_is_capture(0)
can return any random values.

Add an assert to be sure it is caught.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-12-06 11:18:31 +01:00
Marco Costalba
268c12bf31 Allow to call Position::print() from MovePicker
Fix a recursion issue that gives a stack overflow.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-12-06 11:18:08 +01:00
Marco Costalba
08265aef81 san.cpp pass position as constant reference
Make a copy of the position when needed instead
of passing as a reference. It is cleaner and
let us to simplify also Position::print()

A small space inflate while there.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-30 01:25:16 +01:00
Marco Costalba
bac4da70c9 Remove an include in movepick.h
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
Signed-off-by: unknown <Marco@.(none)>
2008-11-19 22:15:41 +01:00
Marco Costalba
93bc05cf69 Convert killers to a vector
Add infrastructure to threat killer moves as a vector,
this will allow us to easily parametrize the number of
killer moves, instead of hardcode this value to two as is now.

This patch just add the infrastructure, no functional
change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-16 12:37:47 +01:00
Marco Costalba
20d7197a9b MovePicker: use EvalInfo to skip generating captures
When we know already no captures are possible in a given
position.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-16 12:37:46 +01:00
Marco Costalba
f4758ced90 Position::to_fen(): fix a bug in side to move representation
Was introduced almost two months ago in patch:
"Space inflate Position::to_fen()"

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-16 12:37:46 +01:00
Marco Costalba
3c05bd70eb Print the move in addition to position
Teach Position::print() to optionally print a
given move in san notation in addition to
the ASCII representation of the board.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-16 12:37:46 +01:00
Marco Costalba
b5232e2da3 Fix a couple of gcc warnings in position.cpp
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-02 15:00:19 +01:00
Marco Costalba
038235ba35 Factor out Position::do_capture_move()
Start to slim line count i position.cpp

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-11-01 12:46:51 +01:00
Marco Costalba
a56e1c662c Revert see shortcut when only one attacker
It does not seem to work after a little testing.

Perhaps it works on the long terms, but it is also
ugly because not correct, so revert for now.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-26 21:30:21 +01:00
Marco Costalba
a5c1b3e8f6 Position: fix a couple of Intel compiler warnings
Plus usual trailing whitespace.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-26 13:23:27 +01:00
Marco Costalba
8a85007023 Test with SEE shortcut
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-26 10:11:13 +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
5dd9159106 Space inflate position: complete!
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-26 10:10:56 +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
1ac2f50145 Unify pinned and discovery checks code
Templates are our friends here. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:04 +02:00
Marco Costalba
af59cb1d63 Refactor Position::pinned_pieces() to use templates
Also better document this interesting function.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-24 21:10:04 +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
257689dec7 Remove white/black_pawn_attacks_square()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:18 +02:00
Marco Costalba
ff211469ba Templetize Position::xxx_attacks_square()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:17 +02:00
Marco Costalba
d316b02771 Remove white/black_pawn_attacks()
Unuseful syntactic sugar, obfuscates the
real code.

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
3f38cca072 Position::is_ok()give more info on failed test
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-20 21:47:16 +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
849809e97e Space inflate Position::to_fen()
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-10-04 09:50:19 +02:00
Marco Costalba
e9e51da4b8 position.cpp: fix a typo introduced by recent patch
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-28 10:59:20 +02:00
Marco Costalba
88bb3c9422 Start to cleanup position.cpp
Still a lot to do. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-28 10:58:56 +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
7dd0c39714 Warnings termination fest
A bunch of Intel C++ warnings removed, other silent out.

Still few remaining but need deeper look.

Also usual whitespace crap removal noise.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2008-09-24 00:32:53 +02:00
Marco Costalba
2dbc8feae3 Finally remove last old C style I/O stuff
Now I/O is fully done with C++ iostreams.

The only exception is in non-windows version
of Bioskey() in misc.cpp

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