pychess.Utils.validator
index
/home/thomas/Programmering/python/skak/svn/lib/pychess/Utils/validator.py

This module is written to do basic chess computing.
This module can validate a Move or generate a list of possible moves
It can also be used to find moves for SAN parsing
and to detect the status of the game

 
Functions
       
findMoves(board, testCheck=True)
Creates a dict of all legal moves for current player (baord.color)
Returns a dict of {fromcord:[tocord,tocord...],...}
findMoves2(board, testCheck=True, pureCaptures=False)
Generate all possible moves for current player (board.color)
genBishop(cord, board, pureCaptures=False)
Generate bishop moves. Bishop is located at cord
genKing(cord, board, pureCaptures=False)
Generate king moves. King is located at cord
genKnight(cord, board, pureCaptures=False)
Generate knight moves. Knight is located at cord
genLegalMoves(board, cord, testCheck)
Generate all legal moves for piece at cord
genMovesPointingAt(board, cols, rows, color, testCheck=False)
Returns a move that legaly attack a cord with the specified color
in one of the specified columns or rows
genPawn(cord, board, pureCaptures=False)
Generate pawn moves. Pawn is located at cord
genQueen(cord, board, pureCaptures=False)
Generate queen moves. Queen is located at cord
genRook(cord, board, pureCaptures=False)
Generate rook moves. Rook is located at cord
getMovePointingAt(board, cord, color=None, sign=None, r=None, c=None)
Returns a cord containing a piece that can attack the specified cord
If color, sign, r, or c is not = None, only cords with that
color / sign / row / column will be returned
isCheck(board, who)
Returns True if "who" is in check in the specified possition
status(history)
Returns a tuple of (the current status of the game, a comment of the reason)
Status can be one of RUNNING, DRAW, WHITEWON or BLACKWON.
Comment can be any from pychess.Utils.const or None, if status is RUNNING
time(...)
time() -> floating point number
 
Return the current time in seconds since the Epoch.
Fractions of a second may be present if the system clock provides them.
valiBishop(move, board, cancapture=False)
Validate bishop move
valiKing(move, board, cancapture=False)
Validate king move
valiKnight(move, board, cancapture=False)
Validate knight move
valiPawn(move, board, cancapture=False)
Validate pawn move
valiQueen(move, board, cancapture=False)
Validate queen move
valiRook(move, board, cancapture=False)
Validate rook move
validate(move, board, testCheck=True, cancapture=False)
Tests if "move" is a legal move on board "board"
Will asume the first cord of move is an ally piece
@param cancapture: Only test if the piece can capture cord1.
willCheck(board, move)
Returns True if the move will cause the player
making the move to be in check

 
Data
        AN = 3
ARTIFICIAL = 1
BISHOP = 3
BLACK = 1
BLACKWON = 3
BLACK_CASTLED = 32
BLACK_OO = 4
BLACK_OOO = 8
DRAW = 1
DRAW_50MOVES = 1
DRAW_ACCEPTION = 3
DRAW_AGREE = 3
DRAW_INSUFFICIENT = 4
DRAW_OFFER = 2
DRAW_REPITITION = 0
DRAW_STALEMATE = 2
FAN = 2
FLAG_CALL = 1
HINT = 0
KING = 0
KNIGHT = 4
LAN = 1
LOCAL = 0
NAME = 'PyChess'
PAWN = 5
PREFIX = '/home/thomas/Programmering/python/skak/svn'
QUEEN = 1
REMOTE = 2
RESIGNATION = 0
ROOK = 2
RUNNING = 0
SAN = 0
SPY = 1
VERSION = '0.6.0_beta'
WHITE = 0
WHITEWON = 2
WHITE_CASTLED = 16
WHITE_OO = 1
WHITE_OOO = 2
WON_CALLFLAG = 6
WON_MATE = 7
WON_RESIGN = 5
checkDic = {}
chr2Sign = {'b': 3, 'k': 0, 'n': 4, 'p': 5, 'q': 1, 'r': 2}
hashfALPHA = 0
hashfBETA = 1
hashfEXACT = 2
kingPlaces = ((1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1))
knightPlaces = ((1, 2), (2, 1), (2, -1), (1, -2), (-1, -2), (-2, -1), (-2, 1), (-1, 2))
localePrefixes = ('/usr/share/locale', '/usr/local/share/locale')
log = <Log object (pychess+System+Log+Log)>
movePool = <pychess.Utils.Move.MovePool instance>
moveToCastling = {'e1c1': 2, 'e1g1': 1, 'e8c8': 8, 'e8g8': 4}
prefixes = ('/usr/share', '/usr/local/share', '/usr/share/games', '/usr/local/share/games')
range8 = (3, 4, 2, 5, 1, 6, 0, 7)
reprColor = ['White', 'Black']
reprMode = ['hint', 'spy']
reprPiece = ['King', 'Queen', 'Rook', 'Bishop', 'Knight', 'Pawn']
reprResult = ['*', '1/2-1/2', '1-0', '0-1']
reprSign = ['K', 'Q', 'R', 'B', 'N', 'P']