符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
就给你一个吧,只不过没有添加棋子,你自己搞吧。import java.applet.*;
创新互联专注于惠济企业网站建设,响应式网站,商城网站建设。惠济网站建设公司,为惠济等地区提供建站服务。全流程按需求定制开发,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务
import java.awt.*;
import java.awt.event.*;
class ChessPad extends Panel implements MouseListener,ActionListener
{int x=-1,y=-1,棋子颜色=1;
Button button=new Button("重新开局");
TextField text_1=new TextField("请黑棋下子"),
text_2=new TextField();
ChessPad()
{setSize(440,440);
setLayout(null);setBackground(Color.pink);
addMouseListener(this);add(button);button.setBounds(10,5,60,26);
button.addActionListener(this);
add(text_1);text_1.setBounds(90,5,90,24);
add(text_2);text_2.setBounds(290,5,90,24);
text_1.setEditable(false);text_2.setEditable(false);
}
public void paint(Graphics g)
{for(int i=40;i=380;i+=20)
{g.drawLine(40,i,400,i);
}
g.drawLine(40,400,400,400);
for(int j=40;j=380;j+=20)
{g.drawLine(j,40,j,400);
}
g.drawLine(400,40,400,400);
g.fillOval(97,97,6,6);g.fillOval(337,97,6,6);
g.fillOval(97,337,6,6);g.fillOval(337,337,6,6);
g.fillOval(217,217,6,6);
}
public void mousePressed(MouseEvent e)
{if(e.getModifiers()==InputEvent.BUTTON1_MASK)
{x=(int)e.getX();y=(int)e.getY();
ChessPoint_black chesspoint_black=new ChessPoint_black(this);
ChessPoint_white chesspoint_white=new ChessPoint_white(this);
int a=(x+10)/2,b=(y+10)/2;
if(x/202||y/202||x/2019||y/2019)
{}
else
{
if(棋子颜色==1)
{this.add(chesspoint_black);
chesspoint_black.setBounds(a*20-7,b*20-7,16,16);
棋子颜色=棋子颜色*(-1);
text_2.setText("请白棋下子");
text_1.setText("");
}
else if(棋子颜色==-1)
{this.add(chesspoint_white);
chesspoint_white.setBounds(a*20-7,b*20-7,16,16);
棋子颜色=棋子颜色*(-1);
text_1.setText("请黑棋下子");
text_2.setText("");
}
}
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void actionPerformed(ActionEvent e)
{this.removeAll();棋子颜色=1;
add(button);button.setBounds(10,5,60,26);
add(text_1);text_1.setBounds(90,5,90,24);
text_2.setText("");text_1.setText("请黑棋下子");
add(text_2);text_2.setBounds(290,5,90,24);
}
}
class ChessPoint_black extends Canvas implements MouseListener
{ChessPad chesspad=null;
ChessPoint_black(ChessPad p)
{setSize(20,20);chesspad=p;addMouseListener(this);
}
public void paint(Graphics g)
{g.setColor(Color.black);g.fillOval(0,0,14,14);
}
public void mousePressed(MouseEvent e)
{if(e.getModifiers()==InputEvent.BUTTON3_MASK)
{chesspad.remove(this);
chesspad.棋子颜色=1;
chesspad.text_2.setText("");chesspad.text_1.setText("请黑棋下子");
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e)
{if(e.getClickCount()=2)
chesspad.remove(this);
}
}
class ChessPoint_white extends Canvas implements MouseListener
{ChessPad chesspad=null;
ChessPoint_white(ChessPad p)
{setSize(20,20);addMouseListener(this);
chesspad=p;
}
public void paint(Graphics g)
{g.setColor(Color.white);g.fillOval(0,0,14,14);
}
public void mousePressed(MouseEvent e)
{if(e.getModifiers()==InputEvent.BUTTON3_MASK)
{chesspad.remove(this);
chesspad.棋子颜色=-1;
chesspad.text_2.setText("请白棋下子");chesspad.text_1.setText("");
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e)
{if(e.getClickCount()=2)
chesspad.remove(this);
}
}
public class Chess extends Frame
{ChessPad chesspad=new ChessPad();
Chess()
{setVisible(true);
setLayout(null);
Label label=new Label("单击左键下子,双击吃子,右击棋子悔棋",Label.CENTER);
add(label);label.setBounds(70,55,440,26);
label.setBackground(Color.orange);
add(chesspad);chesspad.setBounds(70,90,440,440);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
pack();setSize(600,550);
}
public static void main (String args[])
{Chess chess=new Chess();
}
}
import java.awt.*;import java.awt.event.*;
//创建棋盘的类:
class ChessPad extends Panel implements MouseListener,ActionListener
{ int x=-1,y=-1, 棋子颜色=1; //控制棋子颜色的成员变量。
Button button=new Button("重新开局"); //控制重新开局的按扭。
TextField text_1=new TextField("请黑棋下子"),
text_2=new TextField(); //提示下棋的两个文本框。
ChessPad()
{setSize(440,440);
setLayout(null);setBackground(Color.pink);
addMouseListener(this);add(button);button.setBounds(10,5,60,26);
button.addActionListener(this);
add(text_1);text_1.setBounds(90,5,90,24);
add(text_2);text_2.setBounds(290,5,90,24);
text_1.setEditable(false);text_2.setEditable(false);
}
public void paint(Graphics g) //绘制围棋棋盘的外观。
{for(int i=40;i=380;i=i+20)
{g.drawLine(40,i,400,i);}
g.drawLine(40,400,400,400);
for(int j=40;j=380;j=j+20)
{g.drawLine(j,40,j,400);}
g.drawLine(400,40,400,400);
g.fillOval(97,97,6,6); g.fillOval(337,97,6,6);
g.fillOval(97,337,6,6);g.fillOval(337,337,6,6);
g.fillOval(217,217,6,6);
}
public void mousePressed(MouseEvent e) //当按下鼠标左键时下棋子。
{ if(e.getModifiers()==InputEvent.BUTTON1_MASK)
{ x=(int)e.getX();y=(int)e.getY(); //获取按下鼠标时的坐标位置。
ChessPoint_black chesspoint_black=new ChessPoint_black(this);
ChessPoint_white chesspoint_white=new ChessPoint_white(this);
int a=(x+10)/20,b=(y+10)/20;
if(x/202||y/202||x/2019||y/2019) //棋盘以外不下棋子。
{}
else{ if(棋子颜色==1) //当棋子颜色是1时下黑棋子。
{this.add(chesspoint_black);
chesspoint_black.setBounds(a*20-7,b*20-7,16,16);
棋子颜色=棋子颜色*(-1);
text_2.setText("请白棋下子");
text_1.setText("");
}
else if(棋子颜色==-1) //当棋子颜色是-1时下白棋子。
{this.add(chesspoint_white);
chesspoint_white.setBounds(a*20-7,b*20-7,16,16);
棋子颜色=棋子颜色*(-1);
text_1.setText("请黑棋下子");
text_2.setText("");
}
}
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e){}
public void actionPerformed(ActionEvent e)
{this.removeAll();棋子颜色=1;
add(button);button.setBounds(10,5,60,26);
add(text_1);text_1.setBounds(90,5,90,24);
text_2.setText("");text_1.setText("请黑棋下子");
add(text_2);text_2.setBounds(290,5,90,24);
}
}
//负责创建黑色棋子的类:
class ChessPoint_black extends Canvas implements MouseListener
{ ChessPad chesspad=null; //棋子所在的棋盘。
ChessPoint_black(ChessPad p)
{setSize(20,20);chesspad=p; addMouseListener(this);
}
public void paint(Graphics g) //绘制棋子的大小。
{ g.setColor(Color.black);g.fillOval(0,0,14,14);
}
public void mousePressed(MouseEvent e)
{ if(e.getModifiers()==InputEvent.BUTTON3_MASK)
{chesspad.remove(this);//当用鼠标右键点击棋子时,从棋盘中去掉该棋子(悔棋)。
chesspad.棋子颜色=1;
chesspad.text_2.setText("");chesspad.text_1.setText("请黑棋下子");
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e)
{ if(e.getClickCount()=2)
chesspad.remove(this); //当用左键双击该棋子时,吃掉该棋子。
}
}
//负责创建白色棋子的类:
class ChessPoint_white extends Canvas implements MouseListener
{
ChessPad chesspad=null;
ChessPoint_white(ChessPad p)
{setSize(20,20);addMouseListener(this);
chesspad=p;
}
public void paint(Graphics g)
{ g.setColor(Color.white);g.fillOval(0,0,14,14);
}
public void mousePressed(MouseEvent e)
{ if(e.getModifiers()==InputEvent.BUTTON3_MASK)
{chesspad.remove(this);chesspad.棋子颜色=-1;
chesspad.text_2.setText("请白棋下子"); chesspad.text_1.setText("");
}
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mouseClicked(MouseEvent e)
{if(e.getClickCount()=2)
chesspad.remove(this);
}
}
public class Chess extends Frame //添加棋盘的窗口。
{ChessPad chesspad=new ChessPad();
Chess()
{setSize(600,600);
setVisible(true);
setLayout(null);
Label label=
new Label("单击下棋子,双击吃棋子,右击棋子悔棋",Label.CENTER);
add(label);label.setBounds(70,55,440,26);
label.setBackground(Color.orange);
add(chesspad);chesspad.setBounds(70,90,440,440);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e){System.exit(0);}
});
}
public static void main(String args[])
{ Chess chess=new Chess();
}
}
这种题自己写吧,题里状态定义个变量,然后判断邻点这些都是方法,然后题里面if要怎么用都给你说清楚了 题了有如果的地方就是一个if语句然后跟着题里的如果把条件写完了 结果也出来了
围棋有几种变化是一个老问题了,比较粗浅的说法是3的19乘19次方,意思就是棋盘上每个点有空、黑、白三种状态,总共有19*19个点,所以得出这个结果。但实际上并没有那么多,因为在那么多状态中,有很大一部分是不可能出现的状态,也就是盘面上有死棋的状态。比如整个棋盘上布满棋子的状态都是不可能的,而这种状态就有2的19*19次方之多。?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /
密码:exn4
按围棋规则编写算法计算每颗棋子的气,可以根据棋盘经纬度及周边棋子的个数来判断;
按围棋规则连成片的棋子共享所有的气,将连成片的棋子定义为一个棋子组的对象,以该片棋子经纬度最小的那个棋子做为该对象的唯一标记,在每颗棋子落子的时候,就会发生棋子组属性变化,包括棋子组的合并,棋子组气数的变化等各类情况;
为了方便发现每次落子会影响到的棋子组,可以将每个棋子组的气点经纬度做为索引,该索引也需要随着棋子组的变化而变化;
按围棋规则气数等于0的棋子组为死棋,当每颗棋子落子后,更新所有棋子组的信息后,遍历将所有气数为0的棋子组从棋盘移除。考虑到“打劫”规则,一方落子后,先判断对方死棋,再判断己方死棋,符合“打劫”情况还需要额外记录次数,防止棋盘陷入僵局;