Questions tagged [programming]

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

Filter by
Sorted by
Tagged with
5
votes
2answers
528 views

Chess Engine: Generate a Bitboard of Pinned Pieces

I'm currently working on a chess engine and have a pseudo-legal move generator working. I'm looking for a way to efficiently generate a bitboard of pinned pieces, so I could skip them when generating ...
2
votes
1answer
128 views

Chess Engine Using LazySMP

I was hoping to parallelize the chess engine I was currently working on. I have done some research on some of the various types of algorithms such as YBWC, ABDADA, and LazySMP which is currently used ...
21
votes
6answers
10k views

What prevents chess engines from being undetectable?

I see accounts of people getting banned from sites like chess.com for using engines like Stockfish and Komodo (I admit I have used these engines before, but never in an actual match). Now, I believe ...
0
votes
1answer
60 views

Search function for chess engines

I'm creating a bitboard based chess engine in c++ and I'm trying to write the search function. It currently looks something like this double search(Position& pos, int depth, double alpha, double ...
5
votes
1answer
341 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 ...
7
votes
3answers
5k views

Representing Moves found via BitBoards, applying them, and removing them

I understand how to find all valid moves for all pieces on the board. For example I know that a certain knight can hit all of the 1's in this board 01000000 00100000 N0000000 00100000 01000000 ...
1
vote
1answer
54 views

Evaluation function in a bitboard based chess engine

How do you go about writing an evaluation function for a bitboard bases chess engine? I want to start of simple and only evaluate based on piece value, and where the pieces stand. For example a knight ...
-7
votes
2answers
281 views

Ok fine, how do I answer questions like records for youngest to obtain a certain title?

A. Background: Under Mobeus Zoom's suggestion here: List of records for youngest superGMs since 1950? (or 1970 or whenever FIDE started rating people. or basically after 2700s after Fischer) (this is ...
2
votes
0answers
91 views

Understanding Null move pruning

I have trouble understanding null move pruning. I understand the concept of a free move for the side that just played a move, but what I don't understand is the code part: int score = -negamax(-beta,-...
1
vote
1answer
57 views

Bitboards and sliding piece attacks

I have been searching about bit boards and piece attacks. The concept of using a bitwise and to find the set of attacked pieces (ie: knightAttackSet & opponentPieces) is really elegant and ...
1
vote
0answers
79 views

Is this a possibly faster way to find pinned pieces using magic hash?

Okay so this is something that I came up with while working on my own engine, but I am not sure if anyone has ever tried. Basically I am using a separate set of magic hashed longs to store pieces and ...
8
votes
2answers
3k views

Is there an online chess evaluation engine with a REST API?

Is there an online chess evaluation engine with a REST API? I'd like to be able to send a game or position (with castling ability presumably) to a simple REST API and get back the positional ...
3
votes
1answer
132 views

How do 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 ...
4
votes
2answers
859 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('...
9
votes
1answer
2k views

Find magic numbers for bitboards

I am writing a C++ chess engine and I am looking for magic numbers for Little-Endian Rank-File Mapping bitboards to generate moves for sliding pieces. The rival chess website gives magic numbers but ...
5
votes
3answers
4k views

What's the right approach of storing moves generated using bitboards?

I am building a chess engine from scratch using bitboards and, so far I am able to generate pawns moves. But, I am stuck on what should I do after finding all possible moves for pawns. Right now the ...
3
votes
1answer
253 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 ...
1
vote
0answers
141 views

Magic bitboards not speeding up my engine

I'm new to writing chess engines but just recently finished my first program. It ran slowly however so I switched over to bitboards, and now to magic bitboards. I used the chess programming wiki a lot....
4
votes
1answer
310 views

How do I complete this implementation of magic bitboards?

I'm currently coding a chess engine in C++, and have run into a bit of trouble with my magic bitboard implementation. So far, I have a function that calculates blockerBoards (all the possible pieces ...
1
vote
1answer
198 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
1answer
129 views

How can I convert a possible pieces' moves to an actual move in a bitboard?

If I have a bitboard (e.g. for knight squares he can move to) like this: 00000000 00000000 00000000 00000000 00000000 01000000 00100000 N0000000 How can I "convert" it into a move or "...
10
votes
5answers
2k views

Is the dead position problem solvable?

In chess, there are some dead positions (FIDE Laws of Chess). 5.2.2 The game is drawn when a position has arisen in which neither player can checkmate the opponent’s king with any series of legal ...
2
votes
0answers
38 views

How can I query an endgame tablebase for multiple positions using loops/conditional statements?

In textbooks you find diagrams about key squares and similar concepts. For example, white can promote a pawn if white's king can control three particular squares infront of the pawn. I would like to ...
3
votes
1answer
118 views

Position Similarity Metrics

I'm looking for metrics that quantify how similar/different two positions are. I have found a paper that used pawn structures to search for similar games in a database. This one tries to use reachable ...
1
vote
0answers
80 views

Why is futility pruning causing an Elo drop in my engine?

I'm getting weird results when introducing futility pruning into Blunder. On the one hand, I'm getting a pretty sizeable reduction in nodes, and I'm searching a full ply deeper for some positions (e.g....
4
votes
2answers
192 views

Techniques used for Stockfish engine selectivity

Example puzzle (I'm sure there are numerous that fit this bill): [FEN "rnbq3r/pppp4/3b1pkp/5p2/2BP4/4P3/PPP2PPP/RN1QK2R w KQ - 0 1"] [Site "Earth"] [White ""] 1. Qh5+ ...
3
votes
2answers
136 views

How can I use JaVaFo in my pairing program?

JaVaFo is the official pairing engine for certifying implementations of the Dutch pairing algorithm for Swiss tournaments. When I look at FIDE's list of endorsed pairing programs I see that most of ...
4
votes
0answers
139 views

How engines accomplish calculation speeds of 1000kN/s per Core and above?

I am developing a chess engine to improve my Cpp. It works, which means it generates legal moves and it can play them out. I optimized a bit and now achieve ~20k N / s, which is way better than my ...
14
votes
2answers
4k views

Which methods can be used to prove that a position is illegal?

Given a board position, there are programs that try to find a series of legal moves that lead to it. Are there algorithms that can do the opposite - prove that the position is not reachable by a ...
14
votes
2answers
3k 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 ...
8
votes
2answers
2k views

Is it normal for a chess engine to blunder material if its evaluation is only based on naive material evaluation?

For the past couple of weeks, I've been making a chess engine, and right now I'm working on creating its search and evaluation phases. To start off with, I made the evaluation phase a simple count of ...
8
votes
2answers
3k views

How to create your own opening book for your own chess engine?

I am currently working on a chess engine in Java. I am using the minimax algorithm with alpha-beta pruning to select the best move. However, it is inefficient to use the algorithm for selecting ...
4
votes
2answers
2k 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 ...
8
votes
4answers
6k views

What is the optimal way to use Stockfish programmatically?

I have Stockfish compiled on my machine. Instead of just running the Stockfish program in the terminal, is it possible to interact with it in a separate program? For example, some basic things I ...
19
votes
3answers
6k views

Given a legal chess position, is there an algorithm that generates a series of moves that lead to it?

Given a FEN board position, is there an alhorthim that can return a PGN move list that evaluates to it from the initial position?
3
votes
1answer
175 views

How can a check evasion move generation algorithm be done efficiently?

In my chess engine, I'm attempting to create a strictly legal move generator, instead of generating pseduo-legal moves, then discarding them later in the search and evaluation phase. So far, here is ...
4
votes
1answer
696 views

Problems with computing the Zobrist hash for a chess position?

I'm attempting to use Zobrist hashing in my chess engine, but I'm running into some difficulties getting it to work correctly. I'm using the random numbers from this site so I can test my results ...
2
votes
1answer
271 views

How can I make my chess engine more efficient?

First, here's some context. My chess engine uses bitboards and works like this: A single gameboard is created as a 2d array at the start of the program. Like this: [[-4 -2 -3 -5 -6 -3 -2 -4] [-1 -1 -...
2
votes
3answers
813 views

When to use Clear Hash

I am developing a program that analyzes games sequentially, i.e. one game after another. Below are the parameters. Engine: Stockfish 10 Threads: 2 Hash Table: 4000 Depth: 30 My question is about ...
25
votes
4answers
9k 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)?
4
votes
2answers
149 views

Looking for an opening where stockfish puts out a queen early

I am by no means a chess person (like 1200 haha). I am designing a computer science challenge where the player has to find a bug in my chess program to beat stockfish in a game of chess. The bug is ...
18
votes
1answer
3k views

What if both players always play the worst engine move?

There are questions for the worst opening in chess and the worst opening in Chess960, but these only consider the very first move. I'm curious what a game would look like where white plays the worst ...
6
votes
2answers
16k 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 ...
5
votes
1answer
219 views

Obtain information about a a position from Stockfish

I want to know from Stockfish: All possible moves in a position, a.k.a. a depth 1 analysis with no score. If the king is in check, is checkmated, or if there is a draw. The current FEN string, after ...
3
votes
1answer
120 views

Live statistics chess960 from chess.com?

Cross-posted stackoverflow, but nothing. Both lichess and chess.com have the feature to play the variant chess960 live. However, only lichess has a graph showing how your live chess960 rating has ...
2
votes
3answers
285 views

How do convert/parse/extract data from a PGN into a spreadsheet/google sheet/excel file?

Sequel to this question: Live statistics chess960 from chess.com? So suppose I go to like https://api.chess.com/pub/player/gmwso/games/2020/12 or https://api.chess.com/pub/player/gmwso/games/2020/12/...
3
votes
2answers
2k views

Program that will give all available moves given the state of a board, including check

I am trying to write a program that will give out every possible move for every piece (one move deep) given the state of a board. I have already done this such that it works with everything except ...
13
votes
1answer
5k views

Stockfish evaluation of a position from PGN

I am trying to get Stockfish's evaluation of a board position(which is in PGN format) using command line.I know it accepts board position in FEN format, but is there any way i can provide PGN format? ...
2
votes
2answers
1k 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 ...
12
votes
11answers
7k views

Do chess programmes keep a history of the full board for each move?

I am creating a chess GUI for UCI engine as a hobby. I keep the history of moved positions (e.g., (4,6) -> (4,4) for the pawn in front of the white king moving forward 2 squares) and the type of ...

1
2 3 4 5