AlphaBeta shouldn't exceed beta ?

Programming Topics (Computer Chess) and technical aspects as test techniques, book building, program tuning etc

Moderator: Andres Valverde

AlphaBeta shouldn't exceed beta ?

Postby Freshblood » 28 Jul 2010, 12:34

Hello everybody.

I have experienced AlphaBeta algorithm with my own old chess engine and now i am trying to write new engine and i see that algorithim encounter beta cut-offs but in my opinion, this should never be occur if i don't use narrowed window. Am i wrong ? I am using int.MaxValue for beta and -int.MaxValue for alpha so what can cause a beta cut-offs ?

Full code is here.
Code: Select all
    public Result Search(int maxDepth)
    {
        int alpha = -int.MaxValue, beta = int.MaxValue, ply = maxDepth;
        var bestLine = new Stack<Move>();

        var score = AlphaBeta(alpha, beta, ply, bestLine);

        return new Result(score, bestLine);
    }
    int AlphaBeta(int alpha, int beta, int ply, Stack<Move> bestLine)
    {
        if (ply <= 0) return Evaluation.Evaluate(Board);
        var moves = Board.GenerateMoves();
        foreach (var move in moves)
        {
            Board.MakeMove(move);

            eval = -AlphaBeta(-beta, -alpha, ply - 1, bestLine);

            Board.TakeBackMove(move);

            if (eval >= beta)
            {
                return beta;
            }
            if (eval > alpha)
            {
                alpha = eval;
                if (ply == 1) bestLine.Clear();

                bestLine.Push(move);
            }
        }
        return alpha;
Freshblood
 
Posts: 1
Joined: 28 Jul 2010, 09:15

Re: AlphaBeta shouldn't exceed beta ?

Postby beneficii » 21 Aug 2010, 03:41

If the score of the position exceeds beta, then that should generally cause a beta cut-off. If you're dealing with null moves you can do a depth reduction in that case, or just allow the beta cut-off.

Perhaps this answers your question? If not, then I'll say this, there are different pros and cons of using fail-hard (only returning a score within the bounds of alpha and beta) and fail-soft (always returning the score of the position). Here are some articles on them:

http://chessprogramming.wikispaces.com/Fail-Hard

http://chessprogramming.wikispaces.com/Fail-Soft
beneficii
 
Posts: 43
Joined: 07 May 2010, 05:17


Return to Programming and Technical Discussions

Who is online

Users browsing this forum: No registered users and 1 guest