chess

Regex to match something based on what was matched before

假装没事ソ 提交于 2019-12-01 21:43:47
问题 I'm trying to write a regular expression to validate moves in algebraic chess notation. Here's what I have so far: / O-O(-O)? # Castling |[KQRBN]x?[a-h][1-8]\+? # Most normal moves and captures / Where I am lost is pawn promotion. A knight, bishop, or centre pawn may only promote on the file from which it starts or the file on either side via a capture. A rook pawn may promote by moving straight or capturing to one side, depending on whether it is on the a- or h- files. So something like /[a

Can a transposition table cause search instability

▼魔方 西西 提交于 2019-12-01 16:58:11
问题 I'm writing a chess engine and recently added a transposition table. When running a few tests, I found that although the search still returned the same best move, the value of the move (how good it is for the maximizing player) fluctuated. Is this normal behavior for a transposition table? I remember reading that a transposition table can cause search instability. Is this what that means? So is this a normal occurrence or a serious bug in my code? 回答1: Yes, transposition tables introduce

Strange behaviour in a function while implementing the alpha-beta pruning algorithm

依然范特西╮ 提交于 2019-12-01 07:15:30
I've implemented a minimax algorithm with alpha-beta pruning. In order to get the best move, I call the alpha-beta algorithm with the rootAlphaBeta function. However, in the rootAlphaBeta function, I spotted some very strange behaviour. When I call the rootAlphaBeta function with a ply of 4, it makes about 20 000 calls, but when I call the alphaBeta function directly, it makes only about 2000 calls. I can't seem to find what's the problem, as the number of calls should be the same. The move that both algorithms eventually find should be the same, right? I think so, at least the score of the

Strange behaviour in a function while implementing the alpha-beta pruning algorithm

China☆狼群 提交于 2019-12-01 04:21:29
问题 I've implemented a minimax algorithm with alpha-beta pruning. In order to get the best move, I call the alpha-beta algorithm with the rootAlphaBeta function. However, in the rootAlphaBeta function, I spotted some very strange behaviour. When I call the rootAlphaBeta function with a ply of 4, it makes about 20 000 calls, but when I call the alphaBeta function directly, it makes only about 2000 calls. I can't seem to find what's the problem, as the number of calls should be the same. The move

Using the Universal Chess Interface

亡梦爱人 提交于 2019-11-30 06:42:13
I'm planning on making a program that interfaces with a UCI chess engine. I've been doing some research on it, but I want to get a little more information before I get more in depth with it. I was wondering if any of you could provide a few example "exchanges" between a UCI engine and a front-end program. I'm not really concerned with the practical interface code (like sending/receiving commands), that should be simple enough. I'm just trying to get some good examples of a small game and some options. I'm using the stockfish engine currently, but I want to be able to use multiple engines. So

How to Communicate with a Chess engine in Python?

↘锁芯ラ 提交于 2019-11-30 02:25:49
on win 7 i can communicate with a chess engine via commandline. Small Example Session with Stockfish on Win 7: C:\run\Stockfish>stockfish-x64.exe Stockfish 2.2.2 JA SSE42 by Tord Romstad, Marco Costalba and Joona Kiiski quit C:\run\Stockfish> The first line was output by the engine and the 'quit' was what i typed to quit the engine (There are other things i can do , but thats clear to me). Now i want to communicate with that engine from python: import subprocess engine = subprocess.Popen( 'stockfish-x64.exe', stdin=subprocess.PIPE, stdout=subprocess.PIPE, ) for line in engine.stdout: print

Chessboard in WPF

旧城冷巷雨未停 提交于 2019-11-29 22:17:19
问题 For years I've developed with Winforms, now I want to switch to WPF and make a chessboard. Unfortunately I have no idea where to start. Using WPF makes me very unsure, I'm feeling like a noob again. Can someone outline a basic design? I guess I would start with a 8x8 Grid and use rectangles for the squares, images for pieces. And then? Am I missing something? Edit: It's just about the user interface; what goes on behind the scenes is no problem. 回答1: An alternative to the standard grid, is

Object Oriented Design for a Chess game [closed]

偶尔善良 提交于 2019-11-29 19:02:10
I am trying to get a feel of how to design and think in an Object Oriented manner and want to get some feedback from the community on this topic. The following is an example of a chess game that I wish to design in an OO manner. This is a very broad design and my focus at this stage is just to identify who is responsible for what messages and how the objects interact each other to simulate the game. Please point out if there are elements of bad design (high coupling, bad cohesion etc.) and how to improve on them. The Chess game has the following classes Board Player Piece Square ChessGame The

How to draw a chess board in D3?

亡梦爱人 提交于 2019-11-29 13:02:02
I would like to draw a chess board in D3: I would be satisfied with just being able to draw the initial game position (as above). It may be the case that one does not need image files for king, queen, knight, etc. (there are 12 distinct pieces) since they are all part of Unicode as codepoints 2654-265F: The Unicode characters appear in any modern browser: ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟ Unicode chess symbols on Wikipedia: here Python script to display chess board in a terminal using Unicode characters: here . Its result: Any pointers or help would be much appreciated. Here is the codepen of the

Trailing/leading zero count for a byte

社会主义新天地 提交于 2019-11-29 10:28:22
问题 I'm using Java and I'm coding a chess engine. I'm trying to find the index of the first 1 bit and the index of the last 1 bit in a byte. I'm currently using Long.numberOfTrailingZeros() (or something like that) in Java, and would like to emulate that functionality, except with bytes. Would it be something like: byte b = 0b011000101; int firstOneBit = bitCount ((b & -b) - 1); If so, how would I implement bitCount relatively efficiently. I don't mind good explainations, please don't just give