📄 telent.java
字号:
a[1][0] = 8;
a[1][1] = 3;
}
if(y == 8)
{
a = new int[3][2];
a[0][0] = 7;
a[0][1] = 3;
a[1][0] = 8;
a[1][1] = 4;
a[2][0] = 9;
a[2][1] = 3;
}
if(y == 9)
{
a = new int[2][2];
a[0][0] = 8;
a[0][1] = 3;
a[1][0] = 9;
a[1][1] = 4;
}
}
if(x == 4)
{
if(y == 7)
{
a = new int[3][2];
a[0][0] = 7;
a[0][1] = 5;
a[1][0] = 8;
a[1][1] = 4;
a[2][0] = 7;
a[2][1] = 3;
}
if(y == 8)
{
a = new int[4][2];
a[0][0] = 8;
a[0][1] = 3;
a[1][0] = 7;
a[1][1] = 4;
a[2][0] = 8;
a[2][1] = 5;
a[3][0] = 9;
a[3][1] = 4;
}
if(y == 9)
{
a = new int[3][2];
a[0][0] = 9;
a[0][1] = 5;
a[1][0] = 8;
a[1][1] = 4;
a[2][0] = 9;
a[2][1] = 3;
}
}
if(x == 5)
{
if(y == 7)
{
a = new int[2][2];
a[0][0] = 8;
a[0][1] = 5;
a[1][0] = 7;
a[1][1] = 4;
}
if(y == 8)
{
a = new int[3][2];
a[0][0] = 7;
a[0][1] = 5;
a[1][0] = 8;
a[1][1] = 4;
a[2][0] = 9;
a[2][1] = 5;
}
if(y == 9)
{
a = new int[2][2];
a[0][0] = 8;
a[0][1] = 5;
a[1][0] = 9;
a[1][1] = 4;
}
}
}
else
{
if(x == 5)
{
if(y == 2)
{
a = new int[2][2];
a[0][0] = 2;
a[0][1] = 4;
a[1][0] = 1;
a[1][1] = 5;
}
if(y == 1)
{
a = new int[3][2];
a[0][0] = 2;
a[0][1] = 5;
a[1][0] = 1;
a[1][1] = 4;
a[2][0] = 0;
a[2][1] = 5;
}
if(y == 0)
{
a = new int[2][2];
a[0][0] = 1;
a[0][1] = 5;
a[1][0] = 0;
a[1][1] = 4;
}
}
if(x == 4)
{
if(y == 2)
{
a = new int[3][2];
a[0][0] = 2;
a[0][1] = 3;
a[1][0] = 1;
a[1][1] = 4;
a[2][0] = 2;
a[2][1] = 5;
}
if(y == 1)
{
a = new int[4][2];
a[0][0] = 1;
a[0][1] = 5;
a[1][0] = 2;
a[1][1] = 4;
a[2][0] = 1;
a[2][1] = 3;
a[3][0] = 0;
a[3][1] = 4;
}
if(y == 0)
{
a = new int[3][2];
a[0][0] = 0;
a[0][1] = 3;
a[1][0] = 1;
a[1][1] = 4;
a[2][0] = 0;
a[2][1] = 5;
}
}
if(x == 3)
{
if(y == 2)
{
a = new int[2][2];
a[0][0] = 1;
a[0][1] = 3;
a[1][0] = 2;
a[1][1] = 4;
}
if(y == 1)
{
a = new int[3][2];
a[0][0] = 2;
a[0][1] = 3;
a[1][0] = 1;
a[1][1] = 4;
a[2][0] = 0;
a[2][1] = 3;
}
if(y == 0)
{
a = new int[2][2];
a[0][0] = 1;
a[0][1] = 3;
a[1][0] = 0;
a[1][1] = 4;
}
}
}
//System.out.println("去掉将走步集合中的无效元素");
//去掉有自己棋子的和老将照面的
for(int i = 0; i < a.length; i++)
{
//System.out.println("进入循环");
int c = a[i][0];
int d = a[i][1];
//System.out.println("1");
int temp = chess[c][d];
//System.out.println("变量初始化完毕");
if(code < 16 && temp < 16 || code > 15 && temp > 15)
{//有自己的棋子
n++;
a[i][0] = -1;
continue;
}
//老将照面判断
boolean isSee = true;
//取得对方老将的Y坐标
int otherLocation = 0;
if(code < 16)
{//老将照面检测
otherLocation = LDS[16][1];
if(otherLocation != d)
isSee = false;
else
{
for(int j = c + 1; j < LDS[16][0]; j++)
{
if(chess[j][d] != 32)
{//只要有一颗棋子,则不能照面
isSee = false;
break;
}
}
}
}
else
{//老将照面检测
otherLocation = LDS[0][1];
if(otherLocation != d)
isSee = false;
else
{
for(int j = LDS[0][0] + 1; j < c; j++)
{
if(chess[j][d] != 32)
{//只要有一颗棋子,则不能照面
isSee = false;
break;
}
}
}
}
//System.out.println("isSee的值是:"+isSee);
if(isSee)
{//老将照面了
n++;
a[i][0] = -1;
}
//System.out.println("去掉将走步集合中的无效元素循环一次完毕");
}
//System.out.println("获取将走步集合,最后tempCollection构造数组");
int tempLength = a.length - n;
tempCollection = new int[tempLength][2];
n = 0;
for(int i = 0 ; i < a.length ; i++)
{
if(a[i][0] != -1)
{
tempCollection[n][0] = a[i][0];
tempCollection[n][1] = a[i][1];
n++;
}
}
//System.out.println("获取将走步集合完毕");
}
//士的走步集合
if(code == 30 || code == 31 || code == 15 || code == 14)
{
//System.out.println("开始获取士走步集合传入的代号为y:"+y+",x:"+x);
int[][] a = null;
int n = 0;
if(code > 15)
{
if(x == 4 && y == 8)
{
a = new int[4][2];
a[0][0] = 7;
a[0][1] = 3;
a[1][0] = 9;
a[1][1] = 3;
a[2][0] = 7;
a[2][1] = 5;
a[3][0] = 9;
a[3][1] = 5;
}
else
{
a = new int[1][2];
a[0][0] = 8;
a[0][1] = 4;
}
}
else
{
if(x == 4 && y == 1)
{
a = new int[4][2];
a[0][0] = 2;
a[0][1] = 5;
a[1][0] = 0;
a[1][1] = 5;
a[2][0] = 2;
a[2][1] = 3;
a[3][0] = 0;
a[3][1] = 3;
}
else
{
a = new int[1][2];
a[0][0] = 1;
a[0][1] = 4;
}
}
//去掉落脚点有自己棋子的
for(int i = 0 ; i < a.length ; i++)
{
int c = a[i][0];
int d = a[i][1];
int temp = chess[c][d];
if(code < 16 && temp < 16 || code > 15 && temp > 15)
{//有红方自己的棋子
n++;
a[i][0] = -1;
}
}
int tempLength = a.length - n;
tempCollection = new int[tempLength][2];
n = 0;
for(int i = 0 ; i < a.length ; i++)
{
if(a[i][0] != -1)
{
tempCollection[n][0] = a[i][0];
tempCollection[n][1] = a[i][1];
n++;
}
}
//System.out.println("获取士走步集合完毕");
}
//相的走步集合
if(code == 28 || code == 29 || code == 13 || code == 12)
{
//System.out.println("开始获取象走步集合");
int[][] a = null;
int n = 0;
if(code > 15)
{
if(y == 5)
{
if(x == 2)
{
a = new int[2][2];
a[0][0] = 7;
a[0][1] = 0;
a[1][0] = 7;
a[1][1] = 4;
if(chess[6][1] != 32)
{
a[0][0] = -1;
n++;
}
if(chess[6][3] != 32)
{
a[1][0] = -1;
n++;
}
}
if(x == 6)
{
a = new int[2][2];
a[0][0] = 7;
a[0][1] = 8;
a[1][0] = 7;
a[1][1] = 4;
if(chess[6][5] != 32)
{
a[1][0] = -1;
n++;
}
if(chess[6][7] != 32)
{
a[0][0] = -1;
n++;
}
}
}
if(y == 7)
{
if(x == 4)
{
a = new int[4][2];
a[0][0] = 5;
a[0][1] = 2;
a[1][0] = 9;
a[1][1] = 2;
a[2][0] = 5;
a[2][1] = 6;
a[3][0] = 9;
a[3][1] = 6;
if(chess[6][3] != 32)
{
a[0][0] = -1;
n++;
}
if(chess[6][5] != 32)
{
a[2][0] = -1;
n++;
}
if(chess[8][5] != 32)
{
a[3][0] = -1;
n++;
}
if(chess[8][3] != 32)
{
a[1][0] = -1;
n++;
}
}
if(x == 0)
{
a = new int[2][2];
a[0][0] = 5;
a[0][1] = 2;
a[1][0] = 9;
a[1][1] = 2;
if(chess[6][1] != 32)
{
a[0][0] = -1;
n++;
}
if(chess[8][1] != 32)
{
a[1][0] = -1;
n++;
}
}
if(x == 8)
{
a = new int[2][2];
a[0][0] = 5;
a[0][1] = 6;
a[1][0] = 9;
a[1][1] = 6;
if(chess[6][7] != 32)
{
a[0][0] = -1;
n++;
}
if(chess[8][7] != 32)
{
a[1][0] = -1;
n++;
}
}
}
if(y == 9)
{
if(x == 2)
{
a = new int[2][2];
a[0][0] = 7;
a[0][1] = 0;
a[1][0] = 7;
a[1][1] = 4;
if(chess[8][1] != 32)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -