Skip to content

Commit

Permalink
Merge pull request #974 from jamesbraza/engine-docs-clarity
Browse files Browse the repository at this point in the history
Clarifications to SimpleEngine in docs
  • Loading branch information
niklasf committed Mar 6, 2023
2 parents 3fc30d6 + 69a5e0f commit 0b4054d
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions docs/engine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The preferred way to use the API is with an
The examples also show a synchronous wrapper
:class:`~chess.engine.SimpleEngine` that automatically spawns an event loop
in the background.
:class:`~chess.engine.SimpleEngine` methods block until there is a result.

Playing
-------
Expand All @@ -27,6 +28,8 @@ Example: Let Stockfish play against itself, 100 milliseconds per move.

.. code:: python
"""Using synchronous engine.SimpleEngine."""
import chess
import chess.engine
Expand All @@ -41,6 +44,8 @@ Example: Let Stockfish play against itself, 100 milliseconds per move.
.. code:: python
"""Using async engine."""
import asyncio
import chess
import chess.engine
Expand Down Expand Up @@ -74,6 +79,8 @@ Example:

.. code:: python
"""Using synchronous engine.SimpleEngine."""
import chess
import chess.engine
Expand All @@ -93,6 +100,8 @@ Example:
.. code:: python
"""Using async engine."""
import asyncio
import chess
import chess.engine
Expand Down Expand Up @@ -139,6 +148,8 @@ Example: Stream information from the engine and stop on an arbitrary condition.

.. code:: python
"""Using synchronous engine.SimpleEngine."""
import chess
import chess.engine
Expand All @@ -156,6 +167,8 @@ Example: Stream information from the engine and stop on an arbitrary condition.
.. code:: python
"""Using async engine."""
import asyncio
import chess
import chess.engine
Expand Down Expand Up @@ -193,21 +206,27 @@ Options
:func:`~chess.Protocol.analyse()` and
:func:`~chess.Protocol.analysis()` accept a dictionary of options.

>>> import chess.engine
>>>
>>> engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish")
>>>
>>> # Check available options.
>>> engine.options["Hash"]
Option(name='Hash', type='spin', default=16, min=1, max=131072, var=[])
>>>
>>> # Set an option.
>>> engine.configure({"Hash": 32})
>>>
>>> # [...]
.. code:: python
"""Using synchronous engine.SimpleEngine."""
import chess.engine
engine = chess.engine.SimpleEngine.popen_uci("/usr/bin/stockfish")
# Check available options.
engine.options["Hash"]
# Option(name='Hash', type='spin', default=16, min=1, max=131072, var=[])
# Set an option.
engine.configure({"Hash": 32})
# [...]
.. code:: python
"""Using async engine."""
import asyncio
import chess.engine
Expand Down

0 comments on commit 0b4054d

Please sign in to comment.