Questions tagged [programming]

Questions related to all aspects of writing software related to chess.

Filter by
Sorted by
Tagged with
2
votes
1answer
54 views

Getting wrong results in perft stats with checks and mates

The perft count works well after testing with many positions from epd files from the web Now I want to see some perft stats like this one: https://www.chessprogramming.org/Perft_Results, from the ...
3
votes
1answer
48 views

How to watch PGN at different speeds?

I am looking for a program for Windows or an online service for viewing PGN at variable speed. I know that lichess has fast and slow speed, but I want more adjustable settings.
3
votes
1answer
61 views

How to I apply moves (bitboard) and continue searching? My current attempt is throwing a strange error!

Explanation I have a list of all possible current moves in a position. At each node, I want to then generate all possible moves and continue. The problem is that my code is modifying the list of moves ...
3
votes
2answers
100 views

Compiling Stockfish to disable own castling while allowing opponent castling

For artistic purposes, I would like to create and study engine games in which only one side is able to castle. For this, I need to compile a version of Stockfish which never castles, and doesn't ...
5
votes
4answers
649 views

Extract anonymized games out of a pgn

I'm a big fan of pgn-extract, but I am open to other linux-friendly tools. I have a big pgn file (over 5 million games) and a set of ECO codes. My goal is to fetch all the games matching those ECO ...
1
vote
0answers
50 views

Magic bitboards: My indexing doesn't seem to work!

I am beginning to understand magic bitboards. I have successfully implemented them with Rooks, and I am currently working with Bishops. The method is very similar though. Problem I have a bishop on g7 ...
1
vote
1answer
53 views

How to store moves for a magic bitboard system?

I am currently trying to implement magic bitboards into my chess engine. Let's just talk about rooks here. Given a square, what I can currently do is: -Calculate the sliding moves on an empty board. ...
2
votes
0answers
38 views

Multi-thread performance

I'm implementing multi-thread in my engine but I think I'm not getting the expected performance boost. Below are the results from the initial position to depth 10. The single thread version takes ...
3
votes
0answers
48 views

Probability of given position/piece configuration

I'm currently working on an image based FEN generator. I found a paper doing the same and they have used Stockfish to calculate the most probable piece configurations. Now I wonder if Stockfish has ...
4
votes
1answer
102 views

Trapped Rooks: Does Stockfish penalize more if the king can't castle temporarily?

In this talkchess thread, they discuss trapped rooks and castling rights. In post #5, user @Lyudmil Tsvetkov posted: I would give at least some 10-15cps for temporary prevention of castling. Here is ...
1
vote
1answer
73 views

Using Stockfish in an automated way, for example, to analyze games in pgn format

I am looking for a way to use Stockfish for an automated analysis of games which I have in pgn format. Similar to Fritz/Chessbase's Blunder Check function I would like Stockfish (or any other UCI ...
1
vote
1answer
26 views

Static null move CPW engine

