Hot answers tagged

19

Here is a well organized list that should validate 99.99%+ of common positions: Board: There are exactly 8 cols The sum of the empty squares and pieces add to 8 for each rank (row) There are no consecutive numbers for empty squares Kings: See if there is exactly one w_king and one b_king Make sure kings are separated 1 square apart Checks: Non-active ...


11

As thb pointed out, you need vectors. I suggest you use a python-chess to generate SVG vector images. Prerequisites: Python 2.6+ or 3.3+ Python-chess: Install form pypi using pip: pip install python-chess[uci,gaviota] Creating a script Since you might need to generate multiple SVGs, let's create a script. So, you can use the script to generate multiple ...


10

PyChess Is a chess client built in Python. You can use it's chess logic libraries without much trouble. http://code.google.com/p/pychess/source/browse/utilities/arena.py http://code.google.com/p/pychess/source/browse/utilities/blunders.py Are examples of how you you might use the libraries to control chess engines, but you can also use just the chess ...


10

\s*([rnbqkpRNBQKP1-8]+\/){7}([rnbqkpRNBQKP1-8]+)\s[bw-]\s(([a-hkqA-HKQ]{1,4})|(-))\s(([a-h][36])|(-))\s\d+\s\d+\s* Here's a regular expression that I use to ensure that a FEN string is actually valid. It doesn't do any testing for a legal/illegal position, but it's a good starting point.


9

You may want to record a fragment of a real game starting from move number 24, for example. Then you specify the FEN after the first 23 moves and set the full move number to 24.


8

