Questions tagged [programming]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
83 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
101 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
82 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
50 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
83 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
106 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
45 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
51 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
289 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 ...
1
vote
1answer
115 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
110 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
97 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
132 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)?
4
votes
1answer
111 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
0answers
131 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
192 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
95 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 ...
2
votes
1answer
69 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
101 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 ...
4
votes
2answers
161 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
74 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
187 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
96 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
72 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
886 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
185 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 ...
2
votes
2answers
117 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 ...
6
votes
3answers
145 views

How do generic game engines work?

The evaluation functions for chess usually includes chess specific knowledge. However, Zillions of Games is able to play any game based only on a description of how the pieces move and winning/losing/...
1
vote
2answers
174 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 ...
1
vote
2answers
168 views

How many moves can be expressed with algebraic chess notation?

I am wanting to write a chess engine (see here: Creating chess engine, machine learning vs. traditional engine?). The first step I am doing is taking a position in as an FEN and converting this ...
2
votes
2answers
140 views

How can I set up en passant in the Popeye engine?

I want to solve a problem with Thomas Maeder's excellent Popeye engine, and to specify that a possible en passant in the diagram is ok. How can I do this please? The documentation seems opaque. Thanks ...
18
votes
4answers
6k views

Creating chess engine, machine learning vs. traditional engine?

I am both an avid chess player and computer programmer. I would say that playing chess and programming are the two things I spend the most time doing. Naturally, I am wanting to create my own engine ...
2
votes
3answers
189 views

How to use Arena GUI outputs in a python program

I'm currently developing a self-playing chessboard on which I'd like to implement an Artificial Intelligence (AI) (currently it's Stockfish. I would like to know how I could, if I can, export Arena ...
2
votes
2answers
251 views

If a pawn promotes to a checking piece while also revealing a check, it is a double check?

I'm writing a chess engine just for fun, and during the validation of movement generation, I found some positions in Perft Results that differ from what my engine is producing. As an example, take ...
4
votes
1answer
170 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 ...
3
votes
1answer
205 views

Python-chess : Are the move scores enough to rank moves from the most to least likely moves played by an engine?

My goal is to make a script to finding the most and least likely move an engine will play, and then make a list it. I tried using the scores to make such a list, with the best score equalling the most ...
3
votes
1answer
686 views

Python-chess : how to get a list for the best engine moves

I am working on a simple cheat detection script to find if a user used one of the top engine moves in a game, so I found this great python-chess library Additionally, I found this example to getting ...
2
votes
0answers
135 views

Wrong perft result?

I'm writing a chess engine for fun. Currently I'm finishing writing the move generator. During the research I leaned about PERFT for debugging my software. Indeed, I found many bugs, some of them was "...
3
votes
1answer
95 views

What is the format for USCF's Golden Database?

I was wanting to collect some statistics about players, and also just easily update player ratings for my local club. I tried the web crawls on USCF's Member Services Area (even using the thin pages ...
4
votes
1answer
126 views

Leela Chess PUCT Mechanism

How do we know w_i which is not possible to calculate using the tree search only? From the lc0 slide, w_i is equal to summation of subtree of V ? How is this equivalent to winning ?
5
votes
1answer
321 views

Converting from Algebraic notation to Coordinate notation

I saw this thread: Converting square notation to algebraic notation programmatically Unfortunately, it's the reverse of what I need to do. Given a FEN and an Algebraic move, I need to generate the ...
6
votes
2answers
389 views

How to evaluate and comment moves in PGN format?

I want, with Python-chess, to evaluate any movement of some game and generate the PGN with analysis, as Chess.com does in its analysis. For example, i played one game with fools mate and they ...
-1
votes
1answer
256 views

Python and Stockfish [duplicate]

I am trying to get Stockfish to work in Python 3. Just to get started on my project, I tried to have Stockfish think until a depth of 20. However, the program instantly returns that Stockfish ...
2
votes
2answers
466 views

Where is the neural network used in MCTS?

Where does an engine (such as AlphaZero) use its neural network in MCTS? It shouldn't be needed to evaluate positions reached via MCTS, since I'm under the impression that only terminal game states ...
3
votes
2answers
378 views

AlphaZero and the revenge of the Artificial Intelligence

Answering this question, @SmallChess offered this answer: Before Google's chess journey, the chess engine community believed: AI chess will not beat classical programming because neural networks ...
1
vote
2answers
172 views

Testing an engine (UCI) against an older version of itself

I am making modifications to a chess engine. I want to get quick feedback on whether the modified version seems stronger than an unmodified version or not, by fighting the older version multiple ...
2
votes
1answer
117 views

How can I get multiple computer recommended lines in python-chess module?

In python-chess you can communicate with the engine on a given position. However the method presented in https://python-chess.readthedocs.io/en/latest/uci.html using the engine.go() function with only ...
4
votes
2answers
258 views

What's the rationale behind chess engines conditionally allowing threefold repetitions when assigning a draw score?

When a chess engine sees a position p repeated once (i.e. position p occurred twice) it immediately assigns the second occurrence of position p a draw score. This makes sense because position p doesn'...
2
votes
1answer
226 views

Is this the correct flow of a chess game?

I am trying to program a chess game as a challenge to myself, however, I am unsure if I have all the moves correct to play a legal game (not any advanced moves, that would be a challenge for another ...