Author: Scott Gasch
Date: 17:28:21 02/22/05
Go up one level in this thread
On February 22, 2005 at 10:44:48, Uri Blass wrote: >On February 22, 2005 at 10:25:22, Guillaume MOYA wrote: > >>Hi, >> >>I write in my spare time, a little chess program, I just have done the move >>generation and I play with alpha beta algorithm. My move generator is coded >>using the rotated bitboard stuff, it works well but I got very bad speed result. >> >>As an example, with this fen : >> >>r4rk1/p2q1ppp/n1pb4/1p1p3Q/3P2NB/P3P2P/1PP3P1/2R2R1K w - - 0 1 >> >>when searching only at depth 4, with the simpliest eval function (just piece >>value count), it takes 3094 ms to compute the PV. Here's how my program proceed >>: >> >>1) Generate all moves >>2 Order move, using memory heuristic >>3) Expand tree, test if the king is in check, remove the node if yes >> >>and I use plain alpha beta with no funny stuff. When profiling my program, main >>time is consummed in the function that's computed attaqued square (called after >>a move is done to test if the king is in check). Is there another method? Is >>this kind of performance right without a hashtable or something else? >> >>Thanks >>Guillaume > >checking if the king is in check should not be something very expensive. >I assume that > >1)you have a varaibles to tell you the square of the kings > >2)You have some fast function that tell you that the last move is not checking >move most of the time(for example it is clear that pawn a2-a4 is not check when >the opponent king is at e8 because a2 is not in queen direction to e8 and a4 is >not square that a pawn can attack king at e8). > >3)In case that you suspect a check based on the move you check only directions >that are from the from square to the opponent king(indirect check) or from the >to square to the opponent king(direct check). > >You may need to take care about some special cases(like indirect check by a >bishop when you capture enpassent capture but special moves like that are very >small part of the moves) > >Uri First of all, why even decide whether a move is checking until you play it? (I ask that rhetorically because I do flag moves as checking or not before they are played). But it seems reasonable to me to not know whether the move is check (or legal, for that matter) until you send it to MakeMove. Unless, for some reason, you want the check flag information before the move is made (to decide pruning? to score the move?) then don't bother with this stuff. If, however, you decide you do want to know if a move is checking before you play it (as you generate it? when you select it in search?) then Uri's advice is good. However it's not fast. It is the fastest way I know to tell if a move checks the king but it's still about 8% of my program's runtime overhead. Scott
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.