from jeton import *
import time

class Coeur:
    
    def __init__(self):
        
        self.MAX_PLY=32
        self.pv_length=[0 for x in range(self.MAX_PLY)]
        self.INFINITY=32000        
        self.init()

    
    def usermove(self,b,c):
       
        pos1=b.caseStr2Int(c[0]+c[1])
        pos2=b.caseStr2Int(c[2]+c[3])
        
      
        promote=''
        if(len(c)>4):
            promote=c[4]
            if(promote=='q'):
                promote='q'
            elif(promote=='r'):
                promote='r'
            elif(promote=='n'):
                promote='n'
            elif(promote=='b'):
                promote='b'
         
        mList=b.gen_moves_list()
    
        if((b.domove(pos1,pos2,promote)==False)):
            print("\n"+c+' : Mouvement incorrect'+"\n")
            return
        
        b.render()
   
    def clear_pv(self):
       
        
        self.pv=[[0 for x in range(self.MAX_PLY)] for x in range(self.MAX_PLY)]
  

    def rplateau(self,b,c):
        
        cmd=c.split()
        cmd.pop(0) 

        if(b.rplateau(' '.join(cmd))):
            self.endgame=False 
            
    
    def newgame(self,b):
        
        self.init()
        b.init()
        
    
    def init(self):
        self.endgame=False    
        self.init_depth=4
        self.nodes=0 
        self.clear_pv()


        
