36D杯-杂项-Match3Game

admin 2022年1月5日22:50:59评论24 views字数 1151阅读3分50秒阅读模式

>

>

36D杯-杂项-Match3Game

ThTsOd

from pwn import *
import time
r=remote("124.156.121.112",28008)
#r=process("./a.out")
context.log_level='warn'
board=[]

def checkmatch():
    for x in range(8):
        for y in range(8):
            if(y+1<8 and y+2<8 and board[x][y]==board[x][y+1]==board[x][y+2]):
                return True
            if(x+1<8 and x+2<8 and board[x][y]==board[x+1][y]==board[x+2][y]):
                return True
    return False

def checkmove(x,y,d):
    #hor
    if d==0:
        if(y+1>=8):
            return False
        temp=board[x][y]
        board[x][y]=board[x][y+1]
        board[x][y+1]=temp
        result=checkmatch()
        temp=board[x][y]
        board[x][y]=board[x][y+1]
        board[x][y+1]=temp
    #vec
    elif d==1:
        if(x+1>=8):
            return False
        temp=board[x][y]
        board[x][y]=board[x+1][y]
        board[x+1][y]=temp
        result=checkmatch()
        temp=board[x][y]
        board[x][y]=board[x+1][y]
        board[x+1][y]=temp
    return result
move=""
t1=time.time()
r.sendline()

while(1):
    move=""
    board=[]
    r.recvuntil("-----------------\n")
    r.recvline()
    for i in range(8):
        board.append(list(r.recvline()[1:-1]))

    for i in range(8):
        for j in range(8):
            if(checkmove(i,j,0)):
                move=str(j)+str(i)+'D'
            if(checkmove(i,j,1)):
                move=str(j)+str(i)+'S'
            if(move==""):
                continue
    else:
        r.sendline(move)
    #print(move)
    t2=time.time()
    if(t2-t1>38):
        context.log_level='debug'

PS.可以去玩玩Bejeweled
PPS.限制步数就要考虑消除数量了,这个可能太难就去掉了。限制时间就可以无脑乱消看运气过。


  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月5日22:50:59
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   36D杯-杂项-Match3Gamehttp://cn-sec.com/archives/719360.html

发表评论

匿名网友 填写信息