五子棋项目结束总结_五子棋总结

BufferedImage image = null;

try {

image = ImageIO.read(new File("E:/ve_eclipse/workspace/fivechess/src/image/chesstable1.jpg"));

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

g.drawImage(image, 0, 50, this);

界面最小化后再开启会变成新界面:重绘

利用chesses[][]存储的落子情况重绘

悔棋功能:

新建类Node 存储每个落子点的坐标和棋子颜色

List nodeList = new ArrayList(); 存储落子顺序

悔棋时Node java.util.List.remove(int index)函数

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list

复盘功能:按照落子顺序重新下一遍。

关键是重绘和暂停。

重绘按钮的事件监听器:

jBut4.addActionListener(new ActionListener(){

/* (non-Javadoc)

* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)

*/

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

clearchesses();

blnstate = false;

javax.swing.SwingUtilities.updateComponentTreeUI(fcUI);

}

});

重绘和暂停:

if(!blnstate){

noderepaint(g);//根据nodelist重绘

}

myrepaint(g);//根据chesses[][]重绘

//根据落子顺序nodelist重绘

private void noderepaint(Graphics g){

for(int i = 0; i< nodeList.size(); i++){

Node node = nodeList.get(i);

chesses[node.getX()][node.getY()] = node.getColor();

myrepaint(g);

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

重新开始功能:清空chesses[][] 和nodelist

界面刷新:void javax.swing.SwingUtilities.updateComponentTreeUI(Component c)

A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel.

五子棋V3

五子棋智能算法:

思路一:搜索对手落子点周围3*8个点中空格的情况。(经观察各个威胁到己方的棋局,在落子点三个棋子之内的概率最大)计算每个空格周围3*8个方向上各个方向上的棋子情况。选择分值最高的落子。。。。。属于防守型。。。。。不能判断己方形势。

思路二:每个棋子的落下,都会对整个局势产生影响,这种影响在该子周围4*8个之内,并且距离落子点越近,影响越大。连子具有指数型叠加效应,其中,+*+*+具有连子的相同叠加效应。都失败了得说。。。。。

希望能够提示对手最新落子点。。。。还没去写

另外按钮的显示总是迟延。。。。

1

0

分享到:

2012-02-13 23:16

浏览 1197

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值