Bruteforce_binbook

Code, algorithms, languages, construction...
User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Bruteforce_binbook

Post by deeds » Thu Oct 03, 2024 9:04 pm

This week I started programming a tool to find *uncovered lines of any BIN book.

In *white positions, it lists the book's moves.

In *black positions, it lists all legal moves then uses an experience file to quickly retrieve their scores.

If the experience data is not *sufficient, it uses an engine to evaluate the score (min D26) of each move.

It only retains positions with positive scores for black.

I only bruteforced 2-3 books and there are already some uncovered lines evaluated at -1.00 !?

DeeDs

*uncovered line: no move is configured in the book for the final position of the line.

*white/black position : position where white/black must play.

*sufficient experience data : move with a score evaluated at min D26 by an engine using nnue, syzygy, etc.

Ding-Bat
Posts: 96
Joined: Sat Jun 18, 2022 6:52 am

Re: Bruteforce_binbook

Post by Ding-Bat » Fri Oct 04, 2024 4:26 am

This is a great idea

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Fri Oct 04, 2024 6:22 am

Ding-Bat wrote:
Fri Oct 04, 2024 4:26 am
This is a great idea
I hope so... At the moment I'm still looking for what score is favorable enough for black (=to keep this line). By default I set -1.00 but I don't know if there will be even more favorable lines (for black) in other bin books.

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Fri Oct 04, 2024 2:58 pm

modMain.vb :

Code: Select all

