Chess Tools

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Chess Tools, MEA

Post by Ferdy »

MEA v0.6.0 is released at https://github.com/fsmosca/Multiple-mov ... r/releases
mea.exe is in mea.zip file.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Chess Tools, MEA

Post by Ferdy »

Ferdy wrote: Sat Aug 31, 2019 5:39 pm MEA v0.6.0 is released at https://github.com/fsmosca/Multiple-mov ... r/releases
mea.exe is in mea.zip file.
Sample tests with tony-pos.epd

Image


tony-pos.epd
https://privat.bahnhof.se/wb432434/fentest.htm

Code: Select all

1r2r1k1/1pqbbppp/p2p1n2/4p3/P3PP2/2N1BB2/1PP2QPP/R4R1K b - - bm Rbc8; c0 "positional scores are: Rbc8=10, exf4=9, Bc6=7, Rec8=6, b6=6, b5=5, Be6=4, h6=3"; id "tony.pos.01";
r1bk1bnr/ppp2ppp/8/4n3/2P5/P3B3/1P3PPP/RN2KBNR w KQ - - bm Nf3; c0 "positional scores are: Nf3=10, Nd2=9, Nc3=7, Be2=6, Bf4=4, f4=3, h3=3"; id "tony.pos.02";
8/7p/3k2p1/6P1/4KP2/8/7P/8 w - - bm h4; c0 "positional scores are: h4=10, Kf3=8, Ke3=6, Kd4=6, Kd3=6, h3=5"; id "tony.pos.03";
r1b1r1k1/1p1n1pbp/2p1n1p1/q1P1p3/4P3/1PN1BNPP/2Q2PB1/1R1R2K1 w - - bm Rb2; c0 "positional scores are: Rb2=10, Na4=8, b4=7, Nd2=6, Qb2=5, Bf1=5, Rd2=4, Ne2=3, Kh2=3, Ra1=1"; id "tony.pos.04";
1rN1r1k1/1pq2pp1/2p1nn1p/p2p1B2/3P4/4P2P/PPQ1NPP1/2R2RK1 b - - bm Rexc8; c0 "positional scores are: Rexc8=10, Rbxc8=7, Qxc8=7"; id "tony.pos.05";
3r1rk1/p1q2pbp/1np1p1p1/1p2P3/5P2/2N2Q1P/PPP3P1/3RRBK1 b - - bm Rxd1; c0 "positional scores are: Rxd1=10, f5=9, Na4=7, Nd5=5, a6=5, f6=4, g5=3"; id "tony.pos.06";
r2r2k1/p3ppbp/1p4p1/3p4/3P4/2P1P2P/P3BPP1/2R2RK1 w - - bm f4; c0 "positional scores are: f4=10, Ba6=8, c4=7, a4=5, Rfd1=4"; id "tony.pos.07";
2rq3r/pb1pbkpp/1p2pp2/n1P5/2P5/QP2BNPB/P3PP1P/3R1RK1 w - - bm b4; c0 "positional scores are: b4=10, Nd4=8, Rd2=5, Qc1=5"; id "tony.pos.08";
1r1q1rk1/pp1bbppp/2n1p1n1/4P3/2BpN3/3P1N2/PP2QPPP/R1B1R1K1 b - - bm b5; c0 "positional scores are: b5=10, Ngxe5=9, Ncxe5=9, Qc7=8, Na5=7, a6=6, h6=5, f6=3"; id "tony.pos.09";
3r2k1/2p2ppp/1p1br3/pPn5/3PP3/P7/1B1N2PP/R3R1K1 w - - bm Re2; c0 "positional scores are: Re2=10, d5=8, Nc4=7, e5=6, dxc5=5"; id "tony.pos.10";
r4rk1/p2qn1bp/1pnp2p1/2p2p2/4PP1N/2PPB3/PP2QN1P/R4RK1 b - - bm d5; c0 "positional scores are: d5=10, Bh6=8, Rae8=7, fxe4=5"; id "tony.pos.11";
r3r1k1/1b1n1p2/1q1p1n1p/2p1p2P/p1P3p1/P1QNPPB1/1P2B1P1/2KR3R w - - bm e4; c0 "positional scores are: e4=10, Rh4=8, Nf2=7, Qd2=6, Qc2=5, Bh4=4, Kb1=3"; id "tony.pos.12";
1rb1nrk1/2q1bppp/p1n1p3/2p1P3/2Pp1PP1/3P1NN1/P5BP/R1BQ1RK1 w - - bm Nd2; c0 "positional scores are: Nd2=10, Qe1=9, Qe2=8, Ne4=7, f5=6, Nh5=6, g5=6, h4=5, Bd2=4, Bh3=3, Re1=1"; id "tony.pos.13";
r3r1k1/ppqbbpp1/2pp1nnp/3Pp3/2P1P3/5N1P/PPBN1PP1/R1BQR1K1 w - - bm Nb1; c0 "positional scores are: Nb1=10, Rb1=9, Nf1=8, dxc6=5, Nb3=5, b3=4, a3=3, b4=2"; id "tony.pos.14";
5r1k/1q2rnpp/p4p2/1pp5/6Q1/1P3P2/PBP3PP/3RR1K1 w - - bm Re6; c0 "positional scores are: Re6=10, Kf2=9, h4=6, f4=5, Rxe7=4"; id "tony.pos.15";
2r2k2/5p2/2Bp1b1r/2qPp1pp/PpN1P3/1P2Q3/5PPP/4R1K1 w - - bm Rc1; c0 "positional scores are: Rc1=10, Nb6=8, Qxc5=7, a5=6, Qf3=5, h4=4, Nxe5=2"; id "tony.pos.16";

