<commit_before>// Copyright (c) 2013-2014 by <NAME>. All Rights Reserved.
// Use of this source code is governed by a MIT-style license that can
// be found in the LICENSE file.

package donna

import(`fmt`)

// Quiescence search.
func (p *Position) xSearchQuiescence(alpha, beta, depth int) int {
        alpha = alpha
        beta = beta
        depth = depth

        fmt.Printf("%*squie/%s> depth: %d, ply: %d\n", depth*2, ` `, C(p.color), depth, Ply())

        return 0
}<commit_msg>Some more experiments with revamping search<commit_after>// Copyright (c) 2013-2014 by <NAME>. All Rights Reserved.
// Use of this source code is governed by a MIT-style license that can
// be found in the LICENSE file.

package donna

import(`fmt`)

// Quiescence search.
func (p *Position) xSearchQuiescence(alpha, beta int, checks bool) int {
        if p.isRepetition() {
                return 0
        }

        bestScore := p.Evaluate()
        if bestScore > alpha {
                if bestScore >= beta {
                        return bestScore
                }
                alpha = bestScore
        }

        gen := p.StartMoveGen(Ply()).GenerateCaptures().rank()
        for move := gen.NextMove(); move != 0; move = gen.NextMove() {
                if position := p.MakeMove(move); position != nil {
                        fmt.Printf("%*squie/%s> ply: %d, move: %s\n", Ply()*2, ` `, C(p.color), Ply(), move)
                        moveScore := 0
                        if position.isInCheck(position.color) {
                                moveScore = -position.xSearchQuiescenceInCheck(-beta, -alpha)
                        } else {
                                moveScore = -position.xSearchQuiescence(-beta, -alpha, false)
                        }

                        position.TakeBack(move)
                        if moveScore > bestScore {
                                if moveScore > alpha {
                                        if moveScore >= beta {
                                                return moveScore
                                        }
                                        alpha = moveScore
                                }
                                beta = moveScore
                        }
                }
        }

        if checks {
                gen := p.StartMoveGen(Ply()).GenerateChecks().rank()
                for move := gen.NextMove(); move != 0; move = gen.NextMove() {
                        if position := p.MakeMove(move); position != nil {
                                fmt.Printf("%*squix/%s> ply: %d, move: %s\n", Ply()*2, ` `, C(p.color), Ply(), move)
                                moveScore := -position.xSearchQuiescenceInCheck(-beta, -alpha)

                                position.TakeBack(move)
                                if moveScore > bestScore {
                                        if moveScore > alpha {
                                                if moveScore >= beta {
                                                        return moveScore
                                                }
                                                alpha = moveScore
                                        }
                                        beta = moveScore
                                }
                        }
                }
        }
        return bestScore
}

// Quiescence search (in check).
func (p *Position) xSearchQuiescenceInCheck(alpha, beta int) int {
        if p.isRepetition() {
                return 0
        }

        bestScore := Ply() - Checkmate
        if bestScore >= beta {
                return bestScore
        }

        gen := p.StartMoveGen(Ply()).GenerateEvasions().rank()
        for move := gen.NextMove(); move != 0; move = gen.NextMove() {
                if position := p.MakeMove(move); position != nil {
                        fmt.Printf("%*squic/%s> ply: %d, move: %s\n", Ply()*2, ` `, C(p.color), Ply(), move)
                        moveScore := 0
                        if position.isInCheck(position.color) {
                                moveScore = -position.xSearchQuiescenceInCheck(-beta, -alpha)
                        } else {
                                moveScore = -position.xSearchQuiescence(-beta, -alpha, false)
                        }

                        position.TakeBack(move)
                        if moveScore > bestScore {
                                if moveScore > alpha {
                                        if moveScore >= beta {
                                                return moveScore
                                        }
                                        alpha = moveScore
                                }
                                beta = moveScore
                        }
                }
        }

        return bestScore
}
{'fraction_non_alphanumeric': 0.09455587392550144, 'fraction_numerical': 0.0057306590257879654, 'mean_word_length': 0.9331487341772152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7448777', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1068, 'n_words': 294}