資源簡介
自己用Java編制的黑白棋,和文曲星上面的黑白棋規則一樣,分初級、中級、高級三個等級,不同等級除了對手棋力不同棋盤樣式也不同。將文曲星上黑白棋三個等級的算法做了適當改進在計算機上通過程序實現,算法主要用到奇偶性原理和一些邊角判定,下棋時需要想辦法搶占4個頂角,另外邊上連4也具有強大的優勢。編程實現對于我來說并不難,但程序設計得比較復雜,初級算法寫了700多行,中級和高級算法寫了2000多行,中級和高級算法具有向后推幾步棋的功能,涉及到一些遞歸算法,用函數實現遞歸,中級水平最多遞歸2次,高級水平最多遞歸7次。此外文曲星上黑白棋高級水平的對手有些步棋下得比較慢,該程序在這方面也做了改進,對手下棋所
代碼片段和文件信息
package?othello.cy;
import?java.util.*;
/**
?*?黑白棋基礎算法
?*?
?*?@author?cy
?*
?*/
public?class?baseAlgorithm?{
protected?final?int?chessboard_size?=?8;
protected?int?id;
protected?int[][]?last_status?=?new?int[chessboard_size][chessboard_size];?//?落子之前棋盤的狀態
protected?MyPoint?last_step;?//?上一步對手落子位置
protected?linkedList?legalPoints?=?new?linkedList();?//?當前計算機所有能落子的位置
protected?int[][]?values?=?new?int[chessboard_size][chessboard_size];?//?各點權值
protected?linkedList?maxPoints?=?new?linkedList();?//?權值最大的所有位置
protected?int?count;
public?baseAlgorithm(int?id?int[][]?last_status?MyPoint?last_step
linkedList?legalPoints?int?count)?{
this.id?=?id;
this.last_status?=?last_status;
this.last_step?=?last_ste
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????301??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\.classpath
?????文件????????385??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\.project
?????文件????????598??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\.settings\org.eclipse.jdt.core.prefs
?????文件??????27478??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\ba
?????文件??????15424??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\BeginnerAlgorithm.class
?????文件??????45268??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\ExpertAlgorithm.class
?????文件??????39076??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\IntermediateAlgorithm.class
?????文件???????2210??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\Mainfr
?????文件???????8920??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\Mainfr
?????文件????????681??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\MyPoint.class
?????文件????????430??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\Othello.class
?????文件???????2196??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\bin\othello\cy\Settingfr
?????文件?????????99??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?1\0.gif
?????文件????????123??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?1\1.gif
?????文件????????141??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?1\2.gif
?????文件?????????99??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?2\0.gif
?????文件????????123??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?2\1.gif
?????文件????????141??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?2\2.gif
?????文件?????????99??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?3\0.gif
?????文件????????123??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?3\1.gif
?????文件????????141??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\img\Level?3\2.gif
?????文件??????58034??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\ba
?????文件??????32197??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\BeginnerAlgorithm.java
?????文件?????102329??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\ExpertAlgorithm.java
?????文件??????88540??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\IntermediateAlgorithm.java
?????文件??????10150??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\Mainfr
?????文件????????340??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\MyPoint.java
?????文件????????162??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\Othello.java
?????文件???????1869??2016-10-01?12:56??黑白棋自制版V1.0\MyOthello\src\othello\cy\Settingfr
?????目錄??????????0??2016-10-01?14:13??黑白棋自制版V1.0\MyOthello\bin\othello\cy
............此處省略15個文件信息
評論
共有 條評論