test.java

来自「九宫问题(八数码)的一个小软件」· Java 代码 · 共 63 行

JAVA
63
字号
/*
 * Test.java
 *
 * Created on February 12, 2006, 7:24 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.ray.ninegrid;

/**
 *
 * @author Ray#
 */
public class Test {
    
    /** Creates a new instance of Test */
    public Test() {
    }
    
    public static void main(String[] args){
        //int[] temp=new int[]{1,2,3,4,5,0,7,8,6,6};
        int[] temp=new int[]{1,2,3,4,0,5,7,8,6,5};
        System.out.println("Simple test:");
        test1(temp);
        test2(temp);
        test3(temp);
        temp=new int[]{3,6,0,2,5,8,1,4,7,3};
        System.out.println("Middle test:");
        test1(temp);
        test2(temp);
        test3(temp);
        temp=new int[]{6,4,7,8,5,0,3,2,1,6};
        System.out.println("Hard test:");
        test1(temp);
        test2(temp);
        test3(temp);
    }
    
    public static void test1(int[] t){
        long cur=System.currentTimeMillis();
        EightBFS ebfs=EightBFS.getInstance(t);
        System.out.println(ebfs.search());
        System.out.println("BFS - time : "+(System.currentTimeMillis()-cur)+"\n");
    }
    
    public static void test2(int[] t){
        long cur=System.currentTimeMillis();
        EightDTBFS ebfs=EightDTBFS.getInstance(t);
        System.out.println(ebfs.search());
        System.out.println("DTBFS - time : "+(System.currentTimeMillis()-cur)+"\n");
    }
    
    public static void test3(int[] t){
        long cur=System.currentTimeMillis();
        EightAStar ebfs=EightAStar.getInstance(t);
        System.out.println(ebfs.search());
        System.out.println("A*Search - time : "+(System.currentTimeMillis()-cur)+"\n");
    }
    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?