# Tag Info

40

This calls for some scripting, so here's my first hasty attempt at it ;) Here's a quick way you can do the search on your own in python, using stockfish 10 and only the python-chess package. All open-source and free-software! Briefly, what the script will do: Consider all 960 positions, one at a time For each position, it scans over all legal white moves ...

32

You may find this game interesting: https://lichess.org/A9ZRnDcE. Here Stockfish (black) is programmed to select the move leading to the most negative eval position. White is a human who is aiming to lose (i.e.: be checkmated). White is ultimately successful, which goes to show that really playing to be checkmated is a variant in its own right - we could ...

30

Engines have no concept of natural moves and they have no fear. An engine will play for the most advantage, not for the most manageable advantage, even if it allows a fierce attack, because it sees that the attack does not work, while a human would probably prevent an attack and settle with a smaller, but practical advantage. "Randomly" picking ...

26

If you're trying to make the strongest engine possible, absolutely go for NN engines. Traditional engines are great - Stockfish is arguably still the strongest engine on the planet on consensus equal hardware - but they are hard to write. These engines didn't get where they were overnight; they took years and years of work. Stockfish for example has been ...

25

The task you are considered is usually called a proof game, named such because the task is to prove that the position is legal. As a genre of puzzles, there are various aesthetic constraints, most commonly that the resulting game be unique. However, this is not necessary in general, and there is even a genre of counting the number of solutions. There are ...

24

If you're curious about the Stockfish code, it can be found here: si->checkersBB = attackers_to(square<KING>(sideToMove)) & pieces(~sideToMove); We call the attackers_to method to figure out if any pieces are attacking the king's position, including pieces on the king's side. Bitboard Position::attackers_to(Square s, Bitboard occupied) const ...

23

You are doing a chess GUI, not a chess engine right? Chess GUI doesn't need to be super efficient, because you have no more than a chess game to look for. Even a game over 200 moves about the world record is absolutely nothing for a computer. I would just simply keep your positions with an array of strings like FEN format (or any other format), and then ...

20

If the engine can choose between getting mated in 2 or mated in 3, it'll choose the line where it is mated in 3 (even though the mate in 2 might be 'more difficult' to spot for humans). It can't really set traps, because it doesn't know what things might be difficult to spot for a human (or other engine) opponent. It just evaluates the position, without ...

18

Using @Phonon's Python script, I was able to determine that the worst move is 1. g4?? from the BBQRNNKR starting configuration, or 1. b4?? from its mirror image. This evaluates to -2.5 in one second of Stockfish search. Not quite a minor piece, but still a substantial handicap to recover from. Why is this position so powerful for the opponent? The black ...

18

Where and how in Stockfish's code is check detected? This is simple engine programming. You will need to build a bitboard of the attacking squares and two bitboards of your king, one for each color. You will then run AND on the two bitboards. If the result is non-zero, you know the king is in check. I can show you the code in Stockfish, but does my answer ...

16

One very obvious indication for people using engines is, that they need roughly the same time for every move (usually about 5s in blitz games), even for the most obvious ones, which could be premoved. They also have much worse ratings in faster time controls (bullet). One example: https://youtu.be/rlxHusHfpck

14

Your question has nothing to do with Stockfish. Though it may be interesting to check the original source code. This is purely algorithmic. One dumb solution would be implementing a boolean function (is_check) that takes an array as input representing the board. Only white pieces can check the black king, except the white king and vice versa. If one of the ...

13

In the beginning years of computer chess, people have actually tried to teach computers chess in the same way as they do with humans, explaining strategic concepts like a healthy pawn structure or the initiative. These attempt were soon abandoned because the method you describe was much more successful. Recently, there has been another attempt to let an ...

13

Threefold-repetition is about a position (not moves) occurring three times. Those positions do not have to be reached by the same moves. Also (as this also seems to be confused sometimes) it is completely irrelevant when this happens, e.g. you can have the same positions after moves 10, 42 and 63 and it would still be a draw. You should check whether the ...

13

This exact bot has already been created. On lichess, it is simpleEval. You could potentially use it to debug a lot of your issues by seeing what this engine does against you in a given position. Having played this bot several times, no that move Nxf2 would probably be incorrect. This seems like a bug on your end. Assuming you have enough depth in the bot's ...

13

