!<その2> ! メインルーチン DO CALL sarch ! 着手可能点のサーチ IF sarev=0 THEN LET pass_auto=1 ! 無条件パス DRAW pass ! パス CALL sarch IF sarev=0 OR count=m*n THEN DRAW gameset ! 終局処理 END IF LET rev=0 ! 返せる石数 DO CALL click ! 左クリック CALL neighbor(x,y,c) ! 隣接する石をチェック LOOP UNTIL rev<>0 LET kif(hand,1)=c ! 第hand手目の色 LET kif(hand,2)=x ! 列(alphabet) LET kif(hand,3)=y ! 行(数字) LET maxhand=MAX(maxhand,hand) IF pass_auto=1 THEN CALL pass_off ! 無条件パスの解除 CALL scan DRAW counter IF c=b THEN LET c=w ELSE LET c=b DRAW turn(c) LOOP
! 以下、副プログラム SUB click ! 左クリック DO GET POINT : x,y LET event=1 IF x>=ex AND x<=ex+bw AND y>=ey AND y<=ey+bh THEN CALL edit ! 盤面編集モード ELSEIF pass_auto=0 AND x>=px AND x<=px+bw AND y>=py AND y<=py+bh THEN LET pass_on=1 DRAW pass ! パス ELSEIF hand>1 AND x>=ix-0.1 AND x<=ix+imw AND y>=by AND y<=by+bgh THEN CALL backstart ! 最初に戻る ELSEIF hand>1 AND kif(hand-1,2)<>0 AND x>=bx AND x<=bx+bgw AND y>=by AND y<=by+bgh THEN CALL back ! 一手戻る ELSEIF hand<=m*n-ic AND kif(hand,2)<>0 AND x>=gx AND x<=gx+bgw AND y>=by AND y<=by+bgh THEN CALL goes ! 一手進む ELSEIF maxhand<>count-ic AND x>=mx AND x<=mx+imw+0.1 AND y>=by AND y<=by+bgh THEN CALL goesmaxhand ! 最後に進む ELSEIF x>=sx AND x<=sx+bw AND y>=sy AND y<=sy+bh THEN CALL program_stop ! 終了 ELSE LET event=0 END IF IF event=1 AND gameset_on=1 THEN DRAW gameset_off ! 終局面からの復帰 IF event=1 AND pass_auto=1 THEN CALL pass_off ! 無条件パスの解除 LET x=INT(x) LET y=INT(y) LOOP UNTIL x>=1 AND x<=m AND y>=1 AND y<=n AND r(x,y)=board END SUB SUB sarch ! 着手可能点のサーチ LET sarch_on=1 ! サーチ中 LET sarev=0 FOR x=1 TO m FOR y=1 TO n IF r(x,y)=board THEN CALL neighbor(x,y,c) IF sarev=1 THEN LET sarch_on=0 EXIT SUB END IF NEXT y NEXT x LET sarch_on=0 END SUB SUB neighbor(x,y,col) ! 隣接する石をチェック FOR i=-1 TO 1 STEP 1 FOR j=-1 TO 1 STEP 1 IF r(x+i,y+j)<>col AND r(x+i,y+j)<>board THEN CALL revcheck(x,y,col,i,j) END IF IF sarch_on=1 AND sarev=1 THEN EXIT SUB NEXT j NEXT i END SUB !<その3>に続く
|