I have two questions about a code implementing a static null move. The questions are in the code. The code is extracted from here: CPW engine search code if (depth < 3 && !...
1
vote
0answers
19 views

Script for finding undefended pieces

I am looking for a script/code/CQL that searches for undefended pieces in a given position. I know that is possible to do it in the python chess library, but that is too complicated for me. Is there ...
5
votes
1answer
221 views

Is there a list of approximate ELO ratings for each Stockfish level?

I want to create something that will select an appropriate Stockfish difficulty setting automatically given the player's rating. The straight Stockfish v11 that I've downloaded has 20 difficulty ...
2
votes
1answer
67 views

Engine is evaluating the same position at the same depth with different score

My engine is evaluating the same position at the same depth with a different score inside the search tree, is that normal? [Title "depth 1 ply 3 alfa -20 beta -15 score -15 (1.Na3 a5 2.Nh3)"] [FEN ...
3
votes
2answers
98 views

Discovered attack in quiescent search

I'm implementing quiescent search in my chess engine, although just capturing moves have been generated. In the below position, at 1 ply, the white queen captures the pawn, but the quiescent search ...
5
votes
2answers
173 views

Stockfish draw value randomization and “3-fold blindness”

In this commit, a change was made to the way Stockfish scores board positions that are draws due to 3-fold repetition or 50-move limits. Prior to this commit, a drawn position was assigned a score of ...
2
votes
1answer
118 views

Is this implementation of Killer Move heuristic correct?

I implemented the killer move heuristic based on my understanding, but is it correct? Inserting a killer move when a non-capture causes a beta cutoff (i is a Move pointer) // Stuff if(val >= beta){...
1
vote
1answer
151 views

Chess Engine: Faster Move Generation

Introduction I'm in the process of rewriting my chess engine for better performance. I've started with the move generation function first. I've been looking at this person's article (Their Article) ...
4
votes
1answer
99 views

Creating a New Neural Network for chess

I'd like to have my own chess engine similar to Leela for personal use. I’d want it to have a decent strength, let’s say 2k, and be able to play with it. I'm wondering if I can use Leela to create a ...
2
votes
1answer
102 views

Quickly converting board to bitboard representation using python-chess library

I would like to convert a given chess board into its bitboard representation, but my implementation is rather slow. Here is what I'm doing (using the python-chess package): board = chess.Board('...
15
votes
2answers
2k views

How do chess engines decide which best line to play when the game outcome is within their horizon?

Inspired by the Hot Network Question "In this puzzle, why does white play dxe5?", when a chess engine is in a position that it can definitively call lost, drawn, or won, what policy is used to decide ...
2
votes
1answer
108 views

How can I increase the search ply depth of my minimax function for my chess engine?

I have programmed a minimax function with alpha-beta pruning for a chess engine I am building. However, it is very slow and I cannot analyze to a deeper depth as it would take too much time. I believe ...
2
votes
1answer
127 views

Magic Bitboards, Feeding in Randoms - Why have to find magic instead of just loading from disk?

I read about Looking for Magics for Magic Bitboard, they mentioned the method "Feeding in Randoms". As I understand, this method works like this: label RETRY; magic = random();//trial for (all ...
4
votes
1answer
605 views

How to use Polyglot opening book bin file

I previously asked how to use polyglot in c# with a chess engine. My question then was not accurate. What I want to know is, what property(ies) of the bin file object I need to do the following: I ...
0
votes
1answer
1k views

Stockfish 11 for Android - binaries

I have an Android app that uses precompiled binary files of Stockfish. There are both arm64-v8a and armeabi-v7a binary files for direct use in version 10. On Stockfish site there's however not such ...
2
votes
1answer
60 views

Question on how to access a move on a line outside the main line using python-chess

I'm trying to write a simple code that is capable of reading a PGN file and searching for moves and comments throughout the variant tree. However, I have not been successful, I have not yet been able ...
2
votes
1answer
226 views

Communication with Stockfish engine via Python

I try to access the Stockfish engine via Python, but only get bestmove = a2a3. If I enter the same commands into the MAC-terminal, the engine calculates the correct move. Can anyone help me, please ?...
1
vote
1answer
127 views

PythonChess - Get engine to predict a list of the best moves in a position

Say that I currently have a board, and then on that board I move my e2 pawn to e4. I'm looking for a way to get the engine to predict the X amount of best moves for black. I know how to predict the ...
2
votes
1answer
68 views

Best way to loop through all possible moves (Alpha Beta)?

Essentially I'm just trying to create a somewhat efficient chess ai using an Alpha Beta Pruning approach for a future neural network to train against. I know I could use an existing program but this ...
1
vote
2answers
55 views

Alpha-beta add variance/handicap

I want to implement a handicap for my engine and I'm struggling with it. I using alpha-beta pruning. In my current approach I set a variance variable in centipawns and let the engine choose a move in ...
4
votes
1answer
333 views

Is there a method to efficiently generate moves for bishops?

I currently have a function which returns the closed off squares for a piece in a particular position based on pieces blocking it. This function iterates over the rays of a piece and is sufficiently ...
2
votes
1answer
344 views

Is there Python code to use the Leela neural network?

I am interested in doing some analyses of chess games using the neural network trained for Lc0. To that end I need to be able to turn PGN into the right kind of input vectors and to load and use the ...
3
votes
1answer
266 views

Python script to let stockfish selfplay 10 games from a given position

I would like to have Stockfish to selfplay 10 games starting from a given position. Game should end after 10 moves. From the python-chess documentation there is an example of playing only one such ...
2
votes
1answer
204 views

Faster bit-board implementation in Javascript

In a previous question I asked, linked here: How can I speed up my check detection in Javascript? I was told to implement bit-boards to speed up my engine. I can say that bit-boards have improved my ...
1
vote
1answer
225 views

Chess move generation with bit boards in Javascript

To make my engine more efficient, I am writing my engine such that it uses bit-boards in its move generation. But I have a question, suppose I have a rook move mask centered at a specific spot, how ...
24
votes
4answers
8k views

What is the worst opening move in Chess960 for White?

Is there a first move for white in Chess960 in which white can immediately blunder a piece or lose a significant advantage (say -2.0 or so)?
5
votes
1answer
132 views

How can I speed up my check detection in Javascript?

I am trying to write a simple chess engine in Javascript. It performs very slowly but I have finally rooted down the problem to check detection. How might I speed up this check detection? If you have ...
4
votes
1answer
200 views

Are these magics wrong?

I am working on my chess engine and wanted to finally implement magic bitboards to get a huge increase in performance. Basically I was writing a method to check if a number can be used as a magic for ...
6
votes
2answers
197 views

Does the PGN specification mistakenly omit solidus (/) for symbol tokens?

The Portable Game Notation (PGN) specification appears to contradict itself regarding the valid characters that may appear in a symbol token. From [1], section 7, quote: A symbol token starts with ...
3
votes
2answers
108 views

A script that can create a chess tree from an EPD file

Is there any script (any language) that can make a chess tree from an EPD file? Or what algorithm (any example) should be use to create it on my own? I am looking for one like the Chessbase opening ...
3
votes
1answer
170 views

Compile StockFish optimized for arm64-v8a

I cloned StockFish from GitHub and did a make inside the src folder and found that supported archs are: x86-64-bmi2 > x86 64-bit with pext support (also enables SSE4) x86-64-modern ...
2
votes
1answer
156 views

Debugging my chess engine through the Arena GUI

I coded (with visual studio 2019 on windows 10) an ultra naive chess engine that complies with UCI engine interface rules. Before starting to develop it in more fancy ways, I want to make sure that I ...
3
votes
2answers
494 views

Minimax with alpha-beta pruning for chess

I am creating a chess AI using the minimax method with alpha-beta pruning. I am trying to understand how the alpha-beta pruning works, but I can't get my head around it when it comes to chess where ...
4
votes
1answer
78 views

How to count pieces from PGN notation?

I am trying to figure out an algorithm to extract the number of each piece that both black and white have from a PGN file. Right now I have all of the moves tokenized(i.e. c("e4", "d6", "Nc3", "f5", ...
4
votes
2answers
239 views

How to calculate pinned chess moves

I am writing a legal move generator, and the last piece of the puzzle is preventing pinned pieces from being moved such that the king will be in check. I have read a lot of posts here and on ...
1
vote
1answer
177 views

How to write an interface to lichess for a millenium board using chesslink?

I am aware of the python chess and chesslink mchess work but would like to attempt to interface it with lichess.org. My purpose would be to play others on lichess using my Millenium board. The API'...
3
votes
2answers
77 views

Creating program for finding top players with respect to elo and age

I want to create a program for personal use but also maybe for publishing it on the web, in order to detect the top players with respect to elo and age. There will be two cases: A) In this case, ...
4
votes
4answers
904 views

Help with game phase identification

I'm working on a chess AI for a school project and I am looking into ways to identify the current phase of a board, meaning the opening, middlegame, and endgame. I have seen an article explaining ...
3
votes
3answers
192 views

File format/interface for home-brew engines (and implementation in lichess)

I'm a hobbyist chess programmer. I've built a few engines from scratch, had lots of fun, and am generally pretty proud of what I've made (I estimate ~1400-1500 though it's hard to tell). I was very ...