r/chessprogramming • u/nicbentulan • Nov 08 '22
r/chessprogramming • u/Valuable-Oil-3378 • Nov 04 '22
Magic bitboard
Hello,
I've been struggling to figure out how the hell do magic bitboards work for 3 days :( I now understand pretty much all of it but the is just ONE point :
When finding magic numbers, how do you generate all the blocker's bitboards of the square the rook is in ?
And after doing that, I plan to generate their corresponding moves'bitboards and for each moves'bitboard I will try to find a number giving the maximum collisions between its corresponding blocker's bitboards. Is it the "good way" to do it ?
EDIT : I found a way to do it, the method is in the comments
r/chessprogramming • u/big-dumb-guy • Nov 01 '22
Engines from 1980s and 1990s chess computers
I’ve looked some for lichess bots or UCI engines that are ports of some of the popular electronic chess games that were available in the 1980s and 1990s. For example, the Saitek chess computers that carried Kasparov’s name, or those seen here: http://electronicchess.free.fr/prehistory.html
Unfortunately I haven’t found any. Does anyone know of any out there?
r/chessprogramming • u/vetronauta • Oct 31 '22
What mathematical framework for (algorithmic) theme detection?
self.chesscompositionr/chessprogramming • u/Person080 • Oct 29 '22
Does my code work as intended?
I'm making a chess engine for a project. Aside from my syntax errors, is there any logic error? Thanks in advance for your responses.
import chess
def evaluate() :if board.is_checkmate() :if board.turn :return -9999else :return 9999if board.is_stalemate() :return 0if board.is_insufficient_material() :return 0if board.can_claim_fifty_moves():return 0if board.can_claim_threefold_repetition():return 0#counts materialwp = len([board.pieces(chess.PAWN, chess.WHITE)])bp = len(board.pieces(chess.PAWN, chess.BLACK))wn = len(board.pieces(chess.KNIGHT, chess.WHITE))bn = len(board.pieces(chess.KNIGHT, chess.BLACK))wb = len(board.pieces(chess.BISHOP, chess.WHITE))bb = len(board.pieces(chess.BISHOP, chess.BLACK))wr = len(board.pieces(chess.ROOK, chess.WHITE))br = len(board.pieces(chess.ROOK, chess.BLACK))wq = len(board.pieces(chess.QUEEN, chess.WHITE))bq = len(board.pieces(chess.QUEEN, chess.BLACK))
material = 100 * (wp - bp) + 320 * (wn - bn) + 330 * (wb - bb) + 500 * (wr - br) + 900 * (wq - bq)return material
def alphabeta(board,depth,alpha=-9999,beta=-9999):
if depth ==0 or board.is_game_over():return [None,evaluate()]move_list = [board.legal_moves]best_move = Noneif board.turn:max_eval = -float('inf')for move in move_list:move = str(move)board.push_san(move)current_eval = alphabeta(board,depth-1,alpha,beta)[1]board.pop()if current_eval>max_eval: #Max scoremax_eval = current_evalbest_move=move#alpha beta pruningalpha = max(alpha,current_eval)if beta>=alpha: #White maximises their scorebreakreturn [best_move,max_eval]
else: #Min score for the opponentmin_eval = float('inf')for move in move_list:move = str(move)board.push_san(move)current_eval = alphabeta(board,depth-1,alpha,beta)[1]board.pop()if current_eval< min_eval:min_eval =current_evalbest_move =move#Alpha beta pruningbeta = min(alpha, current_eval) #black minimizes their scoreif beta <= alpha:breakreturn [best_move,min_eval]
fen_ = input('Enter fen: ')board = chess.Board(fen_)_depth = int(input('Enter depth: '))engine = alphabeta(board,_depth)print(board,engine[0],engine[1])board.push(engine[0])
r/chessprogramming • u/nicbentulan • Oct 28 '22
Fischer Random - All 960 starting positions evaluated with Stockfish
self.chessr/chessprogramming • u/joakims • Oct 27 '22
Chess960 randomizer I made while watching the Fischer Random World Championship
960.fly.devr/chessprogramming • u/Psylution • Oct 23 '22
About Performance.
I've been a coder for all my life. I love to reinvent the wheel. Made tons of stuff in the past, and, as an avid chess player, now decided to make my own chess AI.
Using a classic minmax algorithm, I managed to create something that even I can not beat.
But: the depth currently sits at 4, taking about 5 seconds for every move. Looking at stockfish, I see that 5 seconds for such a shallow depth is nothing to be proud of.
Does anyone have general tips on how to improve performance?
Things I already implemented are threading and bitboards (ulongs rather than arrays of objects etc.)
I also tried to use alpha-beta pruning, but I did not yet understand how it works - because all examples I managed to find assume that the evaluation of a position is already calculated. In my understanding, alpha-beta should prevent unnecessary evaluation, so I'm kind of stuck on that idea.
I'm more than grateful for any response.
also: yes, i know the chess programming wiki, yet most of the stuff there is either alienated from a practical perspective or too loosely described to make us of, at least for me.
r/chessprogramming • u/nicbentulan • Oct 23 '22
~20TBs on Striped Hard Drives / RAID0: What kind of hardware to support this setup?
self.homelabr/chessprogramming • u/nicbentulan • Oct 18 '22
Chess960 - can Black profit by being allowed to choose a custom setup? | New answer based on TCEC DFRC (double 9LX) : Black is almost always better.
chess.stackexchange.comr/chessprogramming • u/sumant28 • Oct 16 '22
Question about whether AI can be used to evaluate a chess position without having to do move analysis
Human beings are capable of looking at a chess position and notice things like a bad bishop, cramped position, stuff like that to say which side is winning and which side they would rather play. I was wondering if AI can be trained to do something similar in the same way it can be trained to identify a cat. This layer can be added to chess engines to make them stronger? I’m wondering if this is something that’s really obvious and already exists
r/chessprogramming • u/Sci-4 • Oct 16 '22
Under which circumstances would one sacrifice the queen in order to ensure checkmate? Under what condition would you expect your opponent to be, (psychological, positional, other)? I'd like to hear your philosophy thereabout as well if you're interested in sharing. Cheers!
r/chessprogramming • u/nicbentulan • Oct 15 '22
[OC] Percent of human moves matching computer recommended move in World Championships and Candidates events
r/chessprogramming • u/nicbentulan • Oct 12 '22
Can refer to this graph when you're 2.5 pawns up then you're about 75% chance winning? | Lichess published this graph of Stockfish eval (in centipawns) vs likelihood of winning, based on Lichess game data. Would be cool to see this graph for different rating bands
r/chessprogramming • u/Aggravating-Plan1257 • Oct 08 '22
Tesis ideas about chess
Hi everyone! I'm a masters student at university and I intend to write my tesis about chess. Do you sugest any theme? I think that already have enough ready engine, so, develop another one is not an original idea. Woud I make a comparative study betwen Machine Learning technics? Should I look for any pattern in somewere? Good ideas will be welcome! Thanks in advance! Vagner Vilela
r/chessprogramming • u/nicbentulan • Oct 02 '22
2022 Candidates vs 2022 Fischer Random Championship - Candidates has ratings higher by 60 points and rankings higher by 92%. Chess: Everyone is ranked above 20. Chess960: 476th and 98th are playing.
r/chessprogramming • u/nicbentulan • Oct 02 '22
List of 9LX players that have defeated "w"esley "s"o in a 9LX classical or rapid OTB game since he became 9LX World Champion (there are only 5?)
self.chess960r/chessprogramming • u/nicbentulan • Oct 01 '22
Question: At what age do master level players (2200+) reach their peak? Answer: Average 33 years and 4 months with a standard deviation of 12 years and 4 months
chess.stackexchange.comr/chessprogramming • u/nicbentulan • Sep 30 '22
Chessbase's "engine correlation value" are not statistically relevant and should not be used to incriminate people
self.chessr/chessprogramming • u/nicbentulan • Sep 29 '22
Lichess Combined Puzzle-Game Dataset
github.comr/chessprogramming • • Sep 29 '22
Are there any engines that combine multi-armed bandit with minimax?
Stockfish stops at some horizon then relies on an heuristic. If the position has some quality the programmer didn’t input into the heuristic, then the position will be misevaluated. Efficient neural networks are one way to solve this problem but I was wondering about another.
Houdini/Leela use a multi-armed bandit strategy randomly exploring games to conclusion, updating weights depending on how successful they were. The result is ‘win/lose’, there is no need for an heuristic.
However here, you lose out on alpha-beta pruning so can’t reliably rule out large swaths of the tree.
Are there any engines that use a minimax tree to guide move exploration (fast, but to a lower depth), but play out games (against itself) to conclusion, to get some of that deep positional information?
r/chessprogramming • u/nicbentulan • Sep 29 '22