Module modMain
    Public nbAnalysis As Integer
    Public nbExperiences As Integer
    Public Const minDepth = 26

    Sub Main()
        Dim tabPositions(0) As String, tabScores(0) As String, currentPosition As String, indexPosition As Integer, offsetPosition As Integer
        Dim legalMoves As String, bookMoves As String, trait As String
        Dim tabChaine(0) As String, i As Integer, tabTmp() As String
        Dim score As Single, depth As Integer
        Dim engineEval As String, engineBook As String, fileBIN As String, maxMultiPV As Integer
        Dim nbOutOfBooks As Integer

        fileBIN = Replace(Command(), """", "")
        If Not My.Computer.FileSystem.FileExists(fileBIN) Then
            MsgBox(nomFichier(fileBIN) & " introuvable", MsgBoxStyle.Critical)
            End
        End If

        engineBook = "E:\JEUX\ARENA CHESS 3.5.1\Engines\asmFish\20T asmFish 291118 x64 BMI2.exe"
        Console.Write("Loading " & nomFichier(engineBook) & " (book/legal moves)... ")
        book_chargerMoteur(engineBook, fileBIN)
        maxMultiPV = maxMultiPVMoteur(nomFichier(engineBook))
        Console.WriteLine("OK" & vbCrLf)

        engineEval = "E:\MEGASync\eman\releases\8.xx\Eman 8.40 64-bit BMI2.exe"
        Console.Write("Loading " & nomFichier(engineEval) & " (exp/eval bestmoves)... ")
        eval_chargerMoteur(engineEval)
        Console.WriteLine("OK" & vbCrLf)

        'départ
        indexPosition = 0
        offsetPosition = indexPosition + 1
        tabPositions(indexPosition) = ""
        tabScores(indexPosition) = ""
        trait = ""
        nbAnalysis = 0
        nbExperiences = 0
        nbOutOfBooks = 0
        Do
            currentPosition = tabPositions(indexPosition)

            bookMoves = ""
            legalMoves = ""

            'scénario : on considère que le livre jouera en blanc
            trait = "white"
            If currentPosition <> "" Then
                If InStr(currentPosition, " ", CompareMethod.Text) = 0 Then
                    trait = "black"
                ElseIf nbCaracteres(currentPosition, " ") Mod 2 = 0 Then
                    trait = "black"
                End If
            End If

            If trait = "white" Then
                'coups du livre
                bookMoves = trierChaine(listBookMoves(currentPosition), ", ")

                If bookMoves <> "" Then
                    tabChaine = Split(bookMoves, ", ")

                    'on ajoute chaque coup du livre à la liste des positions à tester
                    If tabPositions.Length < tabPositions.Length + tabChaine.Length Then
                        ReDim Preserve tabPositions(tabPositions.Length + tabChaine.Length - 1)
                        ReDim Preserve tabScores(UBound(tabPositions))
                    End If
                    For i = 0 To UBound(tabChaine)
                        tabPositions(offsetPosition) = Trim(currentPosition & " " & tabChaine(i))
                        offsetPosition = offsetPosition + 1
                    Next
                    tabPositions(indexPosition) = ""
                ElseIf bookMoves = "" Then
                    bookMoves = "out-of-book"
                    nbOutOfBooks = nbOutOfBooks + 1
                    tabPositions(indexPosition) = tabScores(indexPosition) & " : " & tabPositions(indexPosition)
                End If
                tabScores(indexPosition) = ""

                Console.Title = "Attack : " & Format(indexPosition / offsetPosition, "0.00%") & " (" & Trim(Format(indexPosition, "### ### ##0")) & " / " & Trim(Format(offsetPosition, "### ### ##0 pos.")) & "), exp. data : " & Trim(Format(nbExperiences, "### ### ##0 moves")) & ", eval. : " & Trim(Format(nbAnalysis, "### ### ##0 moves")) & ", out-of-book : " & Trim(Format(nbOutOfBooks, "### ### ##0 lines"))
                Console.WriteLine("position   : " & currentPosition & vbCrLf)
                If bookMoves = "out-of-book" Then
                    Console.WriteLine("00 book    : " & bookMoves & vbCrLf)
                Else
                    Console.WriteLine(Format(tabChaine.Length, "00") & " book    : " & bookMoves & vbCrLf)
                End If
                Console.WriteLine(StrDup(120, "-"))
            Else
                'coups légaux
                legalMoves = trierChaine(listLegalMoves(currentPosition, maxMultiPV), ", ")
                tabChaine = Split(legalMoves, ", ")

                Console.Title = "Attack : " & Format(indexPosition / offsetPosition, "0.00%") & " (" & Trim(Format(indexPosition, "### ### ##0")) & " / " & Trim(Format(offsetPosition, "### ### ##0 pos.")) & "), exp. data : " & Trim(Format(nbExperiences, "### ### ##0 moves")) & ", eval. : " & Trim(Format(nbAnalysis, "### ### ##0 moves")) & ", out-of-book : " & Trim(Format(nbOutOfBooks, "### ### ##0 lines"))
                Console.WriteLine("position   : " & currentPosition & vbCrLf)
                Console.WriteLine(Format(tabChaine.Length, "00") & " legal   : " & legalMoves & vbCrLf)

                If tabPositions.Length < tabPositions.Length + tabChaine.Length Then
                    ReDim Preserve tabPositions(tabPositions.Length + tabChaine.Length - 1)
                    ReDim Preserve tabScores(UBound(tabPositions))
                End If
                For i = 0 To UBound(tabChaine)
                    Console.Title = "Attack : " & Format(indexPosition / offsetPosition, "0.00%") & " (" & Trim(Format(indexPosition, "### ### ##0")) & " / " & Trim(Format(offsetPosition, "### ### ##0 pos.")) & "), exp. data : " & Trim(Format(nbExperiences, "### ### ##0 moves")) & ", eval. : " & Trim(Format(nbAnalysis, "### ### ##0 moves")) & ", out-of-book : " & Trim(Format(nbOutOfBooks, "### ### ##0 lines"))
                    Console.Write("move " & Format(i + 1, "00") & "/" & tabChaine.Length & " : " & tabChaine(i))

                    tabPositions(offsetPosition) = Trim(currentPosition & " " & tabChaine(i))

                    tabTmp = Split(expListe(currentPosition, tabChaine(i)), "/")
                    score = CSng(tabTmp(0))
                    depth = CInt(tabTmp(1))
                    tabScores(offsetPosition) = Format(score, "0.00/") & depth
                    Console.Write(" {" & tabScores(offsetPosition) & "}")
                    If score < 0 Then
                        'on la supprime
                        Console.WriteLine()
                        tabPositions(offsetPosition) = ""
                        tabScores(offsetPosition) = ""
                    Else
                        If 2 <= score Then
                            Console.WriteLine(" !!!")
                        ElseIf 1 <= score Then
                            Console.WriteLine(" !!")
                        ElseIf 0.5 <= score Then
                            Console.WriteLine(" !")
                        Else
                            Console.WriteLine()
                        End If
                        offsetPosition = offsetPosition + 1
                    End If
                Next
                Console.WriteLine(StrDup(120, "-"))
                tabPositions(indexPosition) = ""
                tabScores(indexPosition) = ""
            End If
            indexPosition = indexPosition + 1
        Loop While indexPosition < offsetPosition And nbOutOfBooks < 2000

        Console.Clear()
        Console.Title = "Attack : " & Format(indexPosition / offsetPosition, "0.00%") & " (" & Trim(Format(indexPosition, "### ### ##0")) & " / " & Trim(Format(offsetPosition, "### ### ##0 pos.")) & "), exp. data : " & Trim(Format(nbExperiences, "### ### ##0 moves")) & ", eval. : " & Trim(Format(nbAnalysis, "### ### ##0 moves")) & ", out-of-book : " & Trim(Format(nbOutOfBooks, "### ### ##0 lines"))

        'décharger le moteur
        Console.Write("Unloading " & nomFichier(engineBook) & " (book/legal moves)... ")
        book_dechargerMoteur()
        Console.WriteLine("OK" & vbCrLf)

        Console.Write("Unloading " & nomFichier(engineEval) & " (exp/eval bestmoves)... ")
        eval_dechargerMoteur()
        Console.WriteLine("OK" & vbCrLf)

        Console.Write("Sorting positions... ")
        currentPosition = ""
        tabPositions = trierTableau(tabPositions)
        Console.WriteLine("OK" & vbCrLf)

        Console.Write("Listing positions... ")
        currentPosition = String.Join(vbCrLf, tabPositions)
        While InStr(currentPosition, vbCrLf & vbCrLf, CompareMethod.Text) > 0
            currentPosition = Replace(currentPosition, vbCrLf & vbCrLf, vbCrLf)
        End While
        If gauche(currentPosition, 2) = vbCrLf Then
            currentPosition = droite(currentPosition, Len(currentPosition) - 2)
        End If
        Console.WriteLine("OK" & vbCrLf)

        Console.Write("Storing positions... ")
        My.Computer.FileSystem.WriteAllText(Replace(nomFichier(fileBIN), ".bin", ".lst"), currentPosition, False)
        Console.WriteLine("OK" & vbCrLf)

        Console.WriteLine("ENJOY !")
        Console.ReadLine()
    End Sub
End Module

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Fri Oct 04, 2024 2:59 pm

modfonctions.vb :

Code: Select all

Imports System.Threading
Imports System.Management
Imports VB = Microsoft.VisualBasic

Module modFonctions
    Public book_processus As System.Diagnostics.Process
    Public book_entree As System.IO.StreamWriter
    Public book_sortie As System.IO.StreamReader

    Public eval_processus As System.Diagnostics.Process
    Public eval_entree As System.IO.StreamWriter
    Public eval_sortie As System.IO.StreamReader

    Public Sub book_chargerMoteur(engine As String, file As String)
        Dim ligne As String

        book_processus = New System.Diagnostics.Process()

        book_processus.StartInfo.RedirectStandardOutput = True
        book_processus.StartInfo.UseShellExecute = False
        book_processus.StartInfo.RedirectStandardInput = True
        book_processus.StartInfo.CreateNoWindow = True
        book_processus.StartInfo.WorkingDirectory = My.Application.Info.DirectoryPath
        book_processus.StartInfo.FileName = engine
        book_processus.Start()
        book_processus.PriorityClass = 64 '64 (idle), 16384 (below normal), 32 (normal), 32768 (above normal), 128 (high), 256 (realtime)

        book_entree = book_processus.StandardInput
        book_sortie = book_processus.StandardOutput

        book_entree.WriteLine("setoption name bookfile value " & file)

        book_entree.WriteLine("isready")
        ligne = ""
        While InStr(ligne, "readyok") = 0
            ligne = book_sortie.ReadLine
            Thread.Sleep(1)
        End While
    End Sub

    Public Sub book_dechargerMoteur()
        book_entree.Close()
        book_sortie.Close()
        book_processus.Close()

        book_entree = Nothing
        book_sortie = Nothing
        book_processus = Nothing
    End Sub

    Public Function listBookMoves(position As String) As String
        Dim tabMoves() As String, tabPoids() As String, ligne As String, i As Integer
        Dim lstMoves As String, lstPoids As String
        Dim totalPoids As Integer, poids As Integer

        book_entree.WriteLine("setoption name OwnBook value true")
        book_entree.WriteLine("position startpos moves " & position)

        book_entree.WriteLine("bookprobe")
        book_entree.WriteLine("isready")

        ligne = ""
        lstMoves = ""
        lstPoids = ""
        totalPoids = 0

        Do
            ligne = book_sortie.ReadLine
            If ligne <> "" And ligne <> "readyok" Then
                tabMoves = Split(Trim(Replace(ligne, ")", "")), "(")
                lstMoves = lstMoves & tabMoves(0) & ":"
                poids = CInt(tabMoves(1))
                totalPoids = totalPoids + poids
                lstPoids = lstPoids & poids & ":"
                Thread.Sleep(1)
            End If
        Loop Until ligne = "readyok"

        If lstMoves <> "" Then
            tabMoves = Split(lstMoves, ":")
            tabPoids = Split(lstPoids, ":")
            lstMoves = ""
            For i = 0 To UBound(tabPoids)
                If tabMoves(i) <> "" Then
                    If 1 < 100 * (CInt(tabPoids(i)) / totalPoids) Then
                        lstMoves = lstMoves & tabMoves(i) & ", "
                    End If
                End If
            Next
        End If

        Return lstMoves
    End Function

    Public Function listLegalMoves(position As String, maxMultiPV As Integer) As String
        Dim ligne As String, move As String, liste As String, pos As Integer

        'on cherche tous les coups possibles
        book_entree.WriteLine("setoption name OwnBook value false")
        book_entree.WriteLine("setoption name MultiPV value " & maxMultiPV)
        book_entree.WriteLine("position startpos moves " & position)

        book_entree.WriteLine("go depth 1")

        ligne = ""
        liste = ""
        While InStr(ligne, "bestmove", CompareMethod.Text) = 0
            ligne = book_sortie.ReadLine
            If InStr(ligne, " depth 1 ", CompareMethod.Text) > 0 Then
                'info depth 1 seldepth 2 multipv 1 time 1 nps 479000 score mate 1 nodes 479 tbhits 0 pv d8h4
                If InStr(ligne, "mate", CompareMethod.Text) = 0 Then
                    'info depth 1 seldepth 1 multipv 1 score cp 29 nodes 210 nps 105000 hashfull 0 tbhits 353 time 2 pv g1f3 e7e5
                    pos = InStr(ligne, " pv ", CompareMethod.Text)
                    If pos > 0 Then
                        move = ligne.Substring(pos + 3)

                        'g1f3 e7e5
                        pos = InStr(move, " ", CompareMethod.Text)
                        If pos > 0 Then
                            move = move.Substring(0, move.IndexOf(" "))
                            'g1f3
                        End If
                        If InStr(liste, move & ", ", CompareMethod.Text) = 0 Then
                            liste = liste & move & ", "
                        End If
                    End If
                End If
            End If
            Thread.Sleep(1)
        End While
        book_entree.WriteLine("stop")

        book_entree.WriteLine("setoption name MultiPV value 1")

        book_entree.WriteLine("isready")
        ligne = ""
        While InStr(ligne, "readyok") = 0
            ligne = book_sortie.ReadLine
            Thread.Sleep(1)
        End While

        Return liste

    End Function

    '///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Public Sub eval_chargerMoteur(engineEXP As String)
        Dim ligne As String
chargement:
        eval_processus = New System.Diagnostics.Process()

        eval_processus.StartInfo.RedirectStandardOutput = True
        eval_processus.StartInfo.UseShellExecute = False
        eval_processus.StartInfo.RedirectStandardInput = True
        eval_processus.StartInfo.CreateNoWindow = True
        eval_processus.StartInfo.WorkingDirectory = My.Application.Info.DirectoryPath
        eval_processus.StartInfo.FileName = engineEXP
        eval_processus.Start()
        eval_processus.PriorityClass = 64 '64 (idle), 16384 (below normal), 32 (normal), 32768 (above normal), 128 (high), 256 (realtime)

        eval_entree = eval_processus.StandardInput
        eval_sortie = eval_processus.StandardOutput

        eval_entree.WriteLine("setoption name Experience File value E:\JEUX\ARENA CHESS 3.5.1\Engines\Eman\work.exp")
        eval_entree.WriteLine("setoption name Experience Read Only value false")
        eval_entree.WriteLine("setoption name Experience MultiPV value false")
        eval_entree.WriteLine("setoption name Experience Book Max Moves value 100")
        eval_entree.WriteLine("setoption name NNUE Eval File value E:\JEUX\ARENA CHESS 3.5.1\Engines\Eman\nn-e1fb1ade4432.nnue")
        eval_entree.WriteLine("setoption name Book 1 File value <empty>")
        eval_entree.WriteLine("setoption name Book 2 File value <empty>")
        eval_entree.WriteLine("setoption name SyzygyPath value E:\JEUX\ARENA CHESS 3.5.1\TB\Syzygy;C:\Syzygy")

        eval_entree.WriteLine("setoption name Threads value " & Format(cpu() - 1), "0")
        eval_entree.WriteLine("setoption name Hash value 2048")

        eval_entree.WriteLine("isready")
        ligne = ""
        While InStr(ligne, "readyok") = 0
            ligne = eval_sortie.ReadLine
            If eval_processus.HasExited Then
                eval_dechargerMoteur()
                GoTo chargement
            End If
            Thread.Sleep(1)
        End While
    End Sub

    Public Sub eval_dechargerMoteur()
        eval_entree.Close()
        eval_sortie.Close()
        eval_processus.Close()

        eval_entree = Nothing
        eval_sortie = Nothing
        eval_processus = Nothing
    End Sub

    Public Function expListe(position As String, move As String) As String
        Dim chaine As String, ligne As String, tabTmp() As String, profondeur As Integer

        eval_entree.WriteLine("position startpos moves " & position)

        eval_entree.WriteLine("expex")
        eval_entree.WriteLine("isready")

        ligne = ""
        chaine = ""
        While InStr(ligne, "readyok") = 0
            ligne = eval_sortie.ReadLine
            If InStr(ligne, " depth: ", CompareMethod.Text) > 0 Then
                If InStr(ligne, ": " & move, CompareMethod.Text) > 0 Then
                    'formatage
                    If InStr(ligne, ",", CompareMethod.Text) > 0 Then
                        While InStr(ligne, "  ", CompareMethod.Text) > 0
                            ligne = Replace(ligne, "  ", " ")
                        End While
                    ElseIf InStr(ligne, "PV", CompareMethod.Text) > 0 Then
                        While InStr(ligne, "  ", CompareMethod.Text) > 0
                            ligne = Replace(ligne, "  ", ",")
                        End While

                        While InStr(ligne, ",,", CompareMethod.Text) > 0
                            ligne = Replace(ligne, ",,", ",")
                        End While
                    End If

                    tabTmp = Split(Replace(Replace(ligne, " : ", ","), ": ", ","), ",")

                    profondeur = CInt(Trim(tabTmp(3)))
                    If minDepth <= profondeur Then
                        If InStr(tabTmp(5), "cp") > 0 Then
                            chaine = Format(CInt(Replace(tabTmp(5), "cp ", "")) / 100, "0.00")
                        ElseIf InStr(tabTmp(5), "mate") > 0 Then
                            chaine = Format(CInt(Replace(tabTmp(5), "mate ", "")), "0")
                        End If
                        chaine = chaine & "/" & profondeur
                        nbExperiences = nbExperiences + 1
                    End If
                End If
            End If
        End While

        If chaine = "" Then
            chaine = searchMove(position, move) & "/" & minDepth
        End If

        Return chaine

    End Function

    Public Function searchMove(position As String, move As String) As Single
        Dim ligne As String, score As String

        ligne = ""
        score = "0"

        'on cherche un coup spécifique
        eval_entree.WriteLine("position startpos moves " & position)
        eval_entree.WriteLine("go depth " & minDepth & " searchmoves " & move)

        While InStr(ligne, "bestmove", CompareMethod.Text) = 0
            ligne = eval_sortie.ReadLine
            If InStr(ligne, " depth " & minDepth, CompareMethod.Text) > 0 Then
                If InStr(ligne, " pv ", CompareMethod.Text) > 0 Then
                    If InStr(ligne, " score cp ", CompareMethod.Text) > 0 Then
                        score = ligne.Substring(ligne.IndexOf(" score cp ") + 10)
                        score = Format(CSng(score.Substring(0, score.IndexOf(" "))) / 100, "0.00")
                    ElseIf InStr(ligne, " score mate ", CompareMethod.Text) > 0 Then
                        score = ligne.Substring(ligne.IndexOf(" score mate ") + 12)
                        score = score.Substring(0, score.IndexOf(" "))
                    Else
                        MsgBox("en travaux")
                        End
                    End If
                End If
            End If
        End While
        eval_entree.WriteLine("stop")
        eval_entree.WriteLine("ucinewgame")

        eval_entree.WriteLine("isready")
        ligne = ""
        While InStr(ligne, "readyok") = 0
            ligne = eval_sortie.ReadLine
        End While

        nbAnalysis = nbAnalysis + 1

        Return CSng(score)

    End Function

    '///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Public Function cpu(Optional reel As Boolean = False) As Integer
        Dim collection As New ManagementObjectSearcher("select * from Win32_Processor"), taches As Integer
        taches = 0

        For Each element As ManagementObject In collection.Get
            If reel Then
                taches = taches + element.Properties("NumberOfCores").Value 'cores
            Else
                taches = taches + element.Properties("NumberOfLogicalProcessors").Value 'threads
            End If
        Next

        Return taches
    End Function

    Public Function droite(texte As String, longueur As Integer) As String
        If longueur > 0 Then
            Return VB.Right(texte, longueur)
        Else
            Return ""
        End If
    End Function

    Public Function gauche(texte As String, longueur As Integer) As String
        If longueur > 0 Then
            Return VB.left(texte, longueur)
        Else
            Return ""
        End If
    End Function

    Public Function maxMultiPVMoteur(chaine As String) As Integer
        maxMultiPVMoteur = 200
        If InStr(chaine, "asmfish", CompareMethod.Text) > 0 Then
            maxMultiPVMoteur = 224
        ElseIf InStr(chaine, "brainfish", CompareMethod.Text) > 0 _
            Or InStr(chaine, "brainlearn", CompareMethod.Text) > 0 _
            Or InStr(chaine, "stockfish", CompareMethod.Text) > 0 _
            Or InStr(chaine, "cfish", CompareMethod.Text) > 0 _
            Or InStr(chaine, "sugar", CompareMethod.Text) > 0 _
            Or InStr(chaine, "eman", CompareMethod.Text) > 0 _
            Or InStr(chaine, "hypnos", CompareMethod.Text) > 0 _
            Or InStr(chaine, "judas", CompareMethod.Text) > 0 _
            Or InStr(chaine, "aurora", CompareMethod.Text) > 0 Then
            maxMultiPVMoteur = 500
        ElseIf InStr(chaine, "houdini", CompareMethod.Text) > 0 Then
            maxMultiPVMoteur = 220
        ElseIf InStr(chaine, "komodo", CompareMethod.Text) > 0 Then
            maxMultiPVMoteur = 218
        End If

        Return maxMultiPVMoteur
    End Function

    Public Function nbCaracteres(ByVal chaine As String, ByVal critere As String) As Integer
        Return Len(chaine) - Len(Replace(chaine, critere, ""))
    End Function

    Public Function nomFichier(chemin As String) As String
        Return My.Computer.FileSystem.GetName(chemin)
    End Function

    Public Function trierChaine(serie As String, separateur As String, Optional ordre As Boolean = True) As String
        Dim tabChaine() As String

        tabChaine = Split(serie, separateur)
        If tabChaine(UBound(tabChaine)) = "" Then
            ReDim Preserve tabChaine(UBound(tabChaine) - 1)
        End If

        Array.Sort(tabChaine)
        If Not ordre Then
            Array.Reverse(tabChaine)
        End If

        Return String.Join(separateur, tabChaine)
    End Function

    Public Function trierTableau(tableau() As String, Optional ordre As Boolean = True) As String()
        Dim tabChaine() As String

        ReDim tabChaine(UBound(tableau))
        Array.Copy(tableau, tabChaine, tableau.Length)

        Array.Sort(tabChaine)
        If Not ordre Then
            Array.Reverse(tabChaine)
        End If

        Return tabChaine
    End Function

End Module

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Fri Oct 04, 2024 3:18 pm

Agarta 040623.bin :
Image

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Sat Oct 05, 2024 12:19 pm

Agarta 040623.lst :

Code: Select all

0,00/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 c8d7 b2b4 b7b6 a2a4 a7a6 e2d4 c5d4 c3a2 a6a5 b4b5 e7e5 f1e2 d8f6
0,00/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 c8d7 b2b4 b7b6 a2a4 a7a6 e2d4 c5d4 c3a2 a6a5 b4b5 e7e5 f1e2 d8h4
0,00/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 c8d7 b2b4 b7b6 a2a4 a7a6 e2d4 c5d4 c3a2 a6a5 b4b5 e7e5 f1e2 f7f5
0,00/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 c8d7 b2b4 b7b6 a2a4 a7a6 e2d4 c5d4 c3a2 a6a5 b4b5 e7e5 f1e2 g7h6 f2f4 e5f4 h2h4 f7f5 a2c1 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08/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 c8d7 b2b4 b7b6 a2a4 a7a6 e2d4 c5d4 c3a2 a6a5 b4b5 e7e5 f1e2 a8c8
0,08/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 d4c6
0,09/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 h7h5
0,14/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 h7h5
0,15/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 e7e6
0,15/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 h7h6
0,20/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 b7b6
0,26/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 b7b6
0,40/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 b7b6
0,45/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 g8f6
What does "0,45/26 : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2 g8f6" mean ?
position : c2c4 c7c5 e2e4 b8c6 b1c3 d7d6 g1e2 c6d4 a1b1 g7g6 d2d3 f8g7 c1d2
move : 7. ... Nf6 {0,45/26}
Even by respecting the moves of the BIN book (which plays as white), it managed to find a slight advantage for black.

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Sun Oct 06, 2024 10:30 am

CallMeX 011122.bin :
Image
Look at the move 20/38 : e7e5 {1.57/26}...

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Tue Oct 08, 2024 7:16 pm

user wrote: How to avoid lines from book's moves which have a very low percent ?
Go to "modFonctions.vb" => "listBookMoves" then change the value "1" by what you want.
This is a percentage threshold that allows you to keep or not the book's moves.

Default setting : all the book's moves with a percent > 1%

Code: Select all

If 1 < 100 * (CInt(tabPoids(i)) / totalPoids) Then
        lstMoves = lstMoves & tabMoves(i) & ", "
End If
Custom setting : all the book's moves with a percent => 20%

Code: Select all

If 20 <= 100 * (CInt(tabPoids(i)) / totalPoids) Then
        lstMoves = lstMoves & tabMoves(i) & ", "
End If

User avatar
deeds
Posts: 934
Joined: Wed Oct 20, 2021 9:24 pm
Location: France
Contact:

Re: Bruteforce_binbook

Post by deeds » Tue Oct 08, 2024 7:33 pm

user wrote: How to avoid drawish lines in the LST file ?
Go to "modMain.vb" => "main" then change the code like this :

Default setting : all the lines are kept

Code: Select all

ElseIf bookMoves = "" Then
    bookMoves = "out-of-book"
    nbOutOfBooks = nbOutOfBooks + 1
    tabPositions(indexPosition) = tabScores(indexPosition) & " : " & tabPositions(indexPosition)
End If
Custom setting : only the lines evaluated over 50 cp for black are kept

Code: Select all

ElseIf bookMoves = "" Then
    bookMoves = "out-of-book"
    If 0.5 < CSng(tabScores(indexPosition).Substring(0, tabScores(indexPosition).IndexOf("/"))) Then
        nbOutOfBooks = nbOutOfBooks + 1
	tabPositions(indexPosition) = tabScores(indexPosition) & " : " & tabPositions(indexPosition)
    Else
        tabPositions(indexPosition) = ""
        tabScores(indexPosition) = ""
    End If
End If

Post Reply