?? mmimproved.java
字號:
if(!closeMill(i,b,color)) {
char[] charArray = new char[23];
charArray = b.toCharArray();
charArray[i]='x';
String tempString = String.valueOf(charArray);
//System.out.println("Generate rem:adding "+tempString);
list.add(tempString);
count++;
}
}
}
if(count==0) {
list.add(b);
}
}
/**
* Checks to see if the addition of current piece closes a mill
* @param index
* @param b
* @param compChar
* @return
*/
public boolean closeMill(int index,String b,char compChar) {
boolean flag=false;
switch(index) {
case 0:
if((b.charAt(8)==compChar && b.charAt(20)==compChar)
||(b.charAt(1)==compChar&&b.charAt(2)==compChar)
||(b.charAt(3)==compChar&&b.charAt(6)==compChar)) {
flag=true;
}
break;
case 1:
if(b.charAt(0)==compChar&&b.charAt(2)==compChar)
{
flag=true;
break;
}
break;
case 2:
if((b.charAt(13)==compChar&&b.charAt(22)==compChar)
||(b.charAt(1)==compChar&&b.charAt(0)==compChar)
||(b.charAt(7)==compChar&&b.charAt(5)==compChar)) {
flag=true;
break;
}
break;
case 3:
if((b.charAt(0)==compChar&&b.charAt(6)==compChar)
||(b.charAt(9)==compChar&&b.charAt(17)==compChar)
||(b.charAt(4)==compChar&&b.charAt(5)==compChar)) {
flag=true;
break;
}
break;
case 4:
if((b.charAt(3)==compChar&&b.charAt(5)==compChar))
{
flag=true;
break;
}
break;
case 5:
if((b.charAt(3)==compChar&&b.charAt(4)==compChar)
||(b.charAt(19)==compChar&&b.charAt(12)==compChar)
||(b.charAt(7)==compChar&&b.charAt(2)==compChar)) {
flag=true;
break;
}
break;
case 6:
if((b.charAt(10)==compChar&&b.charAt(14)==compChar)
||(b.charAt(0)==compChar&&b.charAt(3)==compChar))
{
flag=true;
break;
}
break;
case 7:
if((b.charAt(5)==compChar&&b.charAt(2)==compChar)
||(b.charAt(11)==compChar&&b.charAt(16)==compChar))
{
flag=true;
break;
}
break;
case 8:
if((b.charAt(10)==compChar&&b.charAt(9)==compChar)
||(b.charAt(0)==compChar&&b.charAt(20)==compChar))
{
flag=true;
break;
}
break;
case 9:
if((b.charAt(8)==compChar&&b.charAt(10)==compChar)
{
flag=true;
break;
}
break;
case 10:
if((b.charAt(8)==compChar&&b.charAt(9)==compChar)
||(b.charAt(6)==compChar&&b.charAt(14)==compChar))
{
flag=true;
break;
}
break;
case 11:
if((b.charAt(12)==compChar&&b.charAt(13)==compChar)
||(b.charAt(16)==compChar&&b.charAt(7)==compChar))
{
flag=true;
break;
}
break;
case 12:
if((b.charAt(19)==compChar&&b.charAt(5)==compChar)
||(b.charAt(13)==compChar&&b.charAt(11)==compChar))
{
flag=true;
break;
}
break;
case 13:
if((b.charAt(22)==compChar&&b.charAt(2)==compChar)
||(b.charAt(12)==compChar&&b.charAt(11)==compChar))
{
flag=true;
break;
}
break;
case 14:
if((b.charAt(20)==compChar&&b.charAt(17)==compChar)
||(b.charAt(15)==compChar&&b.charAt(16)==compChar)
||(b.charAt(10)==compChar&&b.charAt(6)==compChar)) {
flag=true;
break;
}
break;
case 15:
if((b.charAt(18)==compChar&&b.charAt(21)==compChar)
||(b.charAt(14)==compChar&&b.charAt(16)==compChar))
{
flag=true;
break;
}
break;
case 16:
if((b.charAt(14)==compChar&&b.charAt(15)==compChar)
||(b.charAt(19)==compChar&&b.charAt(22)==compChar)
||(b.charAt(7)==compChar&&b.charAt(11)==compChar)) {
flag=true;
break;
}
break;
case 17:
if((b.charAt(20)==compChar&&b.charAt(14)==compChar)
||(b.charAt(18)==compChar&&b.charAt(19)==compChar)
||(b.charAt(3)==compChar&&b.charAt(9)==compChar)) {
flag=true;
break;
}
break;
case 18:
if((b.charAt(21)==compChar&&b.charAt(15)==compChar)
||(b.charAt(19)==compChar&&b.charAt(17)==compChar))
{
flag=true;
break;
}
break;
case 19:
if((b.charAt(12)==compChar&&b.charAt(5)==compChar)
||(b.charAt(16)==compChar&&b.charAt(22)==compChar)
||(b.charAt(17)==compChar&&b.charAt(18)==compChar)) {
flag=true;
break;
}
break;
case 20:
if((b.charAt(0)==compChar&&b.charAt(8)==compChar)
||(b.charAt(21)==compChar&&b.charAt(22)==compChar)
||(b.charAt(17)==compChar&&b.charAt(14)==compChar)) {
flag=true;
break;
}
break;
case 21:
if((b.charAt(18)==compChar&&b.charAt(15)==compChar)
||(b.charAt(20)==compChar&&b.charAt(22)==compChar))
{
flag=true;
break;
}
break;
case 22:
if((b.charAt(20)==compChar&&b.charAt(21)==compChar)
||(b.charAt(13)==compChar&&b.charAt(2)==compChar)
||(b.charAt(16)==compChar&&b.charAt(19)==compChar)) {
flag=true;
break;
}
break;
}
return flag;
}
/**
* Returns the list of neighbors of a node
* @param i
* @return list of neighbors
*/
public int[] getNeighbors(int i) {
switch(i) {
case 0:
int n0[]= {1,3,8,-1};
return (n0);
case 1:
int n1[]= {0,4,2,-1};
return (n1);
case 2:
int n2[]= {1,5,13,-1};
return (n2);
case 3:
int n3[]= {0,4,9,6};
return (n3);
case 4:
int n4[]= {3,5,1,-1};
return (n4);
case 5:
int n5[]= {7,4,2,12};
return (n5);
case 6:
int n6[]= {10,7,3,-1};
return (n6);
case 7:
int n7[]= {6,11,5,-1};
return (n7);
case 8:
int n8[]= {0,9,20,-1};
return (n8);
case 9:
int n9[]= {8,10,3,17};
return (n9);
case 10:
int n10[]= {9,6,14,-1};
return (n10);
case 11:
int n11[]= {16,7,12,-1};
return (n11);
case 12:
int n12[]= {11,13,5,19};
return (n12);
case 13:
int n13[]= {12,2,22,-1};
return (n13);
case 14:
int n14[]= {17,10,15,-1};
return (n14);
case 15:
int n15[]= {14,16,18,-1};
return (n15);
case 16:
int n16[]= {15,11,19,-1};
return (n16);
case 17:
int n17[]= {14,20,9,18};
return (n17);
case 18:
int n18[]= {17,19,15,21};
return (n18);
case 19:
int n19[]= {18,22,12,16};
return (n19);
case 20:
int n20[]= {8,21,17,-1};
return (n20);
case 21:
int n21[]= {20,18,22,-1};
return (n21);
case 22:
int n22[]= {19,13,21,-1};
return (n22);
}
int defaulta[]= {-1,-1,-1,-1};
return(defaulta);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -