def setUp(self): self.numberofloops = 10 self.board = chessboard.ChessBoard() self.board[27] = pieces.KingPiece('white') self.board[45] = pieces.KingPiece('black') self.generator = movegenerator.MoveGenerator(self.board) return None
def setUp(self): self.board = chessboard.ChessBoard() self.board[18] = pieces.QueenPiece('white') self.board[19] = pieces.PawnPiece('white') self.board[23] = pieces.RookPiece('black') self.board[42] = pieces.KnightPiece('black') self.generator = movegenerator.MoveGenerator(self.board)
def makebestmove(board): """Makes the best move on board.""" print "\nThe computer is thinking...\n" time.sleep(SLEEP_TIME) movelist = movegenerator.MoveGenerator(board).generatemovelist( board.computercolour) makemove(random.choice(movelist), board) return board
def checkorcheckmatesymbol(colour, board): """Determines if the move requires a special symbol.""" generator = movegenerator.MoveGenerator(board) oppositecolour = core.oppositecolour(colour) specialsymbol = '' if generator.kingincheck(oppositecolour): if len(generator.generatemovelist(oppositecolour)) == 0: # Checkmate! specialsymbol += '#' else: # Else just check. specialsymbol += '+' return specialsymbol
def setUp(self): board = chessboard.ChessBoard() board[4] = pieces.KingPiece('white') board[8] = pieces.PawnPiece('white') board[9] = pieces.PawnPiece('white') board[13] = pieces.PawnPiece('white') board[14] = pieces.PawnPiece('white') board[23] = pieces.PawnPiece('white') board[60] = pieces.KingPiece('black') board[17] = pieces.RookPiece('black') board[30] = pieces.RookPiece('black') self.generator = movegenerator.MoveGenerator(board) return None
def setUp(self): self.board = chessboard.ChessBoard() self.board[60] = pieces.KingPiece('black') self.board[4] = pieces.KingPiece('white') self.board[51] = pieces.PawnPiece('black') self.board[52] = pieces.PawnPiece('black') self.board[53] = pieces.PawnPiece('black') self.board[49] = pieces.PawnPiece('black') self.board[36] = pieces.PawnPiece('white') self.board[34] = pieces.PawnPiece('white') self.generator = movegenerator.MoveGenerator(self.board) return None
def setUp(self): self.board = chessboard.ChessBoard() self.board[0] = pieces.RookPiece('white') self.board[55] = pieces.RookPiece('white') self.board[4] = pieces.KingPiece('white') self.board[10] = pieces.PawnPiece('white') self.board[13] = pieces.PawnPiece('white') self.board[15] = pieces.PawnPiece('white') self.board[31] = pieces.BishopPiece('black') self.board[56] = pieces.RookPiece('black') self.board[60] = pieces.KingPiece('black') self.board[49] = pieces.PawnPiece('black') self.generator = movegenerator.MoveGenerator(self.board) return None
def mobilityscore(self, board): """Determines how mobile each side is and returns a net score.""" generator = movegenerator.MoveGenerator(board) whitemobility = len(generator.generatemovelist('white')) * 100 blackmobility = len(generator.generatemovelist('black')) * 100 return whitemobility - blackmobility
def test_initialise_and_generate(self): with Timer() as t: for x in xrange(self.numberofloops): movegenerator.MoveGenerator(self.board).generatemovelist('white') print '\n\t=> elapsed time for %i loops: %s s' % (self.numberofloops, t.secs) return None
def islegalmove(colour, movetuple, board): """Determine if the move is legal.""" generator = movegenerator.MoveGenerator(board) allallowedmoves = generator.generatemovelist(colour) return movetuple in allallowedmoves