帮忙注释下面代码,谢谢
public long LeftBiasPowerValue(Color[][] allChesses,int row,int col,Color color){
NullAndCount colUp=LeftBiasUpPowerValue(allChesses, row, col, color);
NullAndCount colDown=LeftBiasDownPowerValue(allChesses, row, col, color);
long powerValue;
switch(colUp.getChessCount()+colDown.getChessCount()+1){
case 1:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=1;
}
else {
powerValue=5;
}
break;
case 2:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=21;
}
else {
powerValue=85;
}
break;
case 3:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=341;
}
else {
powerValue=1365;
}
break;
case 4:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=5461;
}
else {
powerValue=21845;
}
break;
default:
powerValue=87381;
break;
}
return powerValue;
}
public NullAndCount LeftBiasDownPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
int i=row;
int j=col;
while(i<allChesses.length-1&&j>0){
if(allChesses[i+1][j-1]==color){
count++;
i=i+1;
j=j-1;
}
else {
if(allChesses[i+1][j-1]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public NullAndCount LeftBiasUpPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
int i=row;
int j=col;
while(i>0&&j<allChesses.length-1){
if(allChesses[i-1][j+1]==color){
count++;
i=i-1;
j=j+1;
}
else {
if(allChesses[i-1][j+1]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public long RightBiasPowerValue(Color[][] allChesses,int row,int col,Color color){
NullAndCount colUp=RightBiasUpPowerValue(allChesses, row, col, color);
NullAndCount colDown=RightBiasDownPowerValue(allChesses, row, col, color);
long powerValue;
switch(colUp.getChessCount()+colDown.getChessCount()+1){
case 1:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=1;
}
else {
powerValue=5;
}
break;
case 2:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=21;
}
else {
powerValue=85;
}
break;
case 3:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=341;
}
else {
powerValue=1365;
}
break;
case 4:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=5461;
}
else {
powerValue=21845;
}
break;
default:
powerValue=87381;
break;
}
return powerValue;
}
public NullAndCount RightBiasDownPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
int i=row;
int j=col;
while(i<allChesses.length-1&&j<allChesses.length-1){
if(allChesses[i+1][j+1]==color){
count++;
i=i+1;
j=j+1;
}
else {
if(allChesses[i+1][j+1]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public NullAndCount RightBiasUpPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
int i=row;
int j=col;
while(i>0&&j>0){
if(allChesses[i-1][j-1]==color){
count++;
i=i-1;
j=j-1;
}
else {
if(allChesses[i-1][j-1]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public long ColPowerValue(Color[][] allChesses,int row,int col,Color color){
NullAndCount colUp=ColUpPowerValue(allChesses, row, col, color);
NullAndCount colDown=ColDownPowerValue(allChesses, row, col, color);
long powerValue;
switch(colUp.getChessCount()+colDown.getChessCount()+1){
case 1:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=1;
}
else {
powerValue=5;
}
break;
case 2:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=21;
}
else {
powerValue=85;
}
break;
case 3:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=341;
}
else {
powerValue=1365;
}
break;
case 4:
if(colUp.getNullCount()==0&&colDown.getNullCount()==0){
powerValue=0;
}
else if((colUp.getNullCount()==1&&colDown.getNullCount()==0)||(colUp.getNullCount()==0&&colDown.getNullCount()==1)){
powerValue=5461;
}
else {
powerValue=21845;
}
break;
default:
powerValue=87381;
break;
}
return powerValue;
}
public NullAndCount ColDownPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
for(int i=row;i<allChesses.length-1;i++){
if(allChesses[i+1][col]==color){
count++;
}
else{
if(allChesses[i+1][col]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public NullAndCount ColUpPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
for(int i=row;i>0;i--){
if(allChesses[i-1][col]==color){
count++;
}
else{
if(allChesses[i-1][col]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public long RowPowerValue(Color[][] allChesses,int row,int col,Color color){
NullAndCount rightRow=RightRowPowerValue(allChesses, row, col, color);
NullAndCount leftRow=LeftRowPowerValue(allChesses, row, col, color);
long powerValue;
switch(rightRow.getChessCount()+leftRow.getChessCount()+1){
case 1:
if(rightRow.getNullCount()==0&&leftRow.getNullCount()==0){
powerValue=0;
}
else if((rightRow.getNullCount()==1&&leftRow.getNullCount()==0)||(rightRow.getNullCount()==0&&leftRow.getNullCount()==1)){
powerValue=1;
}
else {
powerValue=5;
}
break;
case 2:
if(rightRow.getNullCount()==0&&leftRow.getNullCount()==0){
powerValue=0;
}
else if((rightRow.getNullCount()==1&&leftRow.getNullCount()==0)||(rightRow.getNullCount()==0&&leftRow.getNullCount()==1)){
powerValue=21;
}
else {
powerValue=85;
}
break;
case 3:
if(rightRow.getNullCount()==0&&leftRow.getNullCount()==0){
powerValue=0;
}
else if((rightRow.getNullCount()==1&&leftRow.getNullCount()==0)||(rightRow.getNullCount()==0&&leftRow.getNullCount()==1)){
powerValue=341;
}
else {
powerValue=1365;
}
break;
case 4:
if(rightRow.getNullCount()==0&&leftRow.getNullCount()==0){
powerValue=0;
}
else if((rightRow.getNullCount()==1&&leftRow.getNullCount()==0)||(rightRow.getNullCount()==0&&leftRow.getNullCount()==1)){
powerValue=5461;
}
else {
powerValue=21845;
}
break;
default:
powerValue=87381;
break;
}
return powerValue;
}
public NullAndCount LeftRowPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
for(int i=col;i>0;i--){
if(allChesses[row][i-1]==color){
count++;
}
else{
if(allChesses[row][i-1]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
public NullAndCount RightRowPowerValue(Color[][] allChesses,int row,int col,Color color){
int count=0;
NullAndCount nullAndCount=new NullAndCount();
for(int i=col;i<allChesses.length-1;i++){
if(allChesses[row][i+1]==color){
count++;
}
else{
if(allChesses[row][i+1]==null){
nullAndCount.setNullCount(1);
}
break;
}
}
nullAndCount.setChessCount(count);
return nullAndCount;
}
}