?? chess.java
字號(hào):
//棋子的基本狀況
import java.awt.*;
public class Chess{
protected int point[][];
protected boolean tableplayer1[][][];//記錄雙方的棋子[x][y]坐標(biāo)及所屬
protected boolean tableplayer2[][][];//的五連子情況
public Chess(){
point=new int[15][15];
tableplayer1=new boolean[15][15][572];//所有的五連子情況為15*11+15*11+
tableplayer2=new boolean[15][15][572];//11*11+11*11=572
init();
}
private void init(){
int i,j,k,count=0;
for(i=0;i<15;i++)
for( j=0;j<15;j++)
point[i][j]=2; //把棋盤(pán)所有位置都置為空
for(i=0;i<15;i++)
for(j=0;j<11;j++)
{//橫連所有可能的五子情況
for(k=0;k<5;k++)
{
tableplayer1[i][j+k][count]=true;
tableplayer2[i][j+k][count]=true;
}
count++;
}
for(i=0;i<11;i++)
for(j=0;j<15;j++)
{//豎連所有可能的五子情況
for(k=0;k<5;k++)
{
tableplayer1[i+k][j][count]=true;
tableplayer2[i+k][j][count]=true;
}
count++;
}
for(i=0;i<11;i++)
for(j=0;j<11;j++)
{
//左上至右下所有斜連五子情況
for(k=0;k<5;k++)
{
tableplayer1[i+k][j+k][count]=true;
tableplayer2[i+k][j+k][count]=true;
}
count++;
}
for(i=0;i<11;i++)
for(j=14;j>=4;j--)
{
//右上至左下所有斜連五子情況
for(k=0;k<5;k++)
{
tableplayer1[i+k][j-k][count]=true;
tableplayer2[i+k][j-k][count]=true;
}
count++;
}
}
//下棋后修改棋子改點(diǎn)的狀態(tài),state=0表示白棋,state=1表示黑棋
public void modify(int x,int y,int state){
point[x][y]=state;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -