1

I am using python's library for chess with Stockfish as chess engine in my program that will create StockfishVsPlayer games and I want to be able to make the user select the difficulty of the game. I know that the higher the depth, the more moves the chess engine checks but is that all it is needed to define its strength? Could I then say difficulty=engine's depth? Like in this line, where I select the depth

[...while it's the computer's turn to move...]
[...]
best_move = engine.go(depth=difficulty)[0]
[...]
ABCD
  • 7,914
  • 9
  • 54
  • 90
BourbonCreams
  • 353
  • 4
  • 21
  • the depth does give some degree of difficulty as long as the moves it takes actually weights the outcome of the moves appropriately. – JamesD Feb 28 '17 at 13:28
  • Can't you access the UCI options? There is a "skill level" option IIRC. – miradulo Feb 28 '17 at 13:29
  • 1
    I don't know exactly how StockFish works , but there are many other aspects exist that will affect chess engines , power of tree prone , sorting move lists ( evaluate most probable moves first), but depth of the tree is most important aspect(my opinion) – ᴀʀᴍᴀɴ Feb 28 '17 at 13:29
  • I have checked online but I can't find much. If there was an option to select the level it should mention it here http://python-chess.readthedocs.io/en/latest/uci.html , right? – BourbonCreams Feb 28 '17 at 13:35
  • @BourbonCreams No, it's not correct. See my answer. – ABCD Mar 01 '17 at 01:14
  • @Arman Correct. But those settings are not adjustable from outside (as a user). – ABCD Mar 01 '17 at 01:29

3 Answers3

2

1. Let's be clear:

  • Python chess is chess GUI, it's not a chess engine.
  • Stockfish is a chess engine, it's not a chess GUI

You don't need Stockfish for Python Chess, and vice versa. Thus, what you wrote:

... If there was an option to select the level it should mention ...

is incorrect. The documentation for Python Chess shouldn't have anything specific to the Stockfish UCI chess settings.

2. Where do I find Stockfish UCI settings?

The official page at:

has what you want. If you want more details, you may want to look at the source code:

3. Answer your question

Depth is one of the most important factor in chess strength. The other possibilities are:

  • Contempt factor
  • Hash size
  • Time for each move
  • Tablebase
  • Opening book
  • Specific positions

For example, Stockfish with the Cerebellum book library is stronger than without. Syzygy tablebase also improves the playing strength.

Stockfish is fast, but it's not the best engine in closed positions. There's a recent post about Komodo and Stockfish in closed positions:

There's a Skill Level parameter in Stockfish (it's in the links above). If you want to understand how it works, check my post:

Community
  • 1
  • 1
ABCD
  • 7,914
  • 9
  • 54
  • 90
0

There is more to a chess engine than simply its depth.

Since we cannot compute the whole game of chess at some point we need to make some evaluation as to the current value of the board. The more accurate this evaluation the better the algorithm will be.

Also it would be a waste of resources to check ever branch to the same depth. For instance say in one branch you lose your queen for free. 99% of the time this will be a dead branch, and any resources used to compute further down this branch would be wasted.

Finally most chess computers use databases for playing the opening and endgames, and the sophistication of these databases have a massive effect on the ability of the computer.

If these three factors remain constant then the only other main factor is the depth of search. However I have not looked at stockfish in python, but from my experience building chess computers move depth can be not such an effective metric. As the game goes on the move depths increase as there are less pieces to consider. Usually I scale computation time with difficulty.

Edd Saunders
  • 138
  • 7
0

In general, yes. Here's a nice paper ranking depth with ELO rating. http://web.ist.utl.pt/diogo.ferreira/papers/ferreira13impact.pdf

However, specifically for Stockfish, the answer is no. If you play a game of Stockfish and set it's skill level to 0, this is about a 1200 rating, and you should beat it easily. However, if you look at the depth it searches, it routinely searches to depth 20, which should be closer to 2500 rating.

So it all depends on how it's programmed.

john k
  • 6,268
  • 4
  • 55
  • 59