def stockFish_init(request): stockfish = Stockfish(parameters={ "Threads": 2, "Minimum Thinking Time": 30 }) stockfish.set_position(["e2e4", "e7e6"]) #posición de Forsyth–Edwards Notation (FEN) stockfish.set_fen_position( "rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2") #coge el mejor movimiento stockfish.get_best_move( ) #stockfish.get_best_move_time(1000) en base al tiempo #nivel del motor stockfish.set_skill_level(15) #parámetros por defecto stockfish.get_parameters() #coge la posición FEN stockfish.get_fen_position() #coge el tablero por defecto del usuario stockfish.get_board_visual() #evalua jugada stockfish.get_evaluation() p = subprocess.Popen('stockfish-x64.exe', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.stdin.write("position startpos moves e2e4 e7e5\n") p.stdin.write("go infinite\n") p.stdin.flush() time.sleep(1) print(p.communicate())
def test_stockfish_constructor_with_custom_params(self): stockfish = Stockfish(parameters={"Skill Level": 1}) assert stockfish.get_parameters() == { "Write Debug Log": "false", "Contempt": 0, "Min Split Depth": 0, "Threads": 1, "Ponder": "false", "Hash": 16, "MultiPV": 1, "Skill Level": 1, "Move Overhead": 30, "Minimum Thinking Time": 20, "Slow Mover": 80, "UCI_Chess960": "false", }
#board = visboard.board def get_board_state(): board = visboard.board # please use appropriate file path stockfish = Stockfish( 'C:/Users/patri/PycharmProjects/chess-ai/stockfish_10_x64.exe') # set position by sequence of moves: stockfish.set_position(['e2e4', 'e7e6']) # set position by Forsyth–Edwards Notation (FEN): stockfish.set_fen_position( "rnbqkbnr/pppp1ppp/4p3/8/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2") print(stockfish.get_best_move()) # d2d4 print(stockfish.is_move_correct('a2a3')) # True # get last move info: print(stockfish.info) # e.g. 'info depth 2 seldepth 3 multipv 1 score mate -1 nodes 11 nps 5500 tbhits 0 time 2 pv h2g1 h4g3' # set current engine's skill level: stockfish.set_skill_level(15) # get current engine's parameters: stockfish.get_parameters()