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

211 commits

Author SHA1 Message Date
Marco Costalba
4324276419 Fix some asserts unhidden by a debug compile
Fallback form previous patches.
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-23 21:44:04 +01:00
Marco Costalba
43bc5479c2 Avoid resetting pinners[c]
Small optimization. No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:19:04 +01:00
Marco Costalba
8f59de48f5 Introduce StateInfo instead of UndoInfo
We don't backup anymore but use the renamed StateInfo
argument passed in do_move() to store the new position
state when doing a move.

Backup is now just revert to previous StateInfo that we know
because we store a pointer to it.
Note that now backing store is up to the caller, Position is
stateless in that regard, state is accessed through a pointer.

This patch will let us remove all the backup/restore copying,
just a pointer switch is now necessary.

Note that do_null_move() still uses StateInfo as backup.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:18:50 +01:00
Marco Costalba
2f6c5f00e6 Wrap state variables in a named struct
This will allow us to more easily move the state
out of Position class.

No functioanl change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:18:35 +01:00
Marco Costalba
2f21ec39ad Convert also undo_null_move() to avoid passing UndoInfo object
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:18:14 +01:00
Marco Costalba
9b257ba29d Passing UndoInfo is not needed anymore when undoing the move
We store it now in the same UndoInfo struct as 'previous'
field, so when doing a move we also know where to get
the previous info when undoing the back the move.

This is needed for future patches and is a nice cleanup anyway.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-22 21:18:02 +01:00
Marco Costalba
b7cb6180cf Position: Unify and templetize mg_pst() and eg_pst()
Also templetize compute_value() can be simpler now that
the above is templetized too.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-20 22:50:35 +01:00
Marco Costalba
f30aa83f8a Unify compute_mg_value() and compute_eg_value()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-20 22:50:20 +01:00
Marco Costalba
1dc27f3232 Use a union to fast and simply backup info in do_move()
This nice union trick let us optimize the speed and
remove the now unuseful backup() and restore() functions.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-20 22:50:08 +01:00
Marco Costalba
95cfc0e306 In Position backup and restore contiguous data
Give the compiler one more chance to optimize the copy.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-20 22:49:54 +01:00
Marco Costalba
683e6dc656 Do not pass discovery check candidates in Position::do_move()
Also remove any bit of 'pinned' and co. from MovePicker class.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-19 17:29:36 +01:00
Marco Costalba
c6630abe0d Do not pass pinned argument in Position::move_is_check()
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
2009-02-19 17:01:08 +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
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