예제 #1
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")	
예제 #2
0
 def move(self, move):
     args = {
         'board': self.numpyify(), 
         'wc': np.array(self.wc).astype(np.uint8), 
         'bc': np.array(self.bc).astype(np.uint8), 
         'ep': self.ep, 
         'kp': self.kp,
         'score': self.score
     }
     pos = chess.make_move(args, np.array(move).astype(np.int32))
     return Position(self.stringify(pos['board']), pos['score'], tuple(map(lambda x: bool(x), pos['wc'])), tuple(map(lambda x: bool(x), pos['bc'])), pos['ep'], pos['kp'])
예제 #3
0
 def move(self, move):
     args = {
         'board': self.numpyify(),
         'wc': np.array(self.wc).astype(np.uint8),
         'bc': np.array(self.bc).astype(np.uint8),
         'ep': self.ep,
         'kp': self.kp,
         'score': self.score
     }
     pos = chess.make_move(args, np.array(move).astype(np.int32))
     return Position(self.stringify(pos['board']), pos['score'],
                     tuple(map(lambda x: bool(x), pos['wc'])),
                     tuple(map(lambda x: bool(x), pos['bc'])), pos['ep'],
                     pos['kp'])
예제 #4
0
파일: play.py 프로젝트: StMichael99/games
def try_move(game, attempted_move):
    for move in chess.legal_moves(game, game.to_move):
        if move == attempted_move:
            game = chess.make_move(game, move)
    return game
예제 #5
0
파일: play.py 프로젝트: StMichael99/games
def make_AI_move(game, color):
    set_title(SCREEN_TITLE + ' - Calculating move...')
    new_game = chess.make_move(game, chess.get_AI_move(game, AI_SEARCH_DEPTH))
    set_title(SCREEN_TITLE)
    print_board(new_game.board, color)
    return new_game
예제 #6
0
def try_move(game, attempted_move):
    for move in chess.legal_moves(game, game.to_move):
        if move == attempted_move:
            game = chess.make_move(game, move)
    return game
예제 #7
0
def make_AI_move(game, color):
    set_title(SCREEN_TITLE + ' - Calculating move...')
    new_game = chess.make_move(game, chess.get_AI_move(game, AI_SEARCH_DEPTH))
    set_title(SCREEN_TITLE)
    print_board(new_game.board, color)
    return new_game