• 大小: 15.1 KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-09-28
  • 语言: 其他
  • 标签: 五子棋  

资源简介

可实现悔棋功能,java语言编写,界面简单,适合初学者学习

资源截图

代码片段和文件信息

public class AutoPlay{
     int xy;
     void autoPlay(int chesspad[][]int aint b){
          int randomNumber=(int)(Math.random()*8)+1;
          switch(randomNumber){
             case(1):
                  if(chesspad[a-1][b-1]==0)
                  {x=a-1;y=b-1;}
                  else if(chesspad[a-2][b-2]==0)
                  {x=a-2;y=b-2;}
                  else {x=a-3;y=b-3;}   
                  break;
                   
             case(2):
                  if(chesspad[a-1][b]==0)
                  {x=a-1;y=b;}
                  else if(chesspad[a-2][b]==0)
                  {x=a-2;y=b;}
                  else {x=a-3;y=b;}
                  break;
     case(3):
                  if(chesspad[a-1][b+1]==0)
                  {x=a-1;y=b+1;}
                  else if(chesspad[a-2][b+2]==0)
                  {x=a-2;y=b+2;}
                  else {x=a-3;y=b+3;}
                  break;
             case(4):
                  if(chesspad[a][b+1]==0)
                  {x=a;y=b+1;}
                  else if(chesspad[a][b+2]==0)
                  {x=a;y=b+2;}
                  else {x=a;y=b+3;}
                  break;
             case(5):
                   if(chesspad[a+1][b+1]==0)
                   {x=a+1;y=b+1;}
                   else if(chesspad[a+2][b+2]==0)
                   {x=a+2;y=b+2;} 
                   else {x=a+3;y=b+3;}
                   break;
             case(6):
                   if(chesspad[a+1][b]==0)
                   {x=a+1;y=b;}
                   else  if(chesspad[a+2][b]==0)
                   {x=a+2;y=b;}
                   else {x=a+3;y=b;}
                   break;
             case(7):
                    if(chesspad[a+1][b-1]==0)
                    {x=a+1;y=b-1;}
                    else if(chesspad[a+2][b-2]==0)
                    {x=a+2;y=b-2;}
                    else {x=a+3;y=b-3;}
                    break;
             case(8):
                     if(chesspad[a][b-1]==0)
                     {x=a;y=b-1;}
                     else if(chesspad[a][b-2]==0)
                     {x=a;y=b-2;}
                     else{x=a;y=b+3;}
                     break; 
            }
      }

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        380  2009-05-28 11:21  five\.project

     文件      12433  2009-05-30 18:16  five\src\Chess.java

     文件       2232  2009-05-28 11:24  five\src\AutoPlay.java

     文件       1821  2009-05-28 11:24  five\src\Judge.java

     文件        560  2009-05-28 11:25  five\src\Sort.java

     文件       2476  2009-05-28 11:25  five\src\Scan.java

     文件       2789  2009-05-28 11:25  five\src\Evaluate.java

     文件       1382  2009-05-28 11:24  five\bin\AutoPlay.class

     文件       1194  2009-05-28 11:24  five\bin\Judge.class

     文件        654  2009-05-28 11:25  five\bin\Sort.class

     文件       1133  2009-05-28 11:25  five\bin\Scan.class

     文件       1207  2009-05-28 11:25  five\bin\Evaluate.class

     文件       7690  2009-05-30 18:16  five\bin\ChessPad.class

     文件        587  2009-05-30 18:16  five\bin\Chess$1.class

     文件       1283  2009-05-30 18:16  five\bin\ChessPoint_black.class

     文件       1174  2009-05-30 18:16  five\bin\Chess.class

     文件       1279  2009-05-30 18:16  five\bin\ChessPoint_white.class

     文件        232  2009-05-28 11:21  five\.classpath

     目录          0  2009-05-28 11:21  five\src

     目录          0  2009-05-28 11:21  five\bin

     目录          0  2009-05-28 11:21  five

----------- ---------  ---------- -----  ----

                40506                    21


评论

共有 条评论