pychess.Players package
Submodules
pychess.Players.CECPEngine module
- class pychess.Players.CECPEngine.CECPEngine(subprocess, color, protover, md5)
Bases:
pychess.Players.ProtocolEngine.ProtocolEngine
- canAnalyze()
- end(status, reason)
Called when the game ends in a normal way. Use this for shutting down engines etc.
- getAnalysisLines()
- hurry()
Forces engines to move now, and sends a hurry message to nonlocal human players
- kill(reason)
Kills the engine, starting with the ‘quit’ command, then sigterm and eventually sigkill. Returns the exitcode, or if engine have already been killed, returns None
- async makeMove(board1, move, board2)
Gets a move from the engine (for player engines). @param board1: The current board @param move: The last move made @param board2: The board before the last move was made @return: The move the engine decided to make
- maxAnalysisLines()
- minAnalysisLines()
- offer(offer)
The players opponent has offered the player offer. If the player accepts, it should respond by mirroring the offer with emit(“accept”, offer). If it should either ignore the offer or emit “decline”.
- offerError(offer, error)
An offer, accept or action made by the player has been refused by the game model.
- async parseLine(proc)
- pause()
Pauses engine using the “pause” command if available. Otherwise put engine in force mode. By the specs the engine shouldn’t ponder in force mode, but some of them do so anyways.
- playerUndoMoves(moves, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- prestart()
- putMove(board1, move, board2)
Sends the engine the last move made (for spectator engines). @param board1: The current board @param move: The last move made @param board2: The board before the last move was made
- requestMultiPV(setting)
Set the number of analysis lines the engine will give, if possible.
If setting is too high, the engine’s maximum will be used. The setting will last until the next call to requestMultiPV. Return value: the setting used.
- resume()
Should resume player to think if he’s paused
- setBoard(board, search=True)
- setBoardList(boards, moves)
- setOption(key, value)
Set an option, which will be sent to the engine, after the ‘readyForOptions’ signal has passed. If you want to know the possible options, you should go to engineDiscoverer or use the hasOption method while you are in your ‘readyForOptions’ signal handler
- setOptionAnalyzing(mode)
- setOptionInitialBoard(model)
If the game starts at a board other than FEN_START, it should be sent here. We sends a gamemodel, so the engine can load the entire list of moves, if any
- setOptionStrength(strength, forcePonderOff)
Strength is a number [1,8] inclusive. Higher is better.
- setOptionTime(secs, gain, moves)
Seconds is the initial clock of the game. Gain is the amount of seconds a player gets after each move. If the engine doesn’t support playing with time, this will fail.
- setOptionVariant(variant)
Inform the engine of any special variant. If the engine doesn’t understand the variant, this will raise an error.
- set_board(board)
- spectatorUndoMoves(moves, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- start(event, is_dead)
- updateTime(secs, opsecs)
Updates the player with the current remaining time as a float of seconds
pychess.Players.Engine module
- class pychess.Players.Engine.Engine(md5=None)
Bases:
pychess.Players.Player.Player
- canAnalyze()
- getAnalysis()
Returns a list of moves, or None if there haven’t yet been made an analysis
- maxAnalysisLines()
- minAnalysisLines()
- offer(offer)
The players opponent has offered the player offer. If the player accepts, it should respond by mirroring the offer with emit(“accept”, offer). If it should either ignore the offer or emit “decline”.
- offerDeclined(offer)
An offer sent by the player was responded negative by the opponent
- offerError(offer, error)
An offer, accept or action made by the player has been refused by the game model.
- offerWithdrawn(offer)
An offer earlier offered to the player has been withdrawn
- on_analysis(engine, analysis)
- putMessage(message)
Sends the player a chatmessage
- requestMultiPV(setting)
Set the number of analysis lines the engine will give, if possible.
If setting is too high, the engine’s maximum will be used. The setting will last until the next call to requestMultiPV. Return value: the setting used.
- setOptionAnalyzing(mode)
- setOptionInitialBoard(model)
If the game starts at a board other than FEN_START, it should be sent here. We sends a gamemodel, so the engine can load the entire list of moves, if any
- setOptionStrength(strength)
Strength is a number [1,8] inclusive. Higher is better.
- setOptionTime(secs, gain)
Seconds is the initial clock of the game. Gain is the amount of seconds a player gets after each move. If the engine doesn’t support playing with time, this will fail.
- setOptionVariant(variant)
Inform the engine of any special variant. If the engine doesn’t understand the variant, this will raise an error.
pychess.Players.Human module
- class pychess.Players.Human.Human(gmwidg, color, name, ichandle=None, icrating=None)
Bases:
pychess.Players.Player.Player
- emit_action(board, action, player, param)
- end(status, reason)
Called when the game ends in a normal way. Use this for shutting down engines etc.
- hurry()
Forces engines to move now, and sends a hurry message to nonlocal human players
- kill(reason)
Called when game has too die fast and ugly. Mostly used in case of errors and stuff. Use for closing connections etc.
- async makeMove(board1, move, board2)
Takes a board object, and if ply>lowply the latest move object and second latest board object as well. Otherwise these two are None. Retruns: A new move object, witch the player wants to do.
- offer(offer)
The players opponent has offered the player offer. If the player accepts, it should respond by mirroring the offer with emit(“accept”, offer). If it should either ignore the offer or emit “decline”.
- offerDeclined(offer)
An offer sent by the player was responded negative by the opponent
- offerError(offer, error)
An offer, accept or action made by the player has been refused by the game model.
- offerWithdrawn(offer)
An offer earlier offered to the player has been withdrawn
- on_game_terminated(model)
- pause()
Should stop the player from thinking until resume is called
- piece_moved(board, move, color)
- playerUndoMoves(movecount, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- putMessage(text)
Sends the player a chatmessage
- resume()
Should resume player to think if he’s paused
- sendMessage(text)
- zero_reached(timemodel, color)
pychess.Players.ICPlayer module
- class pychess.Players.ICPlayer.ICPlayer(gamemodel, ichandle, gameno, color, name, icrating=None)
Bases:
pychess.Players.Player.Player
- end(status=None, reason=None)
Called when the game ends in a normal way. Use this for shutting down engines etc.
- getICHandle()
- kill(reason)
Called when game has too die fast and ugly. Mostly used in case of errors and stuff. Use for closing connections etc.
- async makeMove(board1, move, board2)
Takes a board object, and if ply>lowply the latest move object and second latest board object as well. Otherwise these two are None. Retruns: A new move object, witch the player wants to do.
- observe()
- offer(offer)
The players opponent has offered the player offer. If the player accepts, it should respond by mirroring the offer with emit(“accept”, offer). If it should either ignore the offer or emit “decline”.
- offerDeclined(offer)
An offer sent by the player was responded negative by the opponent
- offerError(offer, error)
An offer, accept or action made by the player has been refused by the game model.
- offerRematch()
- offerWithdrawn(offer)
An offer earlier offered to the player has been withdrawn
- on_game_terminated(model)
- pause()
Should stop the player from thinking until resume is called
- playerUndoMoves(movecount, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- putMessage(text)
Sends the player a chatmessage
- resetPosition()
Used in observed examined games f.e. when LectureBot starts another example
- resume()
Should resume player to think if he’s paused
- setBoard(fen)
- property move_queue
- property time
pychess.Players.Player module
- exception pychess.Players.Player.GameEnded
Bases:
Exception
Used instead of returning a move on game end
- exception pychess.Players.Player.InvalidMove
Bases:
Exception
Used instead of returning a move, when an engine plays an invalid move
- exception pychess.Players.Player.PassInterrupt
Bases:
Exception
Used instead of returning a move, when a players turn is interrupted but not changed. This may happen when undoMoves doesn’t changes the current player
- exception pychess.Players.Player.PlayerIsDead
Bases:
Exception
Used instead of returning a move, when an engine crashes, or a nonlocal player disconnects
- exception pychess.Players.Player.TurnInterrupt
Bases:
Exception
Used instead of returning a move, when a players turn is interrupted. This may happen when undoMoves changes the current player
- class pychess.Players.Player.Player
Bases:
GObject
- end(status, reason)
Called when the game ends in a normal way. Use this for shutting down engines etc.
- hurry()
Forces engines to move now, and sends a hurry message to nonlocal human players
- kill(reason)
Called when game has too die fast and ugly. Mostly used in case of errors and stuff. Use for closing connections etc.
- makeMove(board1, move, board2)
Takes a board object, and if ply>lowply the latest move object and second latest board object as well. Otherwise these two are None. Retruns: A new move object, witch the player wants to do.
- offer(offer)
The players opponent has offered the player offer. If the player accepts, it should respond by mirroring the offer with emit(“accept”, offer). If it should either ignore the offer or emit “decline”.
- offerDeclined(offer)
An offer sent by the player was responded negative by the opponent
- offerError(offer, error)
An offer, accept or action made by the player has been refused by the game model.
- offerWithdrawn(offer)
An offer earlier offered to the player has been withdrawn
- pause()
Should stop the player from thinking until resume is called
- playerUndoMoves(moves, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- prestart()
- putMessage(message)
Sends the player a chatmessage
- putMove(board1, move, board2)
Like makeMove, but doesn’t block and doesn’t return anything. putMove is only used when the player is spectatctor to a game
- resume()
Should resume player to think if he’s paused
- setName(name)
__repr__ should return this name
- setOptionInitialBoard(model)
- spectatorUndoMoves(moves, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- start(event, is_dead)
- undoMoves(moves, gamemodel)
Undo ‘moves’ moves and makes the latest board in gamemodel the current
- updateTime(secs, opsecs)
Updates the player with the current remaining time as a float of seconds
- property time
pychess.Players.ProtocolEngine module
- class pychess.Players.ProtocolEngine.ProtocolEngine(subprocess, color, protover, md5)
Bases:
pychess.Players.Engine.Engine
- isAnalyzing()
pychess.Players.PyChessCECP module
- class pychess.Players.PyChessCECP.PyChessCECP
Bases:
pychess.Players.PyChess.PyChess
- handle_sigterm(*args)
- makeReady()
- run()
- pychess.Players.PyChessCECP.get_input()
pychess.Players.PyChessFICS module
pychess.Players.UCIEngine module
- class pychess.Players.UCIEngine.UCIEngine(subprocess, color, protover, md5)
Bases:
pychess.Players.ProtocolEngine.ProtocolEngine
- end(status, reason)
Called when the game ends in a normal way. Use this for shutting down engines etc.
- getAnalysisLines()
- hasOption(key)
- hurry()
Forces engines to move now, and sends a hurry message to nonlocal human players
- kill(reason)
Kills the engine, starting with the ‘stop’ and ‘quit’ commands, then trying sigterm and eventually sigkill. Returns the exitcode, or if engine have already been killed, the method returns None
- async makeMove(board1, move, board2)
Takes a board object, and if ply>lowply the latest move object and second latest board object as well. Otherwise these two are None. Retruns: A new move object, witch the player wants to do.
- maxAnalysisLines()
- minAnalysisLines()
- offer(offer)
The players opponent has offered the player offer. If the player accepts, it should respond by mirroring the offer with emit(“accept”, offer). If it should either ignore the offer or emit “decline”.
- async parseLine(proc)
- pause()
Should stop the player from thinking until resume is called
- playerUndoMoves(moves, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- prestart()
- putMove(board1, move, board2)
Like makeMove, but doesn’t block and doesn’t return anything. putMove is only used when the player is spectatctor to a game
- requestMultiPV(n)
Set the number of analysis lines the engine will give, if possible.
If setting is too high, the engine’s maximum will be used. The setting will last until the next call to requestMultiPV. Return value: the setting used.
- resume()
Should resume player to think if he’s paused
- setBoard(board, search=True)
- setOption(key, value)
Set an option, which will be sent to the engine, after the ‘readyForOptions’ signal has passed. If you want to know the possible options, you should go to engineDiscoverer or use the hasOption method while you are in your ‘readyForOptions’ signal handler
- setOptionAnalyzing(mode)
- setOptionInitialBoard(model)
If the game starts at a board other than FEN_START, it should be sent here. We sends a gamemodel, so the engine can load the entire list of moves, if any
- setOptionStrength(strength, forcePonderOff)
Strength is a number [1,8] inclusive. Higher is better.
- setOptionTime(secs, gain, moves)
Seconds is the initial clock of the game. Gain is the amount of seconds a player gets after each move. If the engine doesn’t support playing with time, this will fail.
- setOptionVariant(variant)
Inform the engine of any special variant. If the engine doesn’t understand the variant, this will raise an error.
- set_board(board)
- spectatorUndoMoves(moves, gamemodel)
Some players undo different depending on whether they are players or spectators. This is a convenient way to handle that.
- start(event, is_dead)
- updateTime(secs, opsecs)
Updates the player with the current remaining time as a float of seconds
pychess.Players.engineNest module
- class pychess.Players.engineNest.EngineDiscoverer
Bases:
GObject
- addEngine(name, new_engine, protocol, vm_name, vm_args)
- addEngineFromReference(engine)
- backup()
- discover()
- getAnalyzers()
- getCountry(engine)
- getEngineByMd5(md5sum, list=[])
- getEngineByName(name, exactName=True)
- getEngineLearn()
- getEngineN(index)
- getEngineVariants(engine)
- getEngines()
Returns a sorted list of engine dicts
- getName(engine=None)
- getReferencedEngine(name)
This methods builds an automatic entry based on the name of the engine and the preconfigured values found for it.
- hasChanged()
- async initAnalyzerEngine(engine, mode, variant)
- async initEngine(engine, color, lowPriority)
- async initPlayerEngine(engine, color, diffi, variant, secs=0, incr=0, moves=0, forcePonderOff=False)
- is_analyzer(engine)
- pre_discover()
- removeEngine(name)
- restore()
- save(*args)
- async pychess.Players.engineNest.init_engine(analyzer_type, gamemodel, force_engine=None)
Initializes and starts the engine analyzer of analyzer_type the user has configured in the Engines tab of the preferencesDialog, for gamemodel. If no such engine is set in the preferences, or if the configured engine doesn’t support the chess variant being played in gamemodel, then no analyzer is started and None is returned.
- pychess.Players.engineNest.is_cecp(engine_command)
- pychess.Players.engineNest.is_uci(engine_command)
- pychess.Players.engineNest.md5_sum(filename)