예제 #1
0
	def run(self):
		global computerThinking
		chess.print_board(b)
		computerThinking = True
		move = chess.pfind_move(b, 1 if playAsWhite else 0, maxTime)
                chess.end()
		chess.take_move(move, b)
		board[chess.get_from(move)].clear()
		board[chess.get_to(move)].piece = chess.get_piece(move) + \
			  6 * chess.get_side(move)
		board[chess.get_to(move)].updateImage()
		computerThinking = False 
예제 #2
0
def movePiece(sq):
	global pieceToMove
	global sqMovingFrom
	global board
	global globalImages
	
	if sq.piece and not pieceToMove and not moveThread.isAlive():	
		if sqMovingFrom != -1:
			col = "#E6F7F4" if (sqMovingFrom + sqMovingFrom / 8) % 2 \
				  else "#7FC44B"
			board[sqMovingFrom].configure(background=col)
		pieceToMove = sq.piece
		sqMovingFrom = sq.index
		sq.configure(background="#61B8A2")
		
	elif pieceToMove and sqMovingFrom != sq.index and \
		 chess.pseudo_legal(chess.make_move(sqMovingFrom, sq.index, b), 
		 b) and not moveThread.isAlive():
		sq.piece = pieceToMove
		sq.updateImage()
		pieceToMove = 0
		chess.take_move(chess.make_move(sqMovingFrom, sq.index, b), b)
		board[sqMovingFrom].clear()
		sqMovingFrom = -1 
				
		if playComputer:
			global moveThread
			moveThread = FindMoveThread(Queue.Queue())
			moveThread.start()
			print 'foo'
	
	elif not moveThread.isAlive() and sqMovingFrom != sq.index:
		if sqMovingFrom != -1:
			board[sqMovingFrom].clear()

		if (sq.index + sq.index / 8) % 2:
			sq.configure(bg="#E6F7F4")
		else:
			sq.configure(bg="#7FC44B")

		pieceToMove = 0
		sqMovingFrom = -1
	
	else:
		pieceToMove = 0
		sqMovingFrom = -1
		if (sq.index + sq.index / 8) % 2:
			sq.configure(bg="#E6F7F4")
		else:
			sq.configure(bg="#7FC44B")