Example command line on Crafty:

Code: Select all

mea.exe --engine "C:\chess\engines\Crafty\Crafty_25.2\Crafty_25.2_x64" --stmode 1 ^
--name "Crafty 25.2" --hash 128 --protocol xboard --protover 2 --san 1 ^
--epd tony-pos.epd --movetime 5000 --output tony.txt --log

Example command line on Lc0:

Code: Select all

mea.exe --engine "C:\chess\engines\lc0\lc0-v0.22.0-windows-blas\Lc0.exe" ^
--name "Lc0 v0.22.0 w11258-80x7 blas" --threads 1 ^
--eoption "smartpruningfactor=0,ramlimitmb=1024,weightsfile=C:\chess\engines\lc0\id\11258-80x7-se.pb.gz" ^
--epd tony-pos.epd --movetime 5000 --output tony.txt --log

Example command line for Stockfish UCI_Elo 2600:

Code: Select all

mea.exe --engine "C:\chess\engines\stockfish\stockfish_19082608_x64_modern.exe" ^
--name "Stockfish 19082608 UCI_Elo 2600" --hash 128 ^
--eoption "UCI_LimitStrength=true,UCI_Elo=2600" ^
--protocol uci --epd tony-pos.epd --movetime 5000 ^
--output tony.txt --log

Example command line for SmarThink using infinite flag:

Code: Select all

mea.exe --engine "C:\chess\engines\smt198\SmarThink_v198_x64_SSE3_standalone.exe" ^
--name "SmarThink v1.98" --infinite --hash 128 ^
--protocol uci --epd tony-pos.epd --movetime 5000 ^
--output tony.txt --log
Zenmastur
Posts: 919
Joined: Sat May 31, 2014 8:28 am

Re: Chess Tools

Post by Zenmastur »

I have a games collection which result in pawnless endgames. The problem is I want only those with 7-pieces or more. Is there a tool (or some technique (to many to do manually)) that would be able to pull just the PGNs that have 7 or more pieces with no pawns?

Regards,

Zenmastur
Only 2 defining forces have ever offered to die for you.....Jesus Christ and the American Soldier. One died for your soul, the other for your freedom.
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Chess Tools

Post by Dann Corbit »

Code: Select all

#include <stdio.h>
#include <string.h>

char string[32767];
char strang[32767];
// This requires EPD, and not PGN, but it will leave only positions with 7 chessmen or less.
//
int count_chessmen (char *string)
{
    int count = 0;
    static const char key[] = "prnbkqPRNBKQ";
        char *black = strstr(string, " b ");
    char * where= strpbrk (string, key);
        strcpy(strang, string);
        if (black) *black = 0;
    while (where != NULL && *where != ' ')
    {
        count++;
        where = strpbrk (where+1,key);
    }
    return count;
}

