黎明守望者吧 关注:5贴子:192
  • 6回复贴,共1

找吧主说件事

只看楼主收藏回复

@幻影流年总是愁


1楼2014-01-30 17:56回复
    下午你拷的那份五子棋代码有问题,我发个正确的


    2楼2014-01-30 17:57
    回复
      你把以下代码复制到记事本,改成vbs


      3楼2014-01-30 17:58
      回复
        on error resume next
        dim [棋局](30,30),a,b,c,d,e,f,g,h,m,x,y,black,white
        [棋盘]
        f=0
        do until m=vbno
        do while cdbl(f/2)=int(f/2)
        f=f+1
        [显示]=""
        [显示画面]
        black=inputbox([显示],"轮黑棋出手"):[下黑棋]
        if black=false or m=vbno then wscript.quit
        if black="" or [棋局](b,c)="○" then black=inputbox([显示]&"输入错误,请重新输入","输入错误 下黑棋"):[下黑棋]
        loop
        do while cdbl(f/2)<>int(f/2)
        f=f+1
        [显示]=""
        [显示画面]
        white=inputbox([显示],"轮白棋出手"):[下白棋]
        if white=false or m=vbno then wscript.quit
        if white="" or [棋局](d,e)="●" then white=inputbox([显示]&"输入错误,请重新输入","输入错误 下白棋"):[下白棋]
        loop
        loop
        sub [显示画面]
        for i=0 to 18
        for j=0 to 18
        [显示]=[显示]&[棋局](i,j)
        next
        [显示]=[显示]&vbcrlf
        next
        [显示]=[显示]&"输入棋子坐标 X,Y ,例如:"&vbcrlf&"2行 D列,输入D2 "&vbcrlf&"若要退出,请按 取消 "&vbcrlf
        end sub
        sub [下黑棋]
        g=len(black)
        b=mid(black,1,1)
        select case b
        case "A"
        b=1
        case "B"
        b=2
        case "C"
        b=3
        case "D"
        b=4
        case "E"
        b=5
        case "F"
        b=6
        case "G"
        b=7
        case "H"
        b=8
        case "I"
        b=9
        case "J"
        b=10
        case "K"
        b=11
        case "L"
        b=12
        case "M"
        b=13
        case "N"
        b=14
        case "O"
        b=15
        case "P"
        b=16
        case "Q"
        b=17
        case "R"
        b=18
        end select
        if g=2 then c=int(mid(black,2,1))
        if g=3 then c=int(mid(black,2,2))
        if [棋局](c,b)="┼" or [棋局](c,b)="┏" or [棋局](c,b)="┛" or [棋局](b,c)="┓" or [棋局](c,b)="┗" or [棋局](c,b)="┯" or [棋局](b,c)="┷" or [棋局](c,b)="┠" or [棋局](c,b)="┨" then [棋局](c,b)="●"
        if ([棋局](b,c)="●" and [棋局](b+1,c)="●" and [棋局](b+2,c)="●" and [棋局](b+3,c)="●"and [棋局](b+4,c)="●") or ([棋局](b,c)="●" and [棋局](b-1,c)="●" and [棋局](b-2,c)="●" and [棋局](b-3,c)="●"and [棋局](b-4,c)="●") or ([棋局](b,c)="●" and [棋局](b,c+1)="●" and [棋局](b,c+2)="●" and [棋局](b,c+3)="●"and [棋局](b,c+4)="●") or ([棋局](b,c)="●" and [棋局](b,c-1)="●" and [棋局](b,c-2)="●" and [棋局](b,c-3)="●"and [棋局](b,c-4)="●") then [显示画面]:m=msgbox([显示]&vbcrlf&"是否再来一局?",vbyesno,"黑胜!"):[棋盘]:f=0
        if ([棋局](b,c)="●" and [棋局](b+1,c-1)="●" and [棋局](b+2,c-2)="●" and [棋局](b+3,c-3)="●"and [棋局](b+4,c-4)="●") or ([棋局](b,c)="●" and [棋局](b-1,c+1)="●" and [棋局](b-2,c+2)="●" and [棋局](b-3,c+3)="●"and [棋局](b-4,c+4)="●") or ([棋局](b,c)="●" and [棋局](b+1,c+1)="●" and [棋局](b+2,c+2)="●" and [棋局](b+3,c+3)="●"and [棋局](b+4,c+4)="●") or ([棋局](b,c)="●" and [棋局](b-1,c-1)="●" and [棋局](b-2,c-2)="●" and [棋局](b-3,c-3)="●"and [棋局](b-4,c-4)="●") then [显示画面]:m=msgbox([显示]&vbcrlf&"是否再来一局?",vbyesno,"黑胜!"):[棋盘]:f=0
        end sub
        sub [下白棋]
        h=len(white)
        d=mid(white,1,1)
        select case d
        case "A"
        d=1
        case "B"
        d=2
        case "C"
        d=3
        case "D"
        d=4
        case "E"
        d=5
        case "F"
        d=6
        case "G"
        d=7
        case "H"
        d=8
        case "I"
        d=9
        case "J"
        d=10
        case "K"
        d=11
        case "L"
        d=12
        case "M"
        d=13
        case "N"
        d=14
        case "O"
        d=15
        case "P"
        d=16
        case "Q"
        d=17
        case "R"
        d=18
        end select
        if h=2 then e=int(mid(white,2,1))
        if h=3 then e=int(mid(white,2,2))
        if [棋局](e,d)="┼" or [棋局](e,d)="┏" or [棋局](e,d)="┛" or [棋局](e,d)="┓" or [棋局](e,d)="┗" or [棋局](e,d)="┯" or [棋局](e,d)="┷" or [棋局](e,d)="┠" or [棋局](e,d)="┨" then [棋局](e,d)="○"
        if ([棋局](d,e)="○" and [棋局](d+1,e-1)="○" and [棋局](d+2,e-2)="○" and [棋局](d+3,e-3)="○"and [棋局](d+4,e-4)="○") or ([棋局](d,e)="○" and [棋局](d-1,e+1)="○" and [棋局](d-2,e+2)="○" and [棋局](d-3,e+3)="○"and [棋局](d-4,e+4)="○") or ([棋局](d,e)="○" and [棋局](d+1,e+1)="○" and [棋局](d+2,e+2)="○" and [棋局](d+3,e+3)="○"and [棋局](d+4,e+4)="○") or ([棋局](d,e)="○" and [棋局](d-1,e-1)="○" and [棋局](d-2,e-2)="○" and [棋局](d-3,e-3)="○"and [棋局](d-4,e-4)="○") then [显示画面]:m=msgbox([显示]&vbcrlf&"是否再来一局?",vbyesno,"白胜!"):[棋盘]:f=0
        if ([棋局](d,e)="○" and [棋局](d,e+1)="○" and [棋局](d,e+2)="○" and [棋局](d,e+3)="○"and [棋局](d,e+4)="○") or ([棋局](d,e)="○" and [棋局](d,e-1)="○" and [棋局](d,e-2)="○" and [棋局](d,e-3)="○"and [棋局](d,e-4)="○") or ([棋局](d,e)="○" and [棋局](d+1,e)="○" and [棋局](d+2,e)="○" and [棋局](d+3,e)="○"and [棋局](d+4,e)="○") or ([棋局](d,e)="○" and [棋局](d-1,e)="○" and [棋局](d-2,e)="○" and [棋局](d-3,e)="○"and [棋局](d-4,e)="○") then [显示画面]:m=msgbox([显示]&vbcrlf&"是否再来一局?",vbyesno,"白胜!"):[棋局]:f=0
        end sub
        sub [棋盘]
        for i=0 to 18
        for j=0 to 18
        [棋局](1,1)="┏":[棋局](18,18)="┛":[棋局](1,18)="┓":[棋局](18,1)="┗":[棋局](0,0)=" "
        if i+1<=9 then [棋局](i+1,0)=" "&i+1
        if i+1>=10 and i+1<=18 then [棋局](i+1,0)=i+1
        select case j
        case 0
        x="A"
        case 1
        x="B"
        case 2
        x="C"
        case 3
        x="D"
        case 4
        x="E"
        case 5
        x="F"
        case 6
        x="G"
        case 7
        x="H"
        case 8
        x="I"
        case 9
        x="J"
        case 10
        x="K"
        case 11
        x="L"
        case 12
        x="M"
        case 13
        x="N"
        case 14
        x="O"
        case 15
        x="P"
        case 16
        x="Q"
        case 17
        x="R"
        end select
        if j+1<=18 then [棋局](0,j+1)=" "&x
        if i+1<=17 and j+1<=17 then [棋局](1,j+1)="┯":[棋局](18,j+1)="┷":[棋局](i+1,1)="┠":[棋局](i+1,18)="┨":[棋局](i+1,j+1)="┼"
        next:next
        end sub


        4楼2014-01-30 17:58
        回复
          记得有if语句的改成一行


          5楼2014-01-30 17:59
          回复
            还有一点……
            仍然无法判定输赢……


            6楼2014-01-30 18:00
            回复
              @幻影流年总是愁


              7楼2014-01-30 19:37
              回复