资源简介
用Java做的骑士游历小游戏,需要的可以下载下来看看学学!
代码片段和文件信息
package gao;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.image.*;
public class KnightsTour extends Japplet {
public static int access[][] = {
{23444432}
{34666643}
{46888864}
{46888864}
{46888864}
{46888864}
{34666643}
{23444432}};
public static int accessbak[][] = arrayCopy ( access ) ;
// the value indicate the No.value moving
int countMoving = -1 ;
int tourXpos [] = new int [ 64 ];
int tourYpos [] = new int [ 64 ];
private int recordXpos [][];
private int recordYpos [][];
private int recordCount = - 1 ;
private int startx ;
private int starty ;
private boolean success = false;
MyPanel myPanel ;
public void tour ( int xpos int ypos ){
// int xy;
countMoving ++ ;
//all the 64 squares has been touch return
if (countMoving == 63 )
{
tourXpos [ countMoving ] = xpos ;
tourYpos [ countMoving ] = ypos ;
// if ( ( ( Math.abs( xpos -startx ) == 1) & ( Math.abs ( ypos - starty ) ==2 ) ) |
// ( ( Math.abs( xpos -startx ) == 2) & ( Math.abs ( ypos - starty ) ==1 ) ) )
success = true ;
countMoving -- ;
return ;
}
AccessibleSquares nextSquare = new AccessibleSquares( xpos ypos );
while (nextSquare.hasMoreAccessible())
{
// do moving
nextSquare.domoving();
//record this moving
tourXpos [ countMoving ] = xpos ;
tourYpos [ countMoving ] = ypos ;
// try the next moving
nextSquare.nextAccessible();
tour ( nextSquare.getXpos() nextSquare.getYpos() );
//all the 64 squares has been touch return
if ( success )
{
countMoving -- ;
return ;
}
//this moving try is a faillure pick it up from the chess board
nextSquare.undomoving();
}// end of while
countMoving -- ;
}//end of tour method
public static int[] arrayCopy ( int array1[] )
{
int[]array2 = new int [array1.length];
for ( int row = 0 ; row < array1.length ; row ++ )
{
array2 [ row ] = array1 [ row ] ;
};
return array2;
}
public static int[][] arrayCopy ( int array1[][] )
{
int[][] array2 = new int [array1.length][array1[0].length];
for ( int row = 0 ; row < array1.length ; row ++ )
{
for ( int column = 0 ; column < array1[0].length ; column ++ )
{
array2 [ row ][ column ] = array1 [ row ][ column ];
};
};
return array2;
}
public void initialArray ( int chessBoard[][] )
{
for ( int row = 0 ; row < 8 ; row ++ )
{
for ( int column = 0 ; column < 8 ; column ++ )
{
chessBoard [ row ][ column ] = 0 ;
};
};
}
/* public static void main( String args[] ) {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
...D.H. 0 2003-04-27 15:43 案例一
.....H. 970 2004-04-27 13:46 案例一\bknight.jpg
.....H. 749 2004-04-27 13:46 案例一\black.jpg
.....H. 4155 2004-04-27 13:46 案例一\knighttour.jpx
..A..H. 2008 2009-10-14 14:28 案例一\knighttour.jpx.local
.....H. 1886 2004-04-27 13:46 案例一\knighttour.jpx.local~
.....H. 0 2004-04-27 13:46 案例一\knighttour.jpx~
.....H. 761 2004-04-27 13:46 案例一\white.jpg
.....H. 959 2004-04-27 13:46 案例一\wknight.jpg
...D.H. 0 2003-04-27 15:43 案例一\src
...D.H. 0 2003-04-27 15:43 案例一\src\gao
.....H. 11515 2004-04-27 13:46 案例一\src\gao\KnightsTour.java
.....H. 6377 2004-04-27 13:46 案例一\src\gao\KnightsTour.java~1~
.....H. 970 2004-04-27 13:46 案例一\src\gao\bknight.jpg
.....H. 749 2004-04-27 13:46 案例一\src\gao\black.jpg
.....H. 761 2004-04-27 13:46 案例一\src\gao\white.jpg
.....H. 959 2004-04-27 13:46 案例一\src\gao\wknight.jpg
...D.H. 0 2003-04-27 15:43 案例一\classes
...D.H. 0 2003-04-27 15:43 案例一\classes\package cache
..A..H. 2992 2009-10-14 14:27 案例一\classes\package cache\gao.dep2
...D.H. 0 2003-04-27 15:43 案例一\classes\gao
..A..H. 2596 2009-10-14 14:27 案例一\classes\gao\AccessibleSquares.class
..A..H. 711 2009-10-14 14:27 案例一\classes\gao\KnightsTour$1.class
..A..H. 1049 2009-10-14 14:27 案例一\classes\gao\KnightsTour$2.class
..A..H. 4101 2009-10-14 14:27 案例一\classes\gao\KnightsTour.class
..A..H. 2593 2009-10-14 14:27 案例一\classes\gao\MyPanel.class
.....H. 970 2004-04-27 13:46 案例一\classes\gao\bknight.jpg
.....H. 749 2004-04-27 13:46 案例一\classes\gao\black.jpg
.....H. 761 2004-04-27 13:46 案例一\classes\gao\white.jpg
.....H. 959 2004-04-27 13:46 案例一\classes\gao\wknight.jpg
............此处省略18个文件信息
- 上一篇:jxl.jar
- 下一篇:java龟兔赛跑源代码
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
川公网安备 51152502000135号
评论
共有 条评论