예제 #1
0
class ChessEngine:
    def __init__(self):
        self.Engine = Engine(depth=19)

    def get_best_move(self, fen):
        self.Engine.setfenposition(fen)
        return self.Engine.bestmove()["move"]
예제 #2
0
파일: minimax.py 프로젝트: js837/chess
    def breadth_search(cls, position, depth):

        with open('dump1.txt','rb') as old_file:
            old_data = old_file.readlines()

        old_data_dict = dict((ln.strip().split(';')[0],ln.strip().split(';')[2]) for ln in old_data)



        with open('dump2.txt','a') as f:

            # Temp
            from pystockfish import Engine
            eng = Engine(depth=15)

            from ai.basic import ShannonAI
            unexplored = [(position, 0)]
            explored = []
            while unexplored:
                new_position, new_depth = unexplored.pop(0)



                fen = PositionSerializer.to_fen(new_position)

                if fen not in old_data_dict:
                    eng.setfenposition(fen)

                    best_move = eng.bestmove()['move']

                    line = '{0};{1};{2}\n'.format(fen,str(new_depth), best_move)

                    f.write(line)
                    f.flush()

                evaluation = ShannonAI.evaluate(new_position)
                explored.append((new_position, new_depth, evaluation))
                if new_depth < depth:
                    moves = new_position.get_moves()
                    for move in moves:
                        unexplored.append((move, new_depth+1))

            return explored
예제 #3
0
파일: untitled2.py 프로젝트: freesloth/fsd
# -*- coding: utf-8 -*-
"""
Created on Wed May 27 03:05:42 2020

@author: user
"""

from pystockfish import Engine

deepthinker = Engine(depth=15)
deepthinker.setposition(['e2e4', 'e7e5'])
deepthinker.bestmove()