If one of the rooks has moved from its starting position, it is no longer legal to castle with that rook. For example, if white plays 1. a4 2. Ra3 3. Ra1, white can no longer castle long, even though the king and rook are both in their normal positions. For this reason, the FEN string must encode whether or not castling is legal (because both king and rook ...


7

I am looking for a software or web site, which allows me to place the pieces on the board, and then create FEN notation automatically. I personally use this site for that. It is free, and it is an online tool. REMARKS: If you wish to put that FEN in our diagram you paste that code like this: Press space bar 4 times; Type square brackets ( [] ); Type fen ...


7

Yes there are easy ways to do this. I'm going to briefly show you one quick way of doing it in python, using the python-chess module. If the in-code comments are not enough, feel free to ask for clarifications or possible extensions of the code: To showcase a working example, I've taken a game between Adams and Kasparov, you can download the PGN from the ...


6

Since you're talking about programming, you're presumably looking for a storage scheme more compact in computer memory space than FEN. Besides going out to research how it's done in large tablebases, two possibilities come to my mind immediately. Normal FEN For the sake of this discussion, "normal" FEN is just a typical text string represented with 1-byte (...


6

The FEN consists of six parts (see definition of FEN here): piece placement: at most 64 characters, one for each square plus 7 times "/" to delimit ranks = 71 characters active color: one character ("w" or "b") castling: at most 4 characters en passant: one or two characters half move clock full move number In addition there are 5 space characters between ...


5

Chess is a game in two dimensions. The game is made to be played in two dimensions. Pieces move horizontally, vertically, and diagonally very naturally on a chess board. It's purely visual and the sort of thing our brain does very well. Other depictions of the position sacrifice the two dimensional nature of the game. When this information is lost, we have ...


5

For the others, there is a simple function in Stockfish engine, that validates a FEN String. bool Position::is_valid_fen(const std::string &fen) { std::istringstream iss(fen); std::string board, side, castleRights, ep; if (!iss) return false; iss >> board; if (!iss) return false; iss >> side; if (!iss) { ...


5

What are the main differences between the two? Extended Position Description is a standard for describing chess positions along with an extended set of structured attribute values using the ASCII (American Standard Code for Information Interchange) character set. It is intended for data and command interchange among chess playing programs. It is ...


5

The active color (i.e. the color which has the next move) is allowed to be in check, and as ajax points out, at most twice. But perhaps you meant the inactive color not being allowed to be in check. Why is that? The answer is: if the inactive color is in check, it would mean that at least the last move by the inactive color was illegal, allowing its own ...


5

http://gorgonian.weebly.com/pgn.html http://exeterchessclub.org.uk/downloads (in chessbase format) Exeter has many other valuable resources.


4

Here is a simple backtracking algorithm, provided that you have a function that can check reverse legal moves at every board state (also known as position): function is_legal_state(state,move) //Terminate if a starting state was found. This immediately implies there //was a legal game that generated this state, in fact the backtracking //can tell ...


4

If all the pieces are on the board, there are 64!/32!/8!^2/2^6*(32/63)*(31/61) or about 1.2*10^42 positions. This would require 140 bits. The 64!/32! puts the pieces on squares, the divisions account for permuting like pieces, and the last two fractions put the bishop pairs on opposite color squares. I would guess a dozen or so more bits would be required ...


4

Let's start at the beginning To understand X-FEN for castling in Chess960, it helps if you first understand castling in Chess960. Castling rules are slightly different in Chess960, hence there comes a need for X-FEN. I believe it's the major source for your confusion. Minor Note 1 X-FEN is used not just for Chess960 but for many other variants as well (...


4

https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation "FEN does not represent sufficient information to decide whether a draw by threefold repetition may be legally claimed or a draw offer may be accepted; for that, a different format such as Extended Position Description is needed." QED.


4

One rule that depends on the move count is the time control. If you have a time control of 40/120, you need to know which move it is to know when the players get more time.


4

This will do it. https://chessvision.ai/ There is also the Chessify app on the ios store where you can take pictures of chessboards and import the position. Hope this helps!


4

Using the definition of FEN it is relatively straightforward to compute an upper bound: piece placement: 64 (pieces/squares) + 7 (slashes) color: 1 (w/b) castling: 4 (KQkq) en passant: 2 (e3) halfmove clock: 3 (100) fullmove number: 4 (considering that maximum game length < 9999 due to the 50-move rule) spaces between fields: 5 So in total we get as an ...


3

A vector format would suit. As you may know, a vector format represents graphic not as a bitmap but geometrically, as a mathematical description which can be rendered at any scale. For web display, you can use the SVG format. Here are some chessmen in the SVG format. (If you follow the link, for each chessman, click through to "original file (SVG file)." ...


3

My solution has been to use a chess font like Chess Merida or Chess Cases. With such a font for example the start position is written like this: 1222222223 4tMvWlVmT5 4OoOoOoOo5 4 + + + +5 4+ + + + 5 4 + + + +5 4+ + + + 5 4pPpPpPpP5 4RnBqKbNr5 7888888889 And (assuming the line-height is set to the height of the font) it looks like this (Here using Chess ...


3

SCID will do it. Create a position using Edit->Setup Board. There's a text box at the bottom of the setup window with the FEN. Or, if you've been playing against the computer, you can just say Edit->Copy FEN to get the board's current position.


3

Although one may try to place the first row as the eighth, the second row as the seventh, etc., the board will appear flipped (as shown above). This is a horizontal flip (mirror-image over the x-axis) and does not look quite right. Switching the letters from lower-case to capital and vice-versa would switch the colors, but that's not the best solution. ...


3

You can also buy Harold Van der Heidjen's endgame study database. It contains more or less all the endgame studies he could gather from the old classic (Saavedra, Ponziani etc..) to the most recent from every publications and composing tournaments out there. And everything in between (Troitsky, Rinck, Platov brothers, Kubbel, Kasparyan, etc..). Back when I ...


3

FEN (Forsyth-Edwards Notation) is a way of recording the current position on the chess board - piece positions, active colour, castling possibilities, en passant target, half move clock, full move number. The result of the game is not included.


3

There is at least one case where your method will fail: pawns on f2, g3, h2 and h3. The structure is illegal, but drawing triangles from every pawn will not show this. To catch this, you'd have to draw the triangle from every square of the chessboard (h4 in this case demonstrates the illegality). So as you said, draw triangles, but instead of starting ...


Only top voted, non community-wiki answers of a minimum length are eligible