java五子棋代码可悔棋 java五子棋源码

用JAVA实现五子棋悔棋代码保存成.java文件直接运行编译
这是java五子棋代码可悔棋我回答java五子棋代码可悔棋的别人问题java五子棋代码可悔棋的答案地址
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
class Gobang extends JFrame implements Runnable, ActionListener
{
final static int Player=1;
final static int AI =-1;
ClassLoader cl = this.getClass().getClassLoader();
Toolkit tk = Toolkit.getDefaultToolkit();
int length=14, game_state, winner, check, step;
int grid[][] = new int[length][length];
int locX, locY /* ?囱?竚 */, count /* 硈囱计 */, x, y /* 既??竚 */, displace_x=0, displace_y=0 /* ?簿秖 */, direction;
ArrayList steps = new ArrayList(); /* 疠魁囱˙ */
JPopupMenu control_menu = new JPopupMenu(); /* ?龄匡虫?? */
JMenuItem[] command = new JMenuItem[4];
String[] command_str={"?囱", "?郎", "弄郎", "?秨"};
int[][] dir = { {-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1} };
boolean[] dir2 = new boolean[8];
boolean turn;
String message;
final JDialog dialog = new JDialog(this, "叫匡?", true);
Font font=new Font("new_font", Font.BOLD, 20);
Grid grids[][] = new Grid[length][length];
Image white= tk.getImage(cl.getResource("res/white.png"));
Image black= tk.getImage(cl.getResource("res/black.png"));
Image title= tk.getImage(cl.getResource("res/title.png"));
Image temp;
JPanel boardPanel, bigpanel;
JRadioButton[] choice = new JRadioButton[2];
final static int Start =0;
final static int Select =1;
final static int Playing =2;
final static int End =3;
final static int nil=-1; /* 礚よ? */
final static int oblique_1 =0; /* ???オ? */
final static int oblique_2 =1; /* オ???? */
final static int horizontal =2; /* 绢? */
final static int vertical=3; /* ?? */
Gobang()
{
super("き?囱");
boardPanel = new JPanel();
boardPanel.setLayout(new GridLayout(length, length, 0, 0));
boardPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
for(int i=0; ilength; i++)
for(int j=0; jlength; j++)
{
grids[i][j] = new Grid(i, j);
boardPanel.add(grids[i][j]);
}
bigpanel = new JPanel();
bigpanel.add(boardPanel, BorderLayout.CENTER);
getContentPane().add(bigpanel, BorderLayout.SOUTH);
game_state=Start;
ThreadStart();
dialog.setSize(160, 100);
dialog.setResizable(false);
dialog.setLocationRelativeTo(null);
ButtonGroup choice_group = new ButtonGroup();
JPanel choice_menu = new JPanel();
choice[0] = new JRadioButton("堵?", new ImageIcon(black), true);
choice[1] = new JRadioButton("フ?", new ImageIcon(white));
for(int i=0; ichoice.length; i++)
{
choice_menu.add(choice[i]);
choice_group.add(choice[i]);
}
for(int i=0; icommand.length; i++)
{
command[i] =new JMenuItem(command_str[i]);
command[i].addActionListener(this);
control_menu.add(command[i]);
}
JButton select = new JButton("絋)");
JPanel select_menu = new JPanel();
select_menu.add(select);
select.addActionListener(this);
dialog.getContentPane().add(choice_menu, BorderLayout.NORTH);
dialog.getContentPane().add(select_menu, BorderLayout.CENTER);
setIconImage(title);
setResizable(false);
setSize(300, 335);
setVisible(true);
setLocationRelativeTo(null);
}
public static void main(String[] arg)
{
Gobang application = new Gobang();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent event)
{
if( event.getSource().equals(command[0]) )

推荐阅读