アットウィキロゴ

qwww888

var koma,pos,ban,hand,mode;
var koma_sel=new Array();
var number_sel; 
var dir=new Array();
var number_dir;
 
var pos_d=new Array();
 
function sample(){
 
koma=["王","歩","歩","王","歩","歩"];
pos=[2,1,3,8,7,9]
ban=[[0,0],[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]];
hand=["先手","先手","先手","後手","後手","後手"];
mode="先手";
 
var de=new Array();
var sig=new Array();
 
number_d=0;
 
select();
for(tr=1;tr<number_sel+1;tr++){
p1=koma_sel[tr];
make_dir(hand[p1],koma[p1]);
for(t=1;t<number_dir+1;t++){
m=pos[p1];
y1=ban[m][0]+dir[t][0];
x1=ban[m][1]+dir[t][1];
p2=point(y1,x1);
if(p2>0)number_d=number_d+1;
if(p2>0)de[number_d]=p1;
if(p2>0)sig[number_d]=p2;
}
}
 
var posx=new Array();
var number_posx; 
 
number_posx=0;
 
for(tr=1;tr<number_d+1;tr++){ 
 
for(s=0;s<6;s++){
pos_d[s]=pos[s];    
}
sx=de[tr];
pos_d[sx]=sig[tr];
 
ch=check();
if(ch<50){
number_posx=number_posx+1;
posx[number_posx]=new Array(); 
for (mx=0;mx<6;mx++){
posx[number_posx][mx]=pos_d[mx];    
}
}
 
nn=Math.random(number_posx);
num=Math.floor(nn)+1
alert(num);
 
 
 
 
 
 
 
 
 
 
 
}
 
 
alert(number_posx);
 
paint();
 
 
}
 
function change(){
    var sp,sx;
 
    var c=new Array();    
    for (sp=1;sp<10;sp++){
    c[sp]=0;    
    }
 
    for(sp=0;sp<6;sp++){
    sx=pos_ch[sp];
    if(sx>0)c[sx]=c[sx]+1;   
    }
 
 
 
    ch=0;
    for(sp=1;sp<10;sp++){
    h=0;
    sx=pos_ch[sp];
    if(c[sx]>1)h=100;    
    if(hand_ch[sp]==mode)h=0;
    if(sx<1)h=0;
    if(h>40)hand_ch[sp]=mode;
    if(h>40)pos_ch[sp]=0;
    }
 
    return ch;
    }
 
function check(){
 
var sp,sx;
 
var c=new Array();    
for (sp=1;sp<10;sp++){
c[sp]=0;    
}
 
for(sp=0;sp<6;sp++){
sx=0;
if(hand[sp]==mode)sx=pos_d[sp];
if(sx>0)c[sx]=c[sx]+1;   
}
 
 
 
ch=0;
for(sp=1;sp<10;sp++){
if(c[sp]>1)ch=100;    
}
 
return ch;
}
 
function point(y1,x1){
 
qs=-1;
for(q=1;q<10;q++){
h=0;
if(y1==ban[q][0])h=h+1;
if(x1==ban[q][1])h=h+1;
if(h==2)qs=q;    
}
 
return qs;
}
 
 
function make_dir(h1,k1){
 
if (k1=="王"){ 
        dir[1]=[1,1];
        dir[2]=[1,0];
        dir[3]=[1,-1];
        dir[4]=[0,1];
        dir[5]=[0,-1];
        dir[6]=[-1,1];
        dir[7]=[-1,0];
        dir[8]=[-1,-1];
        number_dir=8;
        }
 
        h=0
        if (k1=="歩")h=h+1;
        if (h1=="先手")h=h+1;
        if (h==2){
        dir[1]=[1,0];
        number_dir=1;    
        }     
 
        h=0
        if (k1=="歩")h=h+1;
        if (h1=="後手")h=h+1;
        if (h==2){
            dir[1]=[-1,0];
            number_dir=1;
        }
}
 
 
function select(){
 
sx=0;
for(s=0;s<6;s++){
h=0;
if(hand[s]==mode)h=h+1;
if(pos[s]>0)h=h+1;
if(h==2)sx=sx+1;
if(h==2)koma_sel[sx]=s;
}
 
number_sel=sx;
 
 
}
 
 
 
function paint(){
 
    sh=new Array();
 
    for(s=1;s<4;s++){
    sh[s]=new Array();    
    }
 
    for(s=1;s<4;s++){
    for(sx=1;sx<4;sx++){
    sh[s][sx]="";
    }   
    }
 
 
    for(s=0;s<6;s++){
    sx=pos[s];
    x1=ban[sx][1];
    y1=ban[sx][0];
    if(sx>0)sh[y1][x1]=koma[s];    
    }
 
 
       str="<table>";
       for(s=1;s<4;s++){
       str=str+"<tr>";
       for(sx=1;sx<4;sx++){
       str=str+"<td>"+sh[4-s][sx]+"</td>";
       }    
       str=str+"</tr>";
       }
 
       str=str+"</table>"
 
   $("#memo").html(str);
 
 
}
最終更新:2018年01月15日 11:50