Skip to content

Commit

Permalink
Bestmove -> BestMove, pondermove -> ponder
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Mar 3, 2015
1 parent 5c5bcdd commit 895de60
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,25 +228,25 @@ Features
>>> # Synchronous mode.
>>> board = chess.Bitboard("1k1r4/pp1b1R2/3q2pp/4p3/2B5/4Q3/PPP2B2/2K5 b - - 0 1")
>>> engine.position(board)
>>> engine.go(movetime=2000) # Gets tuple of bestmove and pondermove.
Bestmove(bestmove=Move.from_uci('d6d1'), pondermove=Move.from_uci('c1d1'))
>>> engine.go(movetime=2000) # Gets tuple of bestmove and ponder move.
BestMove(bestmove=Move.from_uci('d6d1'), ponder=Move.from_uci('c1d1'))
>>> # Synchronous communication, but search in background.
>>> engine.go(infinite=True)
>>> time.sleep(2)
>>> engine.stop()
Bestmove(bestmove=Move.from_uci('d6d1'), pondermove=Move.from_uci('c1d1'))
BestMove(bestmove=Move.from_uci('d6d1'), ponder=Move.from_uci('c1d1'))
>>> # Asynchronous mode.
>>> def callback(command):
... bestmove, pondermove = command.result()
... bestmove, ponder = command.result()
... assert bestmove == chess.Move.from_uci('d6d1')
...
>>> command = engine.go(movetime=2000, async_callback=callback)
>>> command.done()
False
>>> command.result()
Bestmove(bestmove=Move.from_uci('d6d1'), pondermove=Move.from_uci('c1d1'))
BestMove(bestmove=Move.from_uci('d6d1'), ponder=Move.from_uci('c1d1'))
>>> command.done()
True
Expand Down
8 changes: 4 additions & 4 deletions chess/uci.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class Score(collections.namedtuple("Score", ["cp", "mate", "lowerbound", "upperb
pass


class Bestmove(collections.namedtuple("Bestmove", ["bestmove", "pondermove"])):
"""A bestmove and pondermove sent by an UCI engine."""
class BestMove(collections.namedtuple("BestMove", ["bestmove", "ponder"])):
"""A bestmove and ponder move sent by an UCI engine."""
pass


Expand Down Expand Up @@ -499,7 +499,7 @@ def execute(self, engine):
self.set_result(None)
else:
engine.bestmove_received.wait()
self.set_result(Bestmove(engine.bestmove, engine.ponder))
self.set_result(BestMove(engine.bestmove, engine.ponder))


class StopCommand(Command):
Expand All @@ -516,7 +516,7 @@ def execute(self, engine):
engine.readyok.wait()

engine.bestmove_received.wait(STOP_TIMEOUT)
self.set_result(Bestmove(engine.bestmove, engine.ponder))
self.set_result(BestMove(engine.bestmove, engine.ponder))


class PonderhitCommand(IsReadyCommand):
Expand Down
6 changes: 3 additions & 3 deletions docs/uci.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ By default all operations are executed synchronously and their result is
returned. For example

>>> engine.go(movetime=2000)
Bestmove(bestmove=Move.from_uci('e2e4'), pondermove=None)
BestMove(bestmove=Move.from_uci('e2e4'), ponder=None)

will take about 2000 milliseconds. All UCI commands have an optional
*async_callback* argument. They will then immediately return information about
Expand All @@ -67,7 +67,7 @@ the command and continue.
>>> command.done()
False
>>> command.result() # Synchronously wait for the command to finish
Bestmove(bestmove=Move.from_uci('e2e4'), pondermove=None)
BestMove(bestmove=Move.from_uci('e2e4'), ponder=None)
>>> command.done()
True

Expand All @@ -77,7 +77,7 @@ command is completed. It takes a *Command* object as a single argument.

>>> def on_go_finished(command):
... # Will likely be executed on a different thread.
... bestmove, pondermove = command.result()
... bestmove, ponder = command.result()
...
>>> command = engine.go(movetime=2000, async_callback=on_go_finished)

Expand Down

0 comments on commit 895de60

Please sign in to comment.