Easy illegality is easy: not exactly 1 king on both sides, both kings in check, pawns on the final ranks. It's also fairly easy to tally promoted material and subtract the missing pawns. A quick captures test, together with the pawn structures, is also possible. An impossibility of last move test, even if only cursorily, is already tricky. A full test is NP-...

12

Stockfish assumes that all FEN positions you feed it are legal positions. If you feed it an illegal position and ask it to evaluate it, it will likely crash: Stockfish 5 64 by Tord Romstad, Marco Costalba and Joona Kiiski position fen 4k3/4p3/8/8/8/8/8/3KP3 go depth 14 Segmentation fault: 11 But you could use a Python library such as Chessnut to validate ...

12

Let's use Stockfish to find out the moves for this position [fen "N7/P3pk1p/3p2p1/r4p2/8/4b2B/4P1KP/1R6 w - - 0 34"] The FEN string is: "N7/P3pk1p/3p2p1/r4p2/8/4b2B/4P1KP/1R6 w - - 0 34". You should copy-and-paste my commands to experience yourself. Load the position by "position fen ..." and then use "d" to print the position. Please note that "d" is a ...

12

Your "checkless" chess AI would run into problems with the stalemate rule. It would consider the poaition with white king on a6, white pawn a7, black king a8, a win for White because wherever Black moves his king it will get captured. In standard chess, of course, the position is a draw.

12

A good chess engine won't stop after a predetermined number of moves, but will keep looking until the position is "quiescent", which roughly speaking means that there are no pending captures or checks. See Quiescence Search in chessprogramming wikispaces for a more detailed explanation.

11

There're only two protocols - UCI and Winboard. Winboard is an old protocol and not really being used nowadays. Crafty is the only major engine still supporting the Winboard protocol, but it's only because the engine is also very old. UCI is a newer protocol developed by Shredder, and is used everywhere - Windows, Macs, Linux, Android, iOS etc. UCI is really ...

11

Easy question. Announce your engine on the chess programming forum (http://talkchess.com/forum/index.php). There'll be engine testers adding your engine to their rating list, such as CCRL. But please and please provide a working compiled binary. Announce your engine, upload a compiled binary to somewhere like Dropbox. You'll hear feedback. EDIT cutechess ...

11

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 ...

11

First step: Define your goals/reasons I think this is the predominant factor. Which of these best fits you? (Choose only one) You want to enjoy a fun, challenging coding task You want to create an extremely good chess engine You want to learn about how chess engines work You want to learn/practice coding skills You want to learn/implement computer science ...

11

Some of those things are possible in theory. Especially if you have a good idea what an engine-detector is looking for, you could maybe do some machine-learning training of algorithm against algorithm until you had one that could make good moves that didn't get detected as different from a given player's normal play. But that would require someone to be ...

10

Computer detection of dead positions is much trickier than people think. It is unlikely that an algorithm exists that runs in reasonable time and is 100% accurate. It is easy to check for a simple condition like insufficient material (K+B v K, K+N v K). It is less easy to check for cases with blocked pawns, for instance: 2b1k3/8/8/1p1p1p1p/1P1P1P1P/8/8/...

10

I don't know of a single program that does all that. I do it myself with following steps. I save most of my games in a pgn file. The interesting ones, esp. my losses, are analyzed by Stockfish. The "blunder threshold" is your choice, typically 3 - 5 pawns or more. With Notepad++ text editor I enter the FEN of the position in a pgn file, of course ...

9

Would this be what you are looking for? PGN-extract (A command line utility) http://www.cs.kent.ac.uk/people/staff/djb/pgn-extract/ I can see a flag in the feature doc that might help: -W[cm|epd|halg|lalg|elalg|san|uci] - specify the output format to use -Whalg is hyphenated long algebraic. -Wlalg is long algebraic -Welalg[PNBRQK] is enhanced long ...

9

I imagine any chess engine must have such function. Find an open source one in your programming language of choice and draw inspiration from there. I often use the python-chess package for simple chess programming and data mining tasks, as it offers a good API with many useful functions (available here: https://pypi.python.org/pypi/python-chess). For your ...

9

Maybe you can take a look at TalkChess, a forum dedicated to computer chess. I found a recent thread that might be interesting for you: Progress in 30 years by four intervals of 7-8 years A couple of matches between (former) top engines are played on the same hardware. The test suggests that in the recent years (2002-2017), the gain is mainly made by ...

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