schroedingerchess package¶
Submodules¶
schroedingerchess.chess module¶
First test for chess implementation.
-
class
schroedingerchess.chess.ChessBoard[source]¶ Bases:
objectChess board manipulation.
-
add_move_to_history(x1, y1, x2, y2, piece, target_piece)[source]¶ Add move to history (temporarily or not).
-
move(x1, y1, x2, y2, disp=True)[source]¶ Test and perform a move.
Will raise IllegalMove if the move is not valid.
-
nature_elimination(piece, x1, y1, x2, y2)[source]¶ Find which natures got impossible for the piece that just moved.
-
possible_move(x1, y1, x2, y2, n, c)[source]¶ Decide if a move belongs to the abilities of a piece nature.
Special case for pawns where it depends upon the color, target and the previous moves.
-
quantum_explanation(check=None)[source]¶ Perform consistency check with MIP.
Returns the solved linear problem.
-
-
class
schroedingerchess.chess.ChessPiece(c, i, n, p, b=None)[source]¶ Bases:
objectChess piece manipulation.
schroedingerchess.client module¶
-
class
schroedingerchess.client.ChessClientProtocol(client)[source]¶ Bases:
twisted.internet.protocol.ProtocolClass which handles the communication protocol between the game client and the game server.
-
connectionLost(reason)[source]¶ Handles the connection lost with the server. :param reason: Reason of the disconnection
-
connectionMade()[source]¶ Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
-
dataReceived(data)[source]¶ Handles the reception of data from the server. :param data: A byte representing a JSON-encoded object (default encoding UTF-8)
-
schroedingerchess.display module¶
Display chess board.
-
class
schroedingerchess.display.ChessDisplay(gameEngine)[source]¶ Bases:
objectDisplay of the chess board.
-
addMessage(message)[source]¶ Split the incoming text message according to the screen size and add it to the message history :param message: A string message
-
drawBoard(lightBoard)[source]¶ Draws the board. :param lightBoard: The light board to draw. :see LightBoard
-
drawCheckMates(checkmate_positions)[source]¶ Draws the checkmates created by the last move. :param checkmates_positions: List of the checkmate positions.
-
drawChecks(check_positions)[source]¶ Draws the checks created by the last move. :param check_positions: List of the check positions.
-
flipDisplay(newState)[source]¶ Set the display orientation :param newState: Is True if and only if the display has to be upside down (Black in the lower part)
-
schroedingerchess.game_engines module¶
-
class
schroedingerchess.game_engines.GameEngine[source]¶ Bases:
object-
setOnePlayerOnNetworkMode(name, address, color)[source]¶ Sets the engine on the one-player-on-network mode.
-
-
class
schroedingerchess.game_engines.OnePlayerOnNetwork(gameEngine, name, address=None, color=0)[source]¶
schroedingerchess.run module¶
schroedingerchess.server module¶
-
class
schroedingerchess.server.ChessServer[source]¶ Bases:
twisted.internet.protocol.FactoryGame server : produces a new ChessServerProtocol each time a client arrives
-
protocol¶ alias of
ChessServerProtocol
-
-
class
schroedingerchess.server.ChessServerProtocol[source]¶ Bases:
twisted.internet.protocol.ProtocolClass to handles the communication protocol with a game client.
-
connectionLost(reason)[source]¶ Handles the connection lost with the client (executes automatically). :param reason: Reason of the disconnection
-
dataReceived(data)[source]¶ Handles the reception of data by the server :param data: A byte representing a JSON-encoded object (default encoding UTF-8)
-
refuseMessage(msg)[source]¶ Handles the reception of messages when waiting for second player. All instructions are illegal. :param msg: A dictionary representing a message.
-
sendMessage(msg)[source]¶ Sends a message to the client. :param msg: A dictionary representing a message.
-
sendMessageToAll(msg)[source]¶ Sends a message to the client and the other player’s client. :param msg: A dictionary representing a message.
-