帮忙注释下面代码,谢谢

fghjklasdfghj 2016-05-19 11:15:23
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;
}
}
...全文
345 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
guan2656 2016-06-02
  • 打赏
  • 举报
回复
路过 66666666666666666
qq_23118143 2016-05-23
  • 打赏
  • 举报
回复
6666666666666666666
进击的菜鸟丶 2016-05-23
  • 打赏
  • 举报
回复
这个帖子6666
WangSongYuan 2016-05-23
  • 打赏
  • 举报
回复
哈哈 这个帖子有意思
nikyotensai 2016-05-22
  • 打赏
  • 举报
回复
自己弄,这里交流技术,不做苦力
子夜静舞 2016-05-20
  • 打赏
  • 举报
回复
引用 6 楼 anselmoe 的回复:
选中那些代码 Ctrl+Shift+/ 就注释了~~
哈哈 你说的注释和他说的注释应该是两个意思
Ansel-枫儿-Moe 2016-05-20
  • 打赏
  • 举报
回复
选中那些代码 Ctrl+Shift+/ 就注释了~~
Intboy 2016-05-20
  • 打赏
  • 举报
回复
引用 2 楼 qnmdcsdn 的回复:
/** * * **/ 注释代码
看了标题我也这么想的
家里敷泥呀 2016-05-20
  • 打赏
  • 举报
回复
引用 2 楼 qnmdcsdn 的回复:
/** * * **/ 注释代码
你最机智
家里敷泥呀 2016-05-20
  • 打赏
  • 举报
回复
  • 打赏
  • 举报
回复
/** * * **/ 注释代码
foo1st 2016-05-20
  • 打赏
  • 举报
回复
考眼力吗这是
鬼狐柒 2016-05-20
  • 打赏
  • 举报
回复
/** 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; } } */
菜 头 2016-05-20
  • 打赏
  • 举报
回复
头晕。。。。
htc123htc 2016-05-20
  • 打赏
  • 举报
回复
我说的注释就是解析每行代码的意思

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