int main(void)
{
    while (fgets(string, sizeof string, stdin))
    {
        int n = count_chessmen(string);
        if (n <= 7) puts(strang);
    }
    return  0;
}
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Chess Tools

Post by Ferdy »

Zenmastur wrote: Wed Sep 04, 2019 1:49 am I have a games collection which result in pawnless endgames. The problem is I want only those with 7-pieces or more. Is there a tool (or some technique (to many to do manually)) that would be able to pull just the PGNs that have 7 or more pieces with no pawns?

Regards,

Zenmastur
Try this py script, see requirements. It does not care if end position has pawns or not.

Code: Select all

# -*- coding: utf-8 -*-
"""
extract_game_by_material.py

Read pgn and extract games based on material counts at the end position.

Requirements:
    * python 3:
        Download python and install
    * python-chess:
        pip install python-chess
"""

import argparse
import chess.pgn


def process_file(inputfile, matcount):
    """
    Returns games in pgn file based on end position material count.
    Output file write mode is overwrite.
    """
    num_saved = 0
    outfile = 'out_' + inputfile
    
    with open(outfile, 'w') as g:
        with open(inputfile, encoding="utf-8-sig") as pgnh:
            game = chess.pgn.read_game(pgnh)  # Read first game
            while game:
                node = game.end() # Go to the last position
                board = node.board()
                if len(board.piece_map()) >= matcount:
                    g.write('{}\n\n'.format(game))  # Write to output file
                    num_saved += 1
                game = chess.pgn.read_game(pgnh)  # Read next game
                
    print('{} output games are saved in {}'.format(num_saved, outfile))
    

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--input', help='input pgn file', required=True)
    parser.add_argument('--minmatcount', 
                        help='minimum count of material at the last position of a game.',
                        type=int, required=True)
    args = parser.parse_args()    
    process_file(args.input, args.minmatcount)    


if __name__ == '__main__':
    main()

Help:

Code: Select all

python extract_game_by_material.py -h
usage: extract_game_by_material.py [-h] --input INPUT --minmatcount
                                   MINMATCOUNT

optional arguments:
  -h, --help            show this help message and exit
  --input INPUT         input pgn file
  --minmatcount MINMATCOUNT
                        minimum count of material at the last position of a
                        game.

Example command line:

Code: Select all

python extract_game_by_material.py --input my_white_rep.pgn --minmatcount 7

Typical output message.

Code: Select all

4 output games are saved in out_my_white_rep.pgn
Heikoschach
Posts: 3
Joined: Sat Nov 06, 2010 11:27 am

Re: Chess Tools MEA

Post by Heikoschach »

Hello Ferdy,

supported MEA under --eoption all Engine UCI Commands?
Specifically SyzygyPath=C:/TB/Syzygy

Regards
Heiko
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Chess Tools MEA

Post by Ferdy »

Heikoschach wrote: Tue Sep 10, 2019 12:37 pm Hello Ferdy,

supported MEA under --eoption all Engine UCI Commands?
Specifically SyzygyPath=C:/TB/Syzygy

Regards
Heiko
Yes.

Code: Select all

--eoption "SyzygyPath=C:/chess/syzygy"

Code: Select all

