Пример #1
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	state, err := sixstair.ReadState()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	goal := sixstair.SolveGoal{}
	for moves := 0; ; moves++ {
		fmt.Println("Trying", moves, "moves...")
		solution := sixstair.Search(state, goal, moves)
		if solution != nil {
			// We're done
			fmt.Println("Found solution:", solution, "("+
				strconv.Itoa(len(solution)), "moves)")
			return
		}
	}
}
Пример #2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	state, err := sixstair.ReadState()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	for progress := 1; progress < 22; progress++ {
		fmt.Print("Doing ", progress, " ... ")
		goal := sixstair.BackStepGoal(progress)
		opt := sixstair.DistOptimal(state, goal, 12)
		if opt == nil {
			fmt.Println("Failed. No solution <= 12 moves.")
			return
		}
		fmt.Println(opt)
		applyMoves(state, opt)
	}
}