def cpu4(self,field,puyo): kekka=np.zeros((3,22),dtype=np.int) aipuyo=AIPuyo() for i in range(22): aifield=AIField(field) aipuyo.syokika(puyo) a=self.cpu_idouhantei(aifield,aipuyo,i+1) if a==1: aipuyo.puyooki(i+1) aipuyo.rakka(aifield) if aifield.shin_rensashirabe()>=5: return i+1 if aifield.renketusirabe5(aipuyo): continue b=aifield.renketusirabe4(aipuyo) kekka[0][i]=b[0] kekka[1][i]=b[1] kekka[2][i]=aifield.rensashirabe() rensamax=kekka[2].max() for i in range(22): if kekka[2][i]!=rensamax: kekka[0][i]=0 renketumax=kekka[0].max() for i in range(22): if kekka[0][i]!=renketumax: kekka[1][i]=100000 return kekka[1].argmin()+1
def cpu3(self,field,puyo): kekka=np.zeros((2,22),dtype=np.int) aipuyo=AIPuyo() for i in range(22): aifield=AIField(field) aipuyo.syokika(puyo) a=self.cpu_idouhantei(aifield,aipuyo,i+1) if a==1: aipuyo.puyooki(i+1) aipuyo.rakka(aifield) b=aifield.renketusirabe2(i+1,aipuyo) kekka[0][i]=b[0] kekka[1][i]=b[1] renketumax=kekka[0].max() for i in range(22): if kekka[0][i]!=renketumax: kekka[1][i]=100000 return kekka[1].argmin()+1
def run(self): sakiyomicpu_c = 0 kirikae_c = 0 sousamati_c = 0 while True: if cpu.cpu_sousa_c == 0: sousamati_c += 1 else: sousamati_c = 0 if sousamati_c >= 30: karifield = AIField(field2.haichi) karifield.zenkeshihyouji = field2.zenkeshihyouji imapuyo = AIPuyo() imapuyo.syokika(puyo_2) imapuyo2 = AIPuyo() imapuyo2.puyo1iro = puyo_2.nexnex[0] imapuyo2.puyo2iro = puyo_2.nexnex[1] imapuyo2.puyo1x = 3 imapuyo2.puyo1y = 13 imapuyo2.puyo2x = 3 imapuyo2.puyo2y = 12 cpu2.cpu_c = cpu2.ai11(karifield, field1, imapuyo, imapuyo2) time.sleep(0.001) sousamati_c = 0 if kirikae_c == 0: karifield = AIField(field2.haichi) karifield.zenkeshihyouji = field2.zenkeshihyouji karipuyo = AIPuyo() karipuyo.syokika(puyo_2) karipuyo.puyooki(cpu2.cpu_c) karipuyo.rakka(karifield.haichi) karifield.sokurensa() imapuyo = AIPuyo() imapuyo2 = AIPuyo() imapuyo.puyo1iro = puyo_2.nexnex[0] imapuyo.puyo2iro = puyo_2.nexnex[1] imapuyo2.puyo1iro = puyo_2.nexnex[2] imapuyo2.puyo2iro = puyo_2.nexnex[3] imapuyo.puyo1x = 3 imapuyo.puyo1y = 13 imapuyo.puyo2x = 3 imapuyo.puyo2y = 12 imapuyo2.puyo1x = 3 imapuyo2.puyo1y = 13 imapuyo2.puyo2x = 3 imapuyo2.puyo2y = 12 t1 = time.time() # pr=Profile() # pr.enable() sakiyomicpu_c = cpu2.ai11(karifield, field1, imapuyo, imapuyo2) # pr.disable() # pr.print_stats() t2 = time.time() print(t2 - t1) kirikae_c = 1 sousamati_c = 0 else: if puyo_2.imapuyo_c == 0: puyo_2.kaiten_c = 0 puyo_2.migi_c = 0 puyo_2.hidari_c = 0 cpu2.cpu_c = sakiyomicpu_c # print(cpu2.cpu_c) kirikae_c = 0 puyo_2.imapuyo_c = 1 time.sleep(0.001)
def run(self): sakiyomicpu_c = 0 kirikae_c = 0 while True: if kirikae_c == 0: karifield = AIField(field2.haichi) karipuyo = AIPuyo() karipuyo.syokika(puyo_2) karipuyo.puyooki(cpu2.cpu_c) karipuyo.rakka(karifield.haichi) karifield.sokurensa() imapuyo = AIPuyo() imapuyo.puyo1iro = puyo_2.nexnex[0] imapuyo.puyo2iro = puyo_2.nexnex[1] if puyo_2.hajime_c == 1: imapuyo.puyo1x = 3 imapuyo.puyo1y = 13 imapuyo.puyo2x = 3 imapuyo.puyo2y = 12 else: imapuyo.puyo1x = puyo_2.puyo1x imapuyo.puyo1y = puyo_2.puyo1y imapuyo.puyo2x = puyo_2.puyo2x imapuyo.puyo2y = puyo_2.puyo2y # t1=time.time() sakiyomicpu_c = cpu2.ai4(karifield.haichi, imapuyo) # t2=time.time() # print(t2-t1) kirikae_c = 1 else: if puyo_2.imapuyo_c == 0: cpu2.cpu_c = sakiyomicpu_c # print(cpu2.cpu_c) kirikae_c = 0 puyo_2.imapuyo_c = 1 time.sleep(0.001)
def run(self): clock = pygame.time.Clock() puyo_1.syote(tumo) time.sleep(2) t_total = 0 t_kaisuu = 0 while True: t_kaisuu += 1 field1.haichi_c = 1 puyo_1.syokika(tumo) tugipuyo = AIPuyo() tugipuyo.puyo1iro = puyo_1.nexnex[0] tugipuyo.puyo2iro = puyo_1.nexnex[1] tugipuyo.puyo1x = 3 tugipuyo.puyo1y = 13 tugipuyo.puyo2x = 3 tugipuyo.puyo2y = 12 t1 = time.time() cpu.cpu_c = cpu.ai5(field1.haichi, puyo_1, tugipuyo) t2 = time.time() print(t2 - t1) print(cpu.cpu_c) # if t_kaisuu!=1: # t_total+=t2-t1 # print(t_total/t_kaisuu) while True: if syuuryou.syuuryou_c == 0: pygame.quit() sys.exit() clock.tick(60) puyo_1.surinukecount += 1 puyo_1.surinukecount2 += 1 puyo_1.kaiten_c = 0 cpu.cpu_sousa_c = cpu.cpu_sousa(field1, puyo_1) puyo_1.yokoidou(field1) if puyo_1.shita_c > 0: idou = puyo_1.idouhantei(field1, 3) if idou == 1: puyo_1.idou_c += 10 puyo_1.rakkab_c += 1 elif idou == 0: puyo_1.setticount += 50 if puyo_1.kaiten_c == 1: puyo_1.hidarikaiten(field1) elif puyo_1.kaiten_c == 2: puyo_1.migikaiten(field1) break_c = puyo_1.shitaidou(field1) if break_c == 1: break time.sleep(0.4) countcheck = field1.counttotal2 field1.rensa(field2) field1.counttotal_a += field1.counttotal field1.counttotal = 0 field1.rensa_c = 0 if countcheck != field1.counttotal2: field1.zenkeshicount = 0 for i in range(1, 14): for j in range(1, 7): if field1.haichi[i][j] != 0: field1.zenkeshicount += 1 if field1.zenkeshicount == 0: field1.zenkeshihyouji = 1 if field2.counttotal_a >= 70: field2.counttotal_a = field1.ojamarakka(field2) if field1.haichi[12][3] != 0: syuuryou.syuuryou_c = 0 pygame.quit() sys.exit()
def run(self): sakiyomicpu_c = 0 kirikae_c = 0 sousamati_c = 0 while True: if cpu.cpu_sousa_c == 0: sousamati_c += 1 else: sousamati_c = 0 if sousamati_c >= 30: karifield = AIField(field1.haichi) imapuyo = AIPuyo() imapuyo.syokika(puyo_1) imapuyo2 = AIPuyo() imapuyo2.puyo1iro = puyo_1.nexnex[0] imapuyo2.puyo2iro = puyo_1.nexnex[1] imapuyo2.puyo1x = 3 imapuyo2.puyo1y = 13 imapuyo2.puyo2x = 3 imapuyo2.puyo2y = 12 cpu.cpu_c = cpu.ai8(karifield, field2, imapuyo, imapuyo2) time.sleep(0.001) sousamati_c = 0 if kirikae_c == 0: karifield = AIField(field1.haichi) karipuyo = AIPuyo() karipuyo.syokika(puyo_1) karipuyo.puyooki(cpu.cpu_c) karipuyo.rakka(karifield.haichi) karifield.sokurensa() imapuyo = AIPuyo() imapuyo2 = AIPuyo() imapuyo.puyo1iro = puyo_1.nexnex[0] imapuyo.puyo2iro = puyo_1.nexnex[1] imapuyo2.puyo1iro = puyo_1.nexnex[2] imapuyo2.puyo2iro = puyo_1.nexnex[3] imapuyo.puyo1x = 3 imapuyo.puyo1y = 13 imapuyo.puyo2x = 3 imapuyo.puyo2y = 12 imapuyo2.puyo1x = 3 imapuyo2.puyo1y = 13 imapuyo2.puyo2x = 3 imapuyo2.puyo2y = 12 # t1=time.time() # pr=Profile() # pr.enable() sakiyomicpu_c = cpu.ai8(karifield, field2, imapuyo, imapuyo2) # pr.disable() # pr.print_stats() # t2=time.time() # print(t2-t1) kirikae_c = 1 sousamati_c = 0 else: if puyo_1.imapuyo_c == 0: cpu.cpu_c = sakiyomicpu_c print(cpu.cpu_c) kirikae_c = 0 puyo_1.imapuyo_c = 1 time.sleep(0.001)