[ 2019-09-10 23:11:02,705 -     INFO ] Pos 3
[ 2019-09-10 23:11:02,705 -     INFO ] EPD: 1B1b1k2/1B3npp/1p6/p1p5/8/1P6/P5PP/7K w - - c0 "g3=1";
[ 2019-09-10 23:11:02,705 -     INFO ] id None
[ 2019-09-10 23:11:02,705 -     INFO ] FEN: 1B1b1k2/1B3npp/1p6/p1p5/8/1P6/P5PP/7K w - - 0 1
[ 2019-09-10 23:11:02,705 -     INFO ] Solutions: g3=1
[ 2019-09-10 23:11:02,705 -    DEBUG ] >> ucinewgame
[ 2019-09-10 23:11:02,705 -    DEBUG ] >> isready
[ 2019-09-10 23:11:02,736 -    DEBUG ] << readyok
[ 2019-09-10 23:11:02,736 -    DEBUG ] >> position fen 1B1b1k2/1B3npp/1p6/p1p5/8/1P6/P5PP/7K w - - 0 1
[ 2019-09-10 23:11:02,736 -    DEBUG ] >> go movetime 2000
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 1 seldepth 1 multipv 1 score cp -69 nodes 22 nps 22000 tbhits 0 time 1 pv b7e4
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 2 seldepth 2 multipv 1 score cp -80 nodes 52 nps 52000 tbhits 0 time 1 pv b7e4 g7g6
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 3 seldepth 3 multipv 1 score cp -64 nodes 118 nps 118000 tbhits 0 time 1 pv b8g3 g7g6 b7e4
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 4 seldepth 4 multipv 1 score cp -74 nodes 218 nps 218000 tbhits 0 time 1 pv b8g3 b6b5 b7e4 g7g6
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 5 seldepth 5 multipv 1 score cp -79 nodes 552 nps 276000 tbhits 0 time 2 pv b7e4 g7g6 a2a4 d8e7 b8g3
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 6 seldepth 8 multipv 1 score cp -75 nodes 962 nps 481000 tbhits 0 time 2 pv b7e4 h7h5 h1g1 d8f6 g1f1 b6b5
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 7 seldepth 9 multipv 1 score cp -58 nodes 1332 nps 666000 tbhits 0 time 2 pv b7e4 h7h5 h1g1 d8f6 b8c7
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 8 seldepth 10 multipv 1 score cp -43 nodes 2185 nps 728333 tbhits 0 time 3 pv b7e4 h7h5 h1g1 b6b5 g1f2 c5c4 b3c4
[ 2019-09-10 23:11:02,736 -    DEBUG ] << info depth 9 seldepth 11 multipv 1 score cp -13 nodes 7158 nps 1193000 tbhits 0 time 6 pv b7d5 b6b5 h1g1 d8f6 g1f2 f6b2 b8c7 b2d4 f2f3
[ 2019-09-10 23:11:02,751 -    DEBUG ] << info depth 10 seldepth 14 multipv 1 score cp -30 nodes 22464 nps 1604571 tbhits 0 time 14 pv b7d5 f8e7 h1g1 e7f6 a2a4 f7e5 b8e5 f6e5 d5c4 h7h6 g1f2
[ 2019-09-10 23:11:02,751 -    DEBUG ] << info depth 11 seldepth 15 multipv 1 score cp -27 nodes 43187 nps 1727480 tbhits 0 time 25 pv b7d5 f8e7 h1g1 h7h6 d5c4 f7d6 b8d6 e7d6 c4e2 d6d5 h2h3
[ 2019-09-10 23:11:02,767 -    DEBUG ] << info depth 12 seldepth 17 multipv 1 score cp -32 nodes 71371 nps 1784275 tbhits 0 time 40 pv b7d5 f8e7 h1g1 f7d6 g1f2 h7h5 b8d6 e7d6 d5c4 d8f6 f2g3 g7g5 g3f3 f6e5
[ 2019-09-10 23:11:02,798 -    DEBUG ] << info depth 13 seldepth 21 multipv 1 score cp -41 nodes 132202 nps 1836138 tbhits 0 time 72 pv b7d5 f8e7 h1g1 f7d6 b8d6 e7d6 d5b7 d8f6 b7e4 h7h5 g2g3 f6e5 g1f2 e5c3 f2f3 c3d4
[ 2019-09-10 23:11:02,861 -    DEBUG ] << info depth 14 seldepth 25 multipv 1 score cp -30 nodes 238493 nps 1892801 tbhits 0 time 126 pv b7d5 f8e7 h1g1 f7g5 a2a4 g5e6 b8g3 g7g6 g3e5 d8c7 d5e6 c7e5 e6c4 e7f6
[ 2019-09-10 23:11:02,892 -    DEBUG ] << info depth 15 seldepth 21 multipv 1 score cp -24 nodes 305981 nps 1900503 tbhits 0 time 161 pv b7d5 f8e7 h1g1 f7d6 b8d6 e7d6 d5c4 g7g5 g1f2 d8f6 h2h3 h7h5 f2f3 g5g4 h3g4 h5g4 f3g4
[ 2019-09-10 23:11:02,970 -    DEBUG ] << info depth 16 seldepth 23 multipv 1 score cp -31 nodes 459964 nps 1900677 tbhits 0 time 242 pv b7d5 f8e7 h1g1 f7d6 b8d6 e7d6 d5c4 d6e5 g2g3 d8f6 a2a4 e5e4 c4g8 e4d4 g8h7 c5c4 b3c4 d4c4 h7g6 c4b4 g1f2 b4a4
[ 2019-09-10 23:11:03,157 -    DEBUG ] << info depth 17 seldepth 27 multipv 1 score cp -38 nodes 810789 nps 1898803 tbhits 0 time 427 pv b7d5 f8e7 h1g1 f7d6 b8d6 e7d6 d5e4 g7g6 g1f2 a5a4 f2e3 a4b3 a2b3 d8g5 e3e2 b6b5 g2g3 b5b4 e2d3 g5h6 d3c2
[ 2019-09-10 23:11:03,313 -    DEBUG ] << info depth 18 seldepth 28 multipv 1 score cp -38 nodes 1086640 nps 1893101 tbhits 0 time 574 pv b7d5 f8e7 h1g1 f7d6 b8d6 e7d6 d5g8 h7h6 g8c4 d6e5 g1f2 e5d4 a2a4 d8c7 h2h4 c7d8 h4h5 d4c3 f2f3 d8f6 f3g4 c3b4 g4f5
[ 2019-09-10 23:11:03,469 -    DEBUG ] << info depth 19 seldepth 26 multipv 1 score cp -37 nodes 1385303 nps 1884765 tbhits 0 time 735 pv b7d5 f8e7 h1g1 f7d6 b8d6 e7d6 d5g8 h7h6 g1f2 b6b5 g8f7 c5c4 b3c4 b5b4 f7e8 d6c5 f2e1 d8h4 e1e2 c5c4 e8a4 h4f6 a4b3 c4c5
[ 2019-09-10 23:11:03,609 -    DEBUG ] << info depth 20 seldepth 30 multipv 1 score cp -28 nodes 1647198 nps 1897693 tbhits 0 time 868 pv b7d5 f8e7 h1g1 f7d6 g1f2 d6e8 d5c6 g7g6 a2a4 e8g7 c6d5 h7h6 d5c4 g7e8 c4d3 g6g5 f2f3 e7f6 g2g3 d8c7
[ 2019-09-10 23:11:03,999 -    DEBUG ] << info depth 21 seldepth 30 multipv 1 score cp -22 nodes 2404681 nps 1905452 hashfull 162 tbhits 0 time 1262 pv b7d5 f8e7 h1g1 f7d6 g1f2 d6e8 d5c6 g7g6 h2h3 d8c7 c6e8 c7b8 e8b5 e7d8 f2f3 b8h2 f3g4 h2e5 g4f3 d8c7 f3e4 e5d4 e4f4 d4g1 f4f3
[ 2019-09-10 23:11:04,311 -    DEBUG ] << info depth 22 seldepth 31 multipv 1 score cp -21 nodes 2763904 nps 1752634 hashfull 176 tbhits 10 time 1577 pv b7d5 f8e7 h1g1 f7d6 g1f2 d6e8 d5c6 g7g6 h2h3 d8c7 c6e8 c7b8 e8b5 e7d6 b5c4 d6c6 c4g8 h7h6 f2f3 g6g5 f3g4 c6d6 g4h5 b6b5 h5h6
[ 2019-09-10 23:11:04,733 -    DEBUG ] << info depth 23 seldepth 31 multipv 1 score cp -21 nodes 3578205 nps 1788208 hashfull 212 tbhits 10 time 2001 pv b7d5 f8e7 h1g1 f7d6 g1f2 d6e8 d5c6 g7g6 h2h3 d8c7 c6e8 c7b8 e8b5 e7d6 b5c4 d6c6 c4g8 h7h6 f2f3 g6g5 f3g4 c6d6 g4h5 b6b5 h5h6
[ 2019-09-10 23:11:04,733 -    DEBUG ] << bestmove b7d5 ponder f8e7
[ 2019-09-10 23:11:04,733 -     INFO ] elapsed(ms) since go: 2001
[ 2019-09-10 23:11:04,733 -     INFO ] bestmove: Bd5

Code: Select all

tbhits 10