アットウィキロゴ

じんこい

class sho:
 
    def makeput(self):
 
        sig=[]
        c=[]   
        for i in range(10):
            c.append(0)
 
        for i in range(6):
            sx=self.pos[i]
            c[sx]=c[sx]+1
 
        c[0]=100
        for j in range(10):
           if c[j]==0:
              sig.append(j)
 
        return sig
 
    def change(self):
 
        c=[]   
        for i in range(10):
            c.append(0)
 
        for i in range(6):
            sx=self.pos_chx[i]
            c[sx]=c[sx]+1
 
        ch=0
        for i in range(6):
            h=0
            p3=self.pos_chx[i]
            if c[p3]>1:
               h=100
            if self.hand_chx[i]==self.mode:
               h=0
            if h>50:
               self.pos_chx[i]=0
               self.hand_chx[i]=self.mode
 
    def check(self,pon):
 
        c=[]   
        for i in range(10):
            c.append(0)
 
        for i in range(6):
            if self.hand[i]==self.mode:
               sx=pon[i]
               c[sx]=c[sx]+1
 
        ch=0
        for i in range(1,10):
            if c[i]>1:
               ch=100
 
        return ch    
 
    def policy(self):
 
        koma_sel=self.select_a()
 
 
        sig=[]
        for u in koma_sel:
            dir=self.makedir(self.hand[u],self.koma[u])
            for d in dir:
                pos_ch=[]
                for pc in self.pos:
                    pos_ch.append(pc)
                px=self.pos[u]
                x1=self.ban[px][0]+d[0]
                y1=self.ban[px][1]+d[1]
                b1=[x1,y1]
                p1=self.point(b1)
                pos_ch[u]=p1
                if p1>0:
                   sig.append(pos_ch)
 
        return sig
 
    def point(self,d):
 
        m=-1  
        for i in range(10):
           if self.ban[i]==d:
              m=i
        return m  
 
    def makedir(self,h1,k1):
 
        dir=[]
        if k1=="王": 
           dir.append([1,1])
           dir.append([1,-1])
           dir.append([-1,1])
           dir.append([-1,-1])
           dir.append([1,0])
           dir.append([0,1])
           dir.append([-1,0])
           dir.append([0,-1])
 
        h=0
        if k1=="歩":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
 
        h=0
        if k1=="歩":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,-1])
 
        h=0
        if k1=="金":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,1]) 
           dir.append([-1,1]) 
 
        h=0
        if k1=="金":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,-1]) 
           dir.append([-1,-1]) 
 
        h=0
        if k1=="銀":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([1,1]) 
           dir.append([-1,1]) 
           dir.append([-1,-1]) 
           dir.append([1,-1])  
 
        h=0
        if k1=="銀":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,-1])     
           dir.append([1,-1]) 
           dir.append([-1,-1]) 
           dir.append([-1,1]) 
           dir.append([1,1]) 
 
        h=0
        if k1=="桂":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([1,2])     
           dir.append([-1,2]) 
 
        h=0
        if k1=="桂":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([1,-2])     
           dir.append([-1,-2])
 
        h=0
        if k1=="香":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,2]) 
 
        h=0
        if k1=="香":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,-1])     
           dir.append([0,-2])
 
        if k1=="飛": 
           dir.append([1,0])
           dir.append([0,1])
           dir.append([-1,0])
           dir.append([0,-1])      
           dir.append([2,0])
           dir.append([0,2])
           dir.append([-2,0])
           dir.append([0,-2])
 
        if k1=="角": 
           dir.append([1,1])
           dir.append([1,-1])
           dir.append([-1,1])
           dir.append([-1,-1])      
           dir.append([2,2])
           dir.append([2,-2])
           dir.append([-2,2])
           dir.append([-2,-2]) 
 
        h=0
        if k1=="と":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,1]) 
           dir.append([-1,1]) 
 
        h=0
        if k1=="と":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,-1]) 
           dir.append([-1,-1])
 
        h=0
        if k1=="成香":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,1]) 
           dir.append([-1,1])
 
        h=0
        if k1=="成香":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,-1]) 
           dir.append([-1,-1])
        h=0
        if k1=="成桂":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,1]) 
           dir.append([-1,1])
        h=0
        if k1=="成桂":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,-1]) 
           dir.append([-1,-1])
        h=0
        if k1=="成銀":
           h=h+1
        if h1=="先手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,1]) 
           dir.append([-1,1])
        h=0
        if k1=="成銀":
           h=h+1
        if h1=="後手":
           h=h+1
        if h==2:
           dir.append([0,1])     
           dir.append([0,-1]) 
           dir.append([1,0]) 
           dir.append([-1,0]) 
           dir.append([1,-1]) 
           dir.append([-1,-1])
 
        if k1=="竜王": 
           dir.append([1,1])
           dir.append([1,-1])
           dir.append([-1,1])
           dir.append([-1,-1])
           dir.append([1,0])
           dir.append([0,1])
           dir.append([-1,0])
           dir.append([0,-1])
           dir.append([2,0])
           dir.append([0,2])
           dir.append([-2,0])
           dir.append([0,-2])
 
        if k1=="竜馬": 
           dir.append([1,1])
           dir.append([1,-1])
           dir.append([-1,1])
           dir.append([-1,-1])
           dir.append([1,0])
           dir.append([0,1])
           dir.append([-1,0])
           dir.append([0,-1])
           dir.append([2,2])
           dir.append([-2,-2])
           dir.append([-2,2])
           dir.append([2,-2])
 
        return dir
 
    def select_a(self):
 
        koma_sel=[]
 
        for u in range(6):
           h=0
           if self.hand[u]==self.mode:
              h=h+1
           if self.pos[u]>0:
              h=h+1
           if h==2:       
              koma_sel.append(u)
 
        return koma_sel
 
    def select_b(self):
 
        koma_b=[]
 
        for u in range(6):
           h=0
           if self.hand[u]==self.mode:
              h=h+1
           if self.pos[u]==0:
              h=h+1
           if h==2:       
              koma_b.append(u)
 
        return koma_b
最終更新:2018年01月16日 05:39