好长时间没有碰java了,在网络上找到一个纯java写的单机版中国象棋,感兴趣的研究了一下,结果发现了几个错误:1。没有胜负结果的判定,老将死掉后还可以继续下棋;2。老将的活动范围没有仅限在田字格内。3。老将对脸问题没有解决。经过对源程序的一番手术,修正了以上的错误,现发布出来感兴趣的可以看一看,蛮有意思的。

主类

/**//*
Chess.java
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.LinkedList;
public class Chess extends JFrame implements ActionListener
...{
  ChessBoard board=null;
  Demon demon=null;
  MakeChessManual record=null;
  Container con=null;
  JMenuBar bar;
  JMenu fileMenu;
  JMenuItem 双人对弈,保存棋谱,演示棋谱;
  JFileChooser fileChooser=null;
  LinkedList 棋谱=null;
  public Chess()
   ...{ 
      bar=new JMenuBar();
      fileMenu=new JMenu("中国象棋");
      双人对弈=new JMenuItem("双人对弈");
      保存棋谱=new JMenuItem("保存棋谱");
      演示棋谱=new JMenuItem("演示棋谱");
      fileMenu.add(双人对弈);
      fileMenu.add(保存棋谱);
      fileMenu.add(演示棋谱);
      bar.add(fileMenu);
      setJMenuBar(bar);
      setTitle(双人对弈.getText());
      双人对弈.addActionListener(this);
      保存棋谱.addActionListener(this);
      演示棋谱.addActionListener(this);
      board=new ChessBoard(45,45,9,10);
      record=board.record;
      con=getContentPane();
      JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,board,record);
      split.setDividerSize(5);
      split.setDividerLocation(460);
      con.add(split,BorderLayout.CENTER); 
      addWindowListener(new WindowAdapter()
                 ...{ public void windowClosing(WindowEvent e)
                     ...{ System.exit(0);
                       }
                 });
      setVisible(true);
      setBounds(60,20,670,540);
      fileChooser=new JFileChooser();
      con.validate();
      validate();
   }
  public void actionPerformed(ActionEvent e)
   ...{ 
     if(e.getSource()==双人对弈) 
       ...{
         con.removeAll();
          保存棋谱.setEnabled(true);
         this.setTitle(双人对弈.getText());
         board=new ChessBoard(45,45,9,10);
         record=board.record;
         JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,board,record);
         split.setDividerSize(5);
         split.setDividerLocation(460);
         con.add(split,BorderLayout.CENTER); 
         validate();
       }   
     if(e.getSource()==保存棋谱) 
       ...{ 
         int state=fileChooser.showSaveDialog(null);
         File saveFile =fileChooser.getSelectedFile();
          if(saveFile!=null&&state==JFileChooser.APPROVE_OPTION)
               ...{try
                   ...{
                    FileOutputStream outOne=new FileOutputStream(saveFile);
                    ObjectOutputStream outTwo=new ObjectOutputStream(outOne);
                    outTwo.writeObject(record.获取棋谱()) ;
                    outOne.close();
                    outTwo.close();
                   }
                catch(IOException event)
                   ...{
                   } 
               }
       }
     if(e.getSource()==演示棋谱) 
       ...{         
           con.removeAll();
           con.repaint();
           con.validate(); 
           validate();
         保存棋谱.setEnabled(false);
         
         int state=fileChooser.showOpenDialog(null);
         File openFile =fileChooser.getSelectedFile();
          if(openFile!=null&&state==JFileChooser.APPROVE_OPTION)
               ...{try
                   ...{
                    FileInputStream inOne=new FileInputStream(openFile);
                    ObjectInputStream inTwo=new ObjectInputStream(inOne);
                    棋谱=(LinkedList)inTwo.readObject() ;
                    inOne.close();
                    inTwo.close();
                    ChessBoard board=new ChessBoard(45,45,9,10);
                    demon=new Demon(board);
                    demon.set棋谱(棋谱);
                    con.add(demon,BorderLayout.CENTER);
                    con.validate(); 
                    validate();
                    this.setTitle(演示棋谱.getText()+":"+openFile); 
                   }
                catch(Exception event)
                   ...{
                      JLabel label=new JLabel("不是棋谱文件");
                      label.setFont(new Font("隶书",Font.BOLD,60));
                      label.setForeground(Color.red); 
                      label.setHorizontalAlignment(SwingConstants.CENTER);
                      con.add(label,BorderLayout.CENTER);
                      con.validate(); 
                      this.setTitle("没有打开棋谱"); 
                      validate();
                   } 
               }
           else
              ...{
                JLabel label=new JLabel("没有打开棋谱文件呢");
                label.setFont(new Font("隶书",Font.BOLD,50));
                label.setForeground(Color.pink); 
                label.setHorizontalAlignment(SwingConstants.CENTER);
                con.add(label,BorderLayout.CENTER);
                con.validate(); 
                this.setTitle("没有打开棋谱文件呢"); 
                validate();  
              }
       }
   }
  public static void main(String args[])
   ...{
      new Chess();
   }
}

棋盘类

/**//*
ChessBoard.java
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ChessBoard extends JPanel implements MouseListener,MouseMotionListener
...{
   JPanel Message;
   public ChessPoint point[][];                                
   public int unitWidth,unitHeight;                            
   int x轴长,y轴长;                                            
   int x,y;                                                    
   boolean move=false;                                         
   public String     红方颜色="红色",黑方颜色="黑色";
   ChessPiece 红车1,红车2,红马1,红马2,红相1,红相2,红帅,红士1,红士2,
              红兵1,红兵2,红兵3,红兵4,红兵5,红炮1,红炮2;
   ChessPiece 黑车1,黑车2,黑马1,黑马2,黑将,黑士1,黑士2,
              黑卒1,黑卒2,黑卒3,黑卒4,黑卒5,黑象1,黑象2,黑炮1,黑炮2;
   
   int startX,startY;                                         
   int startI,startJ;                                         
   public boolean 红方走棋=true,黑方走棋=false;               
   Rule rule=null;                                            
   public  MakeChessManual record=null;                        
   public  ChessBoard(int w,int h,int r,int c)
   ...{
        setLayout(null);
        addMouseListener(this);
        addMouseMotionListener(this);
        Color bc=getBackground();
        unitWidth=w;
        unitHeight=h;
        x轴长=r;
        y轴长=c;
      
        point=new ChessPoint[r+1][c+1]; 
                                        
                                        
        for(int i=1;i<=r;i++)
          ...{
            for(int j=1;j<=c;j++)
              ...{
                point[i][j]=new ChessPoint(i*unitWidth,j*unitHeight,false); 
              }
          }

        rule=new Rule(this,point);
        record=new MakeChessManual(this,point) ;  
        
        红车1=new ChessPiece("车",Color.red,bc,w-4,h-4,this);
        红车1.set棋子类别(红方颜色);
        红车2=new ChessPiece("车",Color.red,bc,w-4,h-4,this);
        红车2.set棋子类别(红方颜色);
        红马1=new ChessPiece("马",Color.red,bc,w-4,h-4,this);
        红马1.set棋子类别(红方颜色);
        红马2=new ChessPiece("马",Color.red,bc,w-4,h-4,this);
        红马2.set棋子类别(红方颜色);
        红炮1=new ChessPiece("炮",Color.red,bc,w-4,h-4,this);
        红炮1.set棋子类别(红方颜色);
        红炮2=new ChessPiece("炮",Color.red,bc,w-4,h-4,this);
        红炮2.set棋子类别(红方颜色);
        红相1=new ChessPiece("相",Color.red,bc,w-4,h-4,this);
        红相1.set棋子类别(红方颜色);
        红相2=new ChessPiece("相",Color.red,bc,w-4,h-4,this);
        红相2.set棋子类别(红方颜色);
        红士1=new ChessPiece("士",Color.red,bc,w-4,h-4,this);
        红士1.set棋子类别(红方颜色);
        红士2=new ChessPiece("士",Color.red,bc,w-4,h-4,this);
        红士2.set棋子类别(红方颜色);
        红帅=new ChessPiece("帅",Color.red,bc,w-4,h-4,this);
        红帅.set棋子类别(红方颜色);
        红兵1=new ChessPiece("兵",Color.red,bc,w-4,h-4,this);
        红兵1.set棋子类别(红方颜色);
        红兵2=new ChessPiece("兵",Color.red,bc,w-4,h-4,this);
        红兵2.set棋子类别(红方颜色);
        红兵3=new ChessPiece("兵",Color.red,bc,w-4,h-4,this);
        红兵3.set棋子类别(红方颜色);
        红兵4=new ChessPiece("兵",Color.red,bc,w-4,h-4,this);
        红兵4.set棋子类别(红方颜色);
        红兵5=new ChessPiece("兵",Color.red,bc,w-4,h-4,this);
        红兵5.set棋子类别(红方颜色);
         
        黑将=new ChessPiece("将",Color.blue,bc,w-4,h-4,this);
        黑将.set棋子类别(黑方颜色);
        黑士1=new ChessPiece("士",Color.blue,bc,w-4,h-4,this);
        黑士1.set棋子类别(黑方颜色);
        黑士2=new ChessPiece("士",Color.blue,bc,w-4,h-4,this);
        黑士2.set棋子类别(黑方颜色);
        黑车1=new ChessPiece("车",Color.blue,bc,w-4,h-4,this);
        黑车1.set棋子类别(黑方颜色);
        黑车2=new ChessPiece("车",Color.blue,bc,w-4,h-4,this);
        黑车2.set棋子类别(黑方颜色);
        黑炮1=new ChessPiece("炮",Color.blue,bc,w-4,h-4,this);
        黑炮1.set棋子类别(黑方颜色);
        黑炮2=new ChessPiece("炮",Color.blue,bc,w-4,h-4,this);
        黑炮2.set棋子类别(黑方颜色);
        黑象1=new ChessPiece("象",Color.blue,bc,w-4,h-4,this);
        黑象1.set棋子类别(黑方颜色);
        黑象2=new ChessPiece("象",Color.blue,bc,w-4,h-4,this);
        黑象2.set棋子类别(黑方颜色);
        黑马1=new ChessPiece("马",Color.blue,bc,w-4,h-4,this);
        黑马1.set棋子类别(黑方颜色); 
        黑马2=new ChessPiece("马",Color.blue,bc,w-4,h-4,this);
        黑马2.set棋子类别(黑方颜色); 
        黑卒1=new ChessPiece("卒",Color.blue,bc,w-4,h-4,this);
        黑卒1.set棋子类别(黑方颜色);
        黑卒2=new ChessPiece("卒",Color.blue,bc,w-4,h-4,this);
        黑卒2.set棋子类别(黑方颜色);
        黑卒3=new ChessPiece("卒",Color.blue,bc,w-4,h-4,this);
        黑卒3.set棋子类别(黑方颜色);
        黑卒4=new ChessPiece("卒",Color.blue,bc,w-4,h-4,this);
        黑卒4.set棋子类别(黑方颜色);
        黑卒5=new ChessPiece("卒",Color.blue,bc,w-4,h-4,this);
        黑卒5.set棋子类别(黑方颜色);
        point[1][10].setPiece(红车1,this);
        point[2][10].setPiece(红马1,this);
        point[3][10].setPiece(红相1,this);
        point[4][10].setPiece(红士1,this);
        point[5][10].setPiece(红帅,this);
        point[6][10].setPiece(红士2,this);
        point[7][10].setPiece(红相2,this);
        point[8][10].setPiece(红马2,this);
        point[9][10].setPiece(红车2,this);
        point[2][8].setPiece(红炮1,this);
        point[8][8].setPiece(红炮2,this);  
        point[1][7].setPiece(红兵1,this);
        point[3][7].setPiece(红兵2,this);
        point[5][7].setPiece(红兵3,this);
        point[7][7].setPiece(红兵4,this);
        point[9][7].setPiece(红兵5,this);

        point[1][1].setPiece(黑车1,this);
        point[2][1].setPiece(黑马1,this);
        point[3][1].setPiece(黑象1,this);
        point[4][1].setPiece(黑士1,this);
        point[5][1].setPiece(黑将,this);
        point[6][1].setPiece(黑士2,this);
        point[7][1].setPiece(黑象2,this);
        point[8][1].setPiece(黑马2,this);
        point[9][1].setPiece(黑车2,this);
        point[2][3].setPiece(黑炮1,this);
        point[8][3].setPiece(黑炮2,this);
        point[1][4].setPiece(黑卒1,this);
        point[3][4].setPiece(黑卒2,this);
        point[5][4].setPiece(黑卒3,this);
        point[7][4].setPiece(黑卒4,this);
        point[9][4].setPiece(黑卒5,this);
    
    }
  public void paintComponent(Graphics g)
   ...{
     super.paintComponent(g);
      for(int j=1;j<=y轴长;j++)   
       ...{
          g.drawLine(point[1][j].x,point[1][j].y,point[x轴长][j].x,point[x轴长][j].y); 
       }
     for(int i=1;i<=x轴长;i++)     
       ...{
         if(i!=1&&i!=x轴长)
          ...{
            g.drawLine(point[i][1].x,point[i][1].y,point[i][y轴长-5].x,point[i][y轴长-5].y);
            g.drawLine(point[i][y轴长-4].x,point[i][y轴长-4].y,point[i][y轴长].x,point[i][y轴长].y); 
          }
         else
          ...{
            g.drawLine(point[i][1].x,point[i][1].y,point[i][y轴长].x,point[i][y轴长].y);
          }
       }
      
       g.drawLine(point[4][1].x,point[4][1].y,point[6][3].x,point[6][3].y);
       g.drawLine(point[6][1].x,point[6][1].y,point[4][3].x,point[4][3].y);
       g.drawLine(point[4][8].x,point[4][8].y,point[6][y轴长].x,point[6][y轴长].y);
       g.drawLine(point[4][y轴长].x,point[4][y轴长].y,point[6][8].x,point[6][8].y);
     
       for(int i=1;i<=x轴长;i++)
       ...{ 
          g.drawString(""+i,i*unitWidth,unitHeight/2);
       }
       int j=1;
      for(char c='A';c<='J';c++)
       ...{ 
          g.drawString(""+c,unitWidth/4,j*unitHeight);
          j++;
       }
         
   } 
  public void mousePressed(MouseEvent e)
  ...{ 
    ChessPiece piece=null;
    Rectangle rect=null;
    if(e.getSource()==this)
        move=false;
    if(move==false)
      if(e.getSource() instanceof ChessPiece)
       ...{
         piece=(ChessPiece)e.getSource();   
         startX=piece.getBounds().x;        
         startY=piece.getBounds().y;     
         
          rect=piece.getBounds();
          for(int i=1;i<=x轴长;i++)
            ...{
              for(int j=1;j<=y轴长;j++)
                ...{
                  int x=point[i][j].getX();
                  int y=point[i][j].getY();
                  if(rect.contains(x,y))
                   ...{                   
                     startI=i;
                     startJ=j;
                     break;
                   }
                  
                }
            }
       }
  } 
 public void mouseMoved(MouseEvent e)
  ...{ 
  }
 public void mouseDragged(MouseEvent e)
  ...{
 
    ChessPiece piece=null;
       if(e.getSource() instanceof ChessPiece)
         ...{
           piece=(ChessPiece)e.getSource();   
           
           move=true; 
           
           e=SwingUtilities.convertMouseEvent(piece,e,this); 
         }
    
       if(e.getSource()==this)
        ...{
          if(move&&piece!=null)
           ...{
            x=e.getX(); 
            y=e.getY();
            if(红方走棋&&((piece.棋子类别()).equals(红方颜色)))
               ...{
                 piece.setLocation(x-piece.getWidth()/2,y-piece.getHeight()/2);
               }
            if(黑方走棋&&(piece.棋子类别().equals(黑方颜色)))
               ...{
                 piece.setLocation(x-piece.getWidth()/2,y-piece.getHeight()/2);
               }
           }
        }
 }
 public void mouseReleased(MouseEvent e)
  ...{ 
    ChessPiece piece=null;
    move=false;
    Rectangle rect=null;
    if(e.getSource() instanceof ChessPiece)
      ...{
        piece=(ChessPiece)e.getSource();   
        rect=piece.getBounds();
         
        e=SwingUtilities.convertMouseEvent(piece,e,this); 
      }
    if(e.getSource()==this)
     ...{
        boolean containChessPoint=false;
        int x=0,y=0;
        int m=0,n=0;
        if(piece!=null)
         ...{ 
          for(int i=1;i<=x轴长;i++)
            ...{
              for(int j=1;j<=y轴长;j++)
                ...{
                  x=point[i][j].getX();
                  y=point[i][j].getY();
                  if(rect.contains(x,y))
                   ...{ 
                    
                     containChessPoint=true;
                     m=i;
                     n=j;
                     break;
                   }
                  
                }
            }
         }
        if(piece!=null&&containChessPoint)
         ...{
           Color pieceColor=piece.获取棋子颜色();
          if(point[m][n].isPiece()) 
            ...{ 
               Color c=(point[m][n].getPiece()).获取棋子颜色();
               if(pieceColor.getRGB()==c.getRGB())
                   ...{ 
                     piece.setLocation(startX,startY);
                     
                     (point[startI][startJ]).set有棋子(true);
                   }                  
               else
                   ...{ 
                      boolean ok=rule.movePieceRule(piece,startI,startJ, m,n);
                      if(ok)
                       ...{                 
                            ChessPiece pieceRemoved=point[m][n].getPiece();
                            point[m][n].reMovePiece(pieceRemoved,this);
                            point[m][n].setPiece(piece,this);
                            (point[startI][startJ]).set有棋子(false);
                            record.记录棋谱(piece,startI,startJ,m,n) ;
                            record.记录吃掉的棋子(pieceRemoved)   ; 
                             if(pieceRemoved.getName().equals("将"))
                                     ...{
                                          红方走棋=false;
                                          黑方走棋=false;
                                          JOptionPane.showMessageDialog(Message,"恭喜红方棋手获得本局对弈胜利");
                                     }
                             else
                                     if(pieceRemoved.getName().equals("帅"))
                                     ...{
                                          红方走棋=false;
                                          黑方走棋=false;
                                          JOptionPane.showMessageDialog(Message,"恭喜蓝方棋手获得本局对弈胜利");
                                     } 
                                     else
                                     if(piece.棋子类别().equals(红方颜色))
                                     ...{
                                       红方走棋=false;
                                       黑方走棋=true;
                                      }
                                    else
                                        if(piece.棋子类别().equals(黑方颜色))
                                      ...{
                                       黑方走棋=false;
                                       红方走棋=true;
                                        }
                           validate();
                           repaint();
                       }
                      else    
                       ...{
                           piece.setLocation(startX,startY);
                           (point[startI][startJ]).set有棋子(true);
                       }
                   }
                 
            }
          else
            ...{
              
               boolean ok=rule.movePieceRule(piece,startI,startJ, m,n);
               if(ok)
                 ...{
                    point[m][n].setPiece(piece,this);
                   (point[startI][startJ]).set有棋子(false);
                   record.记录棋谱(piece,startI,startJ,m,n) ;
                   record.记录吃掉的棋子("没吃棋子");        
                     if(piece.棋子类别().equals(红方颜色))
                       ...{
                          红方走棋=false;
                          黑方走棋=true;
                       }
                      if(piece.棋子类别().equals(黑方颜色))
                       ...{
                         黑方走棋=false;
                         红方走棋=true;
                       }
                 }
               else     
                 ...{
                   piece.setLocation(startX,startY);
                   (point[startI][startJ]).set有棋子(true);
                 }
            }
        }
     if(piece!=null&&!containChessPoint)        
       ...{        
          piece.setLocation(startX,startY);
          (point[startI][startJ]).set有棋子(true);
       }
    }  
  }
 public void mouseEntered(MouseEvent e)
  ...{
  }
 public void mouseExited(MouseEvent e)
  ...{ 
  }
 public void mouseClicked(MouseEvent e)
  ...{ 
  }
}

棋子类

/**//*
ChessPiece.java
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ChessPiece extends JLabel 
...{
   String name;
   Color backColor=null,foreColor;
   String 颜色类别=null;
   ChessBoard board=null;
   int width,height;
  public ChessPiece(String name,Color fc,Color bc,int width,int height,ChessBoard board)
   ...{
     this.name=name;
     this.board=board;
     this.width=width;
     this.height=height;
     foreColor=fc; 
     backColor=bc;
     setSize(width,height);
     setBackground(bc); 
     addMouseMotionListener(board);
     addMouseListener(board);
   }
   public void paint(Graphics g)
   ...{ 
     g.setColor(foreColor);
     g.fillOval(2,2,width-2,height-2);
     g.setColor(Color.white);
     g.setFont(new Font("隶书",Font.BOLD,28));    
     g.drawString(name,7,height-8);
     g.setColor(Color.yellow);
     g.drawOval(2,2,width-2,height-2);
   }
   public int getWidth()
   ...{
     return width;
   }
   public int getHeight()
   ...{
     return height;
   }
   public String getName()
   ...{
     return name;
   }
   public Color 获取棋子颜色()
   ...{
     return foreColor;
   }
   public void set棋子类别(String 类别)
   ...{
      颜色类别=类别;
   }
  public String 棋子类别()
   ...{
     return  颜色类别;
   }

棋子落点类

/**//*
ChessPoint.java
*/
public class ChessPoint
...{
   int x,y;
   boolean 有棋子;
   ChessPiece piece=null;
   ChessBoard board=null;
   public ChessPoint(int x,int y,boolean boo)
   ...{
      this.x=x;
      this.y=y;
      有棋子=boo;
   }
  public boolean isPiece()
  ...{
    return 有棋子;
  }
  public void set有棋子(boolean boo)
  ...{
    有棋子=boo;
  }
 
  public int getX()
  ...{
    return x;
  }
  public int getY()
  ...{
    return y;
  }
  public void setPiece(ChessPiece piece,ChessBoard board)
  ...{
     this.board=board;
     this.piece=piece;
     board.add(piece);
     int w=(board.unitWidth);
     int h=(board.unitHeight);
     piece.setBounds(x-w/2,y-h/2,w,h);
     有棋子=true;
     board.validate(); 
  }
  public ChessPiece getPiece()
  ...{
     return piece;
  }
  public void reMovePiece(ChessPiece piece,ChessBoard board)
  ...{
     this.board=board;
     this.piece=piece;
     board.remove(piece);
     board.validate();
     有棋子=false;
  }
}

棋谱演示类

/**//*
Demon.java
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Demon extends JPanel  implements ActionListener,Runnable
...{
   public JButton replay=null,next=null,auto=null,stop=null;
   LinkedList 棋谱=null;
   Thread 自动演示=null;
   int index=-1;
   ChessBoard board=null;
   JTextArea text;
   JTextField 时间间隔=null;
   int time=1000;
   String 演示过程="";
   JSplitPane splitH=null,splitV=null;
   public  Demon(ChessBoard board)
   ...{    
        this.board=board;
        replay=new JButton("重新演示");
        next=new JButton("下一步");
        auto=new JButton("自动演示");
        stop=new JButton("暂停演示");
        自动演示=new Thread(this);
        replay.addActionListener(this);
        next.addActionListener(this);
        auto.addActionListener(this);
        stop.addActionListener(this); 
        text=new JTextArea(); 
        时间间隔=new JTextField("1");
        setLayout(new BorderLayout());
        JScrollPane pane=new JScrollPane(text);
        JPanel p=new JPanel(new GridLayout(3,2));
        p.add(next);
        p.add(replay);
        p.add(auto);
        p.add(stop);
        p.add(new JLabel("时间间隔(秒)",SwingConstants.CENTER)) ;
        p.add(时间间隔);
        splitV=new JSplitPane(JSplitPane.VERTICAL_SPLIT,pane,p);
        splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,board,splitV);
        splitV.setDividerSize(5);
        splitV.setDividerLocation(400);
        splitH.setDividerSize(5);
        splitH.setDividerLocation(460);
        add(splitH,BorderLayout.CENTER); 
        validate();
    }   
 public void set棋谱(LinkedList 棋谱)
   ...{ 
    this.棋谱=棋谱;
   }
 public char numberToLetter(int n)   
  ...{ 
    char c='

棋谱制作

/**//*
MakeChessManual.java
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.LinkedList;

public class MakeChessManual extends JPanel implements ActionListener
...{
  JTextArea text=null;
  JScrollPane scroll=null;
  ChessBoard board=null;
  ChessPoint[][] point;
  LinkedList 棋谱=null;
  LinkedList 吃掉的棋子=null;    
  JButton buttonUndo;
  int i=0;
  public MakeChessManual(ChessBoard board,ChessPoint[][] point)   
  ...{
   this.board=board;
   this.point=point;
   text=new JTextArea();
   scroll=new JScrollPane(text);
   棋谱=new LinkedList();
   吃掉的棋子=new LinkedList();
   buttonUndo=new JButton("悔棋");
   buttonUndo.setFont(new Font("隶书",Font.PLAIN,18));
   setLayout(new BorderLayout());
   add(scroll,BorderLayout.CENTER);
   add(buttonUndo,BorderLayout.SOUTH);
   buttonUndo.addActionListener(this);
  }
  public char numberToLetter(int n)   
  ...{ 
    char c='

MoveStep类

import java.awt.Point;
public class MoveStep implements java.io.Serializable
...{
  public Point pStart,pEnd;
  public MoveStep(Point p1,Point p2)
  ...{
     pStart=p1;
     pEnd=p2;
  }
}

走棋规则类

/**//*
Rule.java
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Rule 
...{
  ChessBoard board=null;
  ChessPiece piece=null;
  ChessPoint point[][]; 
  int startI,startJ,endI,endJ,k;
  public Rule(ChessBoard board,ChessPoint point[][])
  ...{
    this.board=board;
    this.point=point;
  }
  public boolean movePieceRule(ChessPiece piece,int startI,int startJ,int endI,int endJ)
  ...{
    this.piece=piece;
    this.startI=startI;
    this.startJ=startJ;
    this.endI=endI;
    this.endJ=endJ;
    int minI=Math.min(startI,endI);
    int maxI=Math.max(startI,endI);
    int minJ=Math.min(startJ,endJ); 
    int maxJ=Math.max(startJ,endJ);
    boolean 可否走棋=false;
    if(piece.getName().equals("车"))
       ...{    int i=0;
           if(startI>=4&&startI<=6)
               ...{
               for(i=startJ-1;i>=1;i--)
                   ...{
                       if(point[startI][i].isPiece())
                           ...{
                               if((point[startI][i].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                               if(endI==startI)                                                                
                                                                   ...{
                                                       int j=0;
                                                       for(j=minJ+1;j<=maxJ-1;j++)
                                                         ...{ 
                                                        if(point[startI][j].isPiece())
                                                          ...{
                                                              可否走棋=false;
                                                             break;
                                                          } 
                                                         }
                                                    if(j==maxJ)
                                                      ...{
                                                      可否走棋=true;
                                                       }
                                                     }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   i=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               i=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][i].getPiece().getName())!="将")
                                           ...{
                                               i=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(i==0)
               ...{
          if(startI==endI)   
             ...{
               int j=0;
               for(j=minJ+1;j<=maxJ-1;j++)
                 ...{ 
                    if(point[startI][j].isPiece())
                      ...{
                         可否走棋=false;
                         break;
                      } 
                 }
                if(j==maxJ)
                 ...{
                    可否走棋=true;
                 }
             }
           else if(startJ==endJ)  
             ...{  
                int h=0;
                for(h=minI+1;h<=maxI-1;h++)
                 ...{ 
                    if(point[h][startJ].isPiece())
                      ...{
                         可否走棋=false;
                         break;
                      } 
                 }
                if(h==maxI)
                 ...{
                      可否走棋=true;
                 } 
             }
           else                  
             ...{
                可否走棋=false;
             }
               }
       }    
    else 
        if(piece.getName().equals("马"))
           ...{int t=0;
            int xAxle=Math.abs(startI-endI);
       int yAxle=Math.abs(startJ-endJ);
           
           if(startI>=4&&startI<=6)
               ...{
               for(t=startJ-1;t>=1;t--)
                   ...{
                       if(point[startI][t].isPiece())
                           ...{
                               if((point[startI][t].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                               if(endI==startI)                                                                
                                                                   ...{
                                                                        可否走棋=false;
                                                     }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   t=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               t=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][t].getPiece().getName())!="将")
                                           ...{
                                               t=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(t==0)
               ...{
               if(xAxle==2&&yAxle==1)
              ...{ 
             if(endI>startI)
                ...{
                   if(point[startI+1][startJ].isPiece())
                     ...{
                       可否走棋=false;
                     }
                   else
                     ...{
                       可否走棋=true;
                     }
                }
              if(endI<startI)
                ...{
                   if(point[startI-1][startJ].isPiece())
                     ...{
                       可否走棋=false;
                     }
                   else
                     ...{
                       可否走棋=true;
                     }
                }
              
              } 
       
               else if(xAxle==1&&yAxle==2)       
               ...{ 
             if(endJ>startJ)
                ...{
                   if(point[startI][startJ+1].isPiece())
                     ...{
                       可否走棋=false;
                     }
                   else
                     ...{
                       可否走棋=true;
                     }
                }
              if(endJ<startJ)
                ...{
                   if(point[startI][startJ-1].isPiece())
                     ...{
                       可否走棋=false;
                     }
                   else
                     ...{
                       可否走棋=true;
                     }
                }
              
              } 
               else 
               ...{
            可否走棋=false;
              }
               }
           }        
   else 
    if(piece.getName().equals("象"))
       ...{      int r=0;
        int centerI=(startI+endI)/2;
        int centerJ=(startJ+endJ)/2;
        int xAxle=Math.abs(startI-endI);
        int yAxle=Math.abs(startJ-endJ); 
           
           if(startI>=4&&startI<=6)
               ...{
               for(r=startJ-1;r>=1;r--)
                   ...{
                       if(point[startI][r].isPiece())
                           ...{
                               if((point[startI][r].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                               if(endI==startI)                                                                
                                                                   ...{
                                                                        可否走棋=false;
                                                     }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   r=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               r=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][r].getPiece().getName())!="将")
                                           ...{
                                               r=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(r==0)
               ...{
            if(xAxle==2&&yAxle==2&&endJ<=5)          
              ...{
             if(point[centerI][centerJ].isPiece())
                ...{            
                 可否走棋=false;
                }
             else
                ...{
                  可否走棋=true;
                }
              } 
           else
              ...{
                可否走棋=false;
              }
               }
       }    
   else
    if(piece.getName().equals("相"))
       ...{        int e=0;
        int centerI=(startI+endI)/2;
        int centerJ=(startJ+endJ)/2;
        int xAxle=Math.abs(startI-endI);
        int yAxle=Math.abs(startJ-endJ); 
           
           if(startI>=4&&startI<=6)
               ...{
               for(e=startJ-1;e>=1;e--)
                   ...{
                       if(point[startI][e].isPiece())
                           ...{
                               if((point[startI][e].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                               if(endI==startI)                                                                
                                                                   ...{
                                                                        可否走棋=false;
                                                     }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   e=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               e=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][e].getPiece().getName())!="将")
                                           ...{
                                               e=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(e==0)
               ...{
            if(xAxle==2&&yAxle==2&&endJ>=6)          
          ...{
             if(point[centerI][centerJ].isPiece())
                ...{            
                  可否走棋=false;
                }
             else
                ...{
                  可否走棋=true;
                }
          } 
           else
          ...{
            可否走棋=false;
          }
               }
       }        
   else
    if(piece.getName().equals("炮"))
       ...{     int w=0;
       int number=0;
           
           if(startI>=4&&startI<=6)
               ...{
               for(w=startJ-1;w>=1;w--)
                   ...{
                       if(point[startI][w].isPiece())
                           ...{
                               if((point[startI][w].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                       if(startI==endI)   
                                                     ...{
                                                       int j=0;
                                                       for(j=minJ+1;j<=maxJ-1;j++)
                                                         ...{ 
                                                            if(point[startI][j].isPiece())
                                                          ...{
                                                            number++;
                                                          } 
                                                      }
                                                   if(number>1)
                                                     ...{
                                                    可否走棋=false;
                                                     }
                                                   else if(number==1)
                                                     ...{
                                                    if(point[endI][endJ].isPiece())
                                                          ...{
                                                            可否走棋=true;
                                                         }
                                                      }
                                                    else if(number==0&&!point[endI][endJ].isPiece())
                                                     ...{
                                                        可否走棋=true;
                                                     }
                                                  }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   w=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               w=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][w].getPiece().getName())!="将")
                                           ...{
                                               w=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(w==0)
               ...{
         if(startI==endI)   
                 ...{
                   int j=0;
                   for(j=minJ+1;j<=maxJ-1;j++)
                     ...{ 
                        if(point[startI][j].isPiece())
                          ...{
                            number++;
                          } 
                     }
                   if(number>1)
                     ...{
                        可否走棋=false;
                     }
                   else if(number==1)
                     ...{
                        if(point[endI][endJ].isPiece())
                          ...{
                            可否走棋=true;
                          }
                     }
                   else if(number==0&&!point[endI][endJ].isPiece())
                     ...{
                        可否走棋=true;
                     }
                 }
         else if(startJ==endJ)  
                 ...{  
                    int i=0;
                    for(i=minI+1;i<=maxI-1;i++)
                     ...{ 
                        if(point[i][startJ].isPiece())
                          ...{
                            number++;
                          } 
                     }
                   if(number>1)
                     ...{
                        可否走棋=false;
                     }
                   else if(number==1)
                     ...{
                        if(point[endI][endJ].isPiece())
                          ...{
                            可否走棋=true;
                          }
                     }
                   else if(number==0&&!point[endI][endJ].isPiece())
                     ...{
                        可否走棋=true;
                     }
                 }
         else 
                 ...{
                    可否走棋=false;
                 }
               }
       }       
   else 
    if(piece.getName().equals("兵"))
       ...{    int q=0;
      int xAxle=Math.abs(startI-endI);
      int yAxle=Math.abs(startJ-endJ);
           
           if(startI>=4&&startI<=6)
               ...{
               for(q=startJ-1;q>=1;q--)
                   ...{
                       if(point[startI][q].isPiece())
                           ...{
                               if((point[startI][q].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                       if(startI==endI)   
                                                     ...{
                                      if(startJ-endJ==1&&xAxle==0) 
                                      ...{
                                        可否走棋=true; 
                                      }
            
                                    else
                                      ...{
                                        可否走棋=false; 
                                      }
                                                  }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   q=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               q=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][q].getPiece().getName())!="将")
                                           ...{
                                               q=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(q==0)
               ...{
         if(endJ>=6)  
            ...{
              if(startJ-endJ==1&&xAxle==0) 
                 ...{
                    可否走棋=true; 
                 }
            
              else
                 ...{
                    可否走棋=false; 
                 }
            }
         else if(endJ<=5)  
            ...{
              if((startJ-endJ==1)&&(xAxle==0)) 
               ...{
                  可否走棋=true; 
               }
              else if((endJ-startJ==0)&&(xAxle==1))
               ...{
                  可否走棋=true; 
               }
              else
               ...{
                  可否走棋=false; 
               }
            }
               }
       }       
   else
    if(piece.getName().equals("卒"))
       ...{    int u=0;
      int xAxle=Math.abs(startI-endI);
      int yAxle=Math.abs(startJ-endJ);
           
           if(startI>=4&&startI<=6)
               ...{
               for(u=startJ-1;u>=1;u--)
                   ...{
                       if(point[startI][u].isPiece())
                           ...{
                               if((point[startI][u].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                       if(startI==endI)   
                                                     ...{
                                      if(endJ-startJ==1&&xAxle==0) 
                                      ...{
                                        可否走棋=true; 
                                      }
            
                                    else
                                      ...{
                                        可否走棋=false; 
                                      }
                                                  }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   u=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               u=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][u].getPiece().getName())!="将")
                                           ...{
                                               u=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(u==0)
               ...{
         if(endJ<=5)  
            ...{
              if(endJ-startJ==1&&xAxle==0) 
                 ...{
                    可否走棋=true; 
                 }
            
              else
                 ...{
                    可否走棋=false; 
                 }
            }
         else if(endJ>=6)  
            ...{
              if((endJ-startJ==1)&&(xAxle==0)) 
               ...{
                  可否走棋=true; 
               }
              else if((endJ-startJ==0)&&(xAxle==1))
               ...{
                  可否走棋=true; 
               }
              else
               ...{
                  可否走棋=false; 
               }
            }
               }
       }         
   else
    if(piece.getName().equals("士"))
       ...{    int p=0;
      int xAxle=Math.abs(startI-endI);
      int yAxle=Math.abs(startJ-endJ);
           
           if(startI>=4&&startI<=6)
               ...{
               for(p=startJ-1;p>=1;p--)
                   ...{
                       if(point[startI][p].isPiece())
                           ...{
                               if((point[startI][p].getPiece().getName()).equals("将"))
                                   ...{
                                       for(k=startJ+1;k<=10;k++)
                                           ...{
                                               if(point[startI][k].isPiece())
                                                   ...{
                                                       if((point[startI][k].getPiece().getName()).equals("帅"))
                                                           ...{
                                                       if(startI==endI)   
                                                     ...{
                                                           可否走棋=false;                                                                        
                                                  }
                                                   else
                                                       ...{
                                                           可否走棋=false;
                                                       }
                                                           }
                                                       else
                                                           if((point[startI][k].getPiece().getName())!=("帅"))
                                                               ...{
                                                                   p=0;
                                                                }
                                                       break;
                                                   }
                                           }
                                       if(k==11)
                                           ...{
                                               p=0;
                                           }
                                   }
                               else
                                   ...{
                                       if((point[startI][p].getPiece().getName())!="将")
                                           ...{
                                               p=0;
                                           }
                                   }
                               break;
                           }
                   
                   }
           
               }
           if(p==0)
               ...{
        if(endI<=6&&endI>=4&&xAxle==1&&yAxle==1) 
           ...{
            可否走棋=true; 
           }
        else
           ...{
            可否走棋=false;
           }
               }
       }       
   else 
       if(piece.getName().equals("帅"))  
        ...{
          int i;
          int xAxle=Math.abs(startI-endI);
              int yAxle=Math.abs(startJ-endJ);
              if(endI==startI)
              ...{
                  if(endI<=6&&endI>=4&&endJ<=10&&endJ>=8)
              ...{ 
                if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                 ...{
                   可否走棋=true; 
                  }
                else
                 ...{
                    可否走棋=false;
                  }
               } 
            else
              ...{
                可否走棋=false;
              }
              }
              else
              ...{
                  for(i=endJ;i>=1;i--)
                      ...{
                          if(point[endI][i].isPiece())
                              ...{
                                  if((point[endI][i].getPiece().getName()).equals("将"))
                                      ...{
                                          if(endI<=6&&endI>=4&&endJ<=10&&endJ>=8&&endI!=startI+1&&endI!=startI-1)
                                         ...{ 
                                        if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                                          ...{
                                            可否走棋=true; 
                                           }
                                        else
                                          ...{
                                             可否走棋=false;
                                           }
                                          } 
                                    else
                                       ...{
                                        可否走棋=false;
                                       }
                                      }
                                  else
                                      if((point[endI][i].getPiece().getName())!=("将"))
                                      ...{
                                          if(endI<=6&&endI>=4&&endJ<=10&&endJ>=8)
                                       ...{ 
                                        if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                                             ...{
                                               可否走棋=true; 
                                              }
                                        else
                                             ...{
                                            可否走棋=false;
                                              }
                                       } 
                                    else
                                          ...{
                                            可否走棋=false;
                                          }    
                                      }
                                    break;
                                }             
                      }
                 if(i==0)
                     ...{
                         if(endI<=6&&endI>=4&&endJ<=10&&endJ>=8)
                         ...{ 
                        if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                          ...{
                            可否走棋=true; 
                           }
                        else
                          ...{
                             可否走棋=false;
                           }
                          } 
                    else
                       ...{
                            可否走棋=false;
                       }    
                     }
             }
         }
        else
       if(piece.getName().equals("将"))  
        ...{    
            int i;
          int xAxle=Math.abs(startI-endI);
              int yAxle=Math.abs(startJ-endJ);
              if(endI==startI)
              ...{
                  if(endI<=6&&endI>=4&&endJ<=3&&endJ>=1)
              ...{ 
                if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                 ...{
                   可否走棋=true; 
                  }
                else
                 ...{
                    可否走棋=false;
                  }
               } 
            else
              ...{
                可否走棋=false;
              }
              }
              else
              ...{
                  for(i=endJ;i<=10;i++)
                      ...{
                          if(point[endI][i].isPiece())
                              ...{
                                  if((point[endI][i].getPiece().getName()).equals("帅"))
                                      ...{
                                          if(endI<=6&&endI>=4&&endJ<=3&&endJ>=1&&endI!=startI+1&&endI!=startI-1)
                                         ...{ 
                                        if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                                          ...{
                                            可否走棋=true; 
                                           }
                                        else
                                          ...{
                                             可否走棋=false;
                                           }
                                          } 
                                    else
                                       ...{
                                        可否走棋=false;
                                       }
                                      }
                                  else
                                      if((point[endI][i].getPiece().getName())!=("帅"))
                                      ...{
                                          if(endI<=6&&endI>=4&&endJ<=3&&endJ>=1)
                                       ...{ 
                                        if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                                             ...{
                                               可否走棋=true; 
                                              }
                                        else
                                             ...{
                                            可否走棋=false;
                                              }
                                       } 
                                    else
                                          ...{
                                            可否走棋=false;
                                          }
                                      }
                                    break;
                                }             
                      }
                 if(i==11)
                     ...{
                         if(endI<=6&&endI>=4&&endJ<=3&&endJ>=1)
                         ...{ 
                        if((xAxle==1&&yAxle==0)||(xAxle==0&&yAxle==1))
                          ...{
                            可否走棋=true; 
                           }
                        else
                          ...{
                             可否走棋=false;
                           }
                          } 
                    else
                       ...{
                            可否走棋=false;
                       }    
                     }
             }
         }

   return 可否走棋;

  }
}

单机中国象棋(Java版)相关推荐

  1. 中国象棋(Java版)

    版本1.0 程序简介: 如果程序运行之后报错 ,一般是由于JDK版本不同的原因,我使用的是JDK1.7,因为在JDK1.7中加入了Swicth(String)即可以对字符串进行切换, 所以会出如下问题 ...

  2. Java实现中国象棋(联机版)

    Java实现中国象棋(联机版) 该版本的中国象棋,程序有点复杂,是基于网络通信的基础上实现的.由于代码带太长,我这里就只做简单的演示,下面会给出链接地址的. 一.程序结构: 客户端: 服务端: 二.操 ...

  3. Java游戏开发——中国象棋联机版

    游戏介绍: 中国象棋是起源于中国的一种棋戏,属于二人对抗性游戏的一种,在中国有着悠久的历史.由于规则简单,趣味性强,成为流行极为广泛的棋类游戏. 中国象棋使用方形格状棋盘及红黑二色圆形棋子进行对弈,棋 ...

  4. java象棋实验报告_中国象棋java程序设计实验报告

    中国象棋java程序设计实验报告 东北大学秦皇岛分校信息与计算科学系Java 程序设计实验报告专业名称 信 息 与 计 算 科 学班级学号 7080206学生姓名 彭 军指导教师 王 薇完成时间 20 ...

  5. java象棋实验报告_中国象棋java程序设计实验报告.doc

    中国象棋java程序设计实验报告.doc 东北大学秦皇岛分校 信息与计算科学系 Java 程序设计实验报告 专业名称 信息与计算科学 班级学号 7080206 学生姓名 彭 军 指导教师 王薇 完成时 ...

  6. 教你怎么用Python和Qt5编写中国象棋AI版——规则模块

    提示:该模块用于实现规则模块 教你怎么用Python和Qt5编写中国象棋AI版--规则模块 前言 一.中国象棋大致规则? 二.各棋子规则实现思路 1.兵 注意事项 过河兵合法偏移 未过河兵合法偏移 2 ...

  7. 教你怎么用Python和Qt5编写中国象棋AI版——简明易懂版

    教你怎么用Python和Qt5编写中国象棋AI版--简明易懂版 一.前言 二.中国象棋的几个模块--作者认为的 三.各模块大致实现思路 四.最后 一.前言 大家学习Python是否有过编写一个稍微大型 ...

  8. 中国象棋java着算法_Java中国象棋博弈程序探秘[4]——生成有效着法

    生成有效着法 转载请保留作者信息: 作者:88250 MSN & Gmail & QQ:DL88250@gmail.com 着法生成就是要产生所有有效的着法,让电脑棋手在这些着法中选择 ...

  9. 中国象棋java算法_Java中国象棋博弈程序探秘[5]——搜索算法

    搜索算法 转载请保留作者信息: 作者:88250 MSN & Gmail & QQ:DL88250@gmail.com 搜索是电脑棋手AI的核心,有效的搜索算法很关键.本文给出了一些常 ...

最新文章

  1. 微服务治理实践 | 金丝雀发布
  2. layer output 激活函数_一文彻底搞懂BP算法:原理推导+数据演示+项目实战(下篇)...
  3. Linux(Contos7.5)环境搭建之Gitblit安装(三)
  4. HDU 5119 Happy Matt Friends(递推)
  5. 11/100. Convert BST to Greater Tree
  6. JS----JavaScript数组去重(12种方法,史上最全)
  7. mongoose mysql_mongoose入门
  8. mpandroidchart 设置x轴数据_Flowjo软件下的流式数据基本分析
  9. 「管理数学基础」1.3 矩阵理论:特征值与特征向量
  10. python 错误代码_[python]WindowsError的错误代码详解
  11. DPDK之KNI原理
  12. eclipse angularjs 插件安装
  13. spss连接mysql
  14. 小白刷LeeCode(算法篇)6
  15. 高龄白菜java学习第109天(java数据结构和算法(27))
  16. NCBI RefSeq命名格式的详细说明
  17. 【Java面试题】有三个线程 t1,t2,t3,怎么确保它们按顺序执行?
  18. 最大公因数等于 K 的子数组数目求解全过程
  19. kali域名无法暂时解析 无法网络
  20. ucinet三天写论文! 分组密度;EI指数实战

热门文章

  1. java new数组对象数组_java的new数组,对数组里每个对象必须再实例化
  2. FFmpeg CENC加密mp4文件
  3. 大规模中文文本处理中的自动切词和标注技术
  4. 数字IC手撕代码-边沿检测(上升沿、下降沿、双边沿)
  5. 微软公司内部培训程序员资料---求解线性方程组的类
  6. docker使用buildx构建不同架构镜像
  7. 软考高项:英语专题及真题
  8. php上传视频文件怎么实现
  9. 国际数据挖掘顶会 KDD 2019 研究方向亚军论文《Optimizing Impression Counts for Outdoor Advertising》解读
  10. 全球27所大学开设区块链课程,这门课究竟该教什么?