著法生成就是要產生所有有效的著法
view plaincopy to clipboardprint?
<PRE class=java name=
* Generates all valid motions
* @return all valid motion list
* returns <code>null</code>
* @see cn
*/
@SuppressWarnings(
final public List<Motion> generatePossibleMoves() {
List<Motion> ret = new ArrayList<Motion>();
for (int x =
for (int y =
int chessman = chessboard[x][y];
if (chessman !=
if (!isRedGo && isRed(chessman)) {
continue;
}
if (isRedGo && !isRed(chessman)) {
continue;
}
switch (chessman) {
case
//<editor
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
for (int oppJiangY =
if (isValidMove(x
ret
}
}
//</editor
break;
case
//<editor
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
for (int oppJiangY =
if (isValidMove(x
ret
}
}
//</editor
break;
case
case
//<editor
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
//</editor
break;
case
case
//<editor
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
//</editor
break;
case
case
//<editor
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
//</editor
break;
case
case
//<editor
// up
for (int i = y +
if (isValidMove(x
ret
} else {
// one chessman block its ways
break;
}
}
// down
for (int i = y
if (isValidMove(x
ret
} else {
// one chessman block its ways
break;
}
}
// left
for (int j = x
if (isValidMove(x
ret
} else {
// one chessman block its ways
break;
}
}
// right
for (int j = x +
if (isValidMove(x
ret
} else {
// one chessman block its ways
break;
}
}
//</editor
break;
case
case
//<editor
// up
for (int i = y +
if (isValidMove(x
ret
}
}
// down
for (int i = y
if (isValidMove(x
ret
}
}
// left
for (int j = x
if (isValidMove(x
ret
}
}
// right
for (int j = x +
if (isValidMove(x
ret
}
}
//</editor
break;
case
case
//<editor
if (isRed(chessman)) {
if (isValidMove(x
// I can see one point at my front
ret
}
if (y >=
// passed the
// my left and right
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
}
} else {
if (isValidMove(x
// I can see one point at my front
ret
}
if (y <=
// passed the
// my left and right
if (isValidMove(x
ret
}
if (isValidMove(x
ret
}
}
}
//</editor
break;
}
}
}
}
// alpha
Collections
return ret
}
</PRE>
轉載請保留作者信息
作者
Blog
MSN & Gmail & QQ
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25876.html