本文整理汇总了Golang中github.com/edgarweto/puzzlopia/puzzle-solvers/finder.SbpBfsFinder类的典型用法代码示例。如果您正苦于以下问题:Golang SbpBfsFinder类的具体用法?Golang SbpBfsFinder怎么用?Golang SbpBfsFinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SbpBfsFinder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CheckRedditQuest4hj6nb
// Result: 123
// Should be:
func CheckRedditQuest4hj6nb() {
// Define the game
var myPuzzle = &games.SBGame{}
// From reddit https://www.reddit.com/r/puzzles/comments/4hj6nb/has_anyone_any_info_on_this_sliding_tile_puzzle/
myPuzzle.Define(&grids.Matrix2d{
[]int{0, 1, 1, 0},
[]int{2, 1, 1, 4},
[]int{2, 7, 9, 4},
[]int{3, 8, 10, 5},
[]int{3, 6, 6, 5},
})
myPuzzle.AutoAlikePieces()
// Check the puzzle is well created, and let it build its internals
myPuzzle.Build()
// Params for finder/solver
const (
// Max depth reached by finder/solver
MAX_DEPTH = 200
// Max number of states to be processed. If 0, then ignored.
// Can be combined with MAX_DEPTH: if either of these two values is exceeded, the algorithm stops.
//MAX_STATES = 4999999
MAX_STATES = 1999999
// (Experimental),Used internally to force the algorithm to revisit some states
// Actually, disabling it makes Pennant to be solved with non-optimal path.
HARD_OPTIMAL = true
// Used for tests: enables/disables console output
SILENT_MODE = false
// Enables/disables debug options (console output, etc.)
DEBUG = false
)
// FINDER ---------------------
var sbpFinder finder.SbpBfsFinder
sbpFinder.SilentMode(SILENT_MODE)
sbpFinder.SetDebug(DEBUG)
sbpFinder.SetLimits(MAX_DEPTH, MAX_STATES)
sbpFinder.SetHardOptimal(HARD_OPTIMAL)
// // BrokenPennant
sbpFinder.Detect(&grids.Matrix2d{
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 1, 1, 0},
[]int{0, 1, 1, 0},
})
sbpFinder.SolvePuzzle(myPuzzle)
found, solutionLen, _ := sbpFinder.GetResult()
if !found {
fmt.Println("P_4hj6nb not solved!")
}
if solutionLen != 123 {
fmt.Printf("P_4hj6nb solution not optimal: found len = %d\n\n", solutionLen)
}
}
开发者ID:puzzlopia,项目名称:puzzle-solvers,代码行数:71,代码来源:checkRedditQuest4hj6nb.go
示例2: TestEquivalence
func TestEquivalence(t *testing.T) {
var myPuzzle = &games.SBGame{}
// Pennant
myPuzzle.Define(&grids.Matrix2d{
[]int{2, 2, 1, 1},
[]int{2, 2, 3, 3},
[]int{5, 4, 0, 0},
[]int{6, 7, 8, 8},
[]int{6, 7, 9, 9},
})
myPuzzle.AutoAlikePieces()
//myPuzzle.SetNotAlikePiece(5)
// Check the puzzle is well created, and let it build its internals
myPuzzle.Build()
const (
// Max depth reached by finder/solver
MAX_DEPTH = 83
// Max number of states to be processed. If 0, then ignored.
// Can be combined with MAX_DEPTH: if either of these two values is exceeded, the algorithm stops.
MAX_STATES = 0
// (Experimental) Used internally to force the algorithm to revisit some states
// Actually, disabling it makes Pennant to be solved with non-optimal path.
HARD_OPTIMAL = true
// Used for tests: enables/disables console output
SILENT_MODE = true
// Enables/disables debug options (console output, etc.)
DEBUG = false
)
// FINDER ---------------------
var sbpFinder finder.SbpBfsFinder
sbpFinder.SilentMode(SILENT_MODE)
sbpFinder.SetDebug(DEBUG)
sbpFinder.SetLimits(MAX_DEPTH, MAX_STATES)
sbpFinder.SetHardOptimal(HARD_OPTIMAL)
// Pennant
sbpFinder.Detect(&grids.Matrix2d{
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{2, 2, 0, 0},
[]int{2, 2, 0, 0},
})
sbpFinder.SolvePuzzle(myPuzzle)
found, solutionLen, duration := sbpFinder.GetResult()
if !found {
t.Errorf("Pennant not solved!")
}
if solutionLen != 59 {
t.Errorf("Pennant solution not optimal: found len = %d", solutionLen)
}
if duration.Seconds() > 0.1 {
t.Errorf("Should solve in less than 0.1 seconds. Current: %v", duration)
}
}
开发者ID:puzzlopia,项目名称:puzzle-solvers,代码行数:70,代码来源:pennant_test.go
示例3: CheckChrisEye
// Result: 52
// Should be: 52
func CheckChrisEye() {
// Define the game
var myPuzzle = &games.SBGame{}
// SuperCompo
myPuzzle.Define(&grids.Matrix2d{
[]int{0, 2, 2, 0},
[]int{3, 7, 8, 4},
[]int{3, 1, 1, 4},
[]int{9, 1, 1, 10},
[]int{5, 5, 6, 6},
})
myPuzzle.AutoAlikePieces()
// Check the puzzle is well created, and let it build its internals
myPuzzle.Build()
// Params for finder/solver
const (
// Max depth reached by finder/solver
MAX_DEPTH = 200
// Max number of states to be processed. If 0, then ignored.
// Can be combined with MAX_DEPTH: if either of these two values is exceeded, the algorithm stops.
//MAX_STATES = 4525252
MAX_STATES = 250000
// (Experimental),Used internally to force the algorithm to revisit some states
// Actually, disabling it makes Pennant to be solved with non-optimal path.
HARD_OPTIMAL = true
// Used for tests: enables/disables console output
SILENT_MODE = false
// Enables/disables debug options (console output, etc.)
DEBUG = false
)
// FINDER ---------------------
var sbpFinder finder.SbpBfsFinder
sbpFinder.SilentMode(SILENT_MODE)
sbpFinder.SetDebug(DEBUG)
sbpFinder.SetLimits(MAX_DEPTH, MAX_STATES)
sbpFinder.SetHardOptimal(HARD_OPTIMAL)
// Objective
sbpFinder.Detect(&grids.Matrix2d{
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 1, 1, 0},
[]int{0, 1, 1, 0},
})
sbpFinder.SolvePuzzle(myPuzzle)
found, solutionLen, _ := sbpFinder.GetResult()
if !found {
fmt.Println("Chris-Eye not solved!")
}
if solutionLen != 52 {
fmt.Printf("Chris-Eye solution not optimal: found len = %d\n\n", solutionLen)
}
}
开发者ID:puzzlopia,项目名称:puzzle-solvers,代码行数:71,代码来源:checkChrisEye.go
示例4: doingTests
//.........这里部分代码省略.........
// myPuzzle.AlikePieces([][]int{
// []int{1, 2, 3, 4},
// []int{7, 8},
// []int{5, 6, 9, 12},
// []int{10, 11},
// })
// Check the puzzle is well created, and let it build its internals
myPuzzle.Build()
// Params for finder/solver
const (
// Max depth reached by finder/solver
MAX_DEPTH = 350
// Max number of states to be processed. If 0, then ignored.
// Can be combined with MAX_DEPTH: if either of these two values is exceeded, the algorithm stops.
//MAX_STATES = 4999999
MAX_STATES = 1999999
// (Experimental),Used internally to force the algorithm to revisit some states
// Actually, disabling it makes Pennant to be solved with non-optimal path.
HARD_OPTIMAL = true
// Used for tests: enables/disables console output
SILENT_MODE = false
// Enables/disables debug options (console output, etc.)
DEBUG = false
)
// FINDER ---------------------
var sbpFinder finder.SbpBfsFinder
sbpFinder.SilentMode(SILENT_MODE)
sbpFinder.SetDebug(DEBUG)
sbpFinder.SetLimits(MAX_DEPTH, MAX_STATES)
sbpFinder.SetHardOptimal(HARD_OPTIMAL)
// // BrokenPennant
sbpFinder.Detect(&grids.Matrix2d{
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 0, 0, 0},
[]int{0, 10, 10, 0},
[]int{0, 10, 10, 0},
})
// sbpFinder.DebugPath([][]int{
// []int{9, -1, 0},
// []int{2, -1, 0},
// []int{7, -1, 0},
// []int{5, 0, -1},
// []int{8, 0, -1},
// []int{6, 1, 0},
// []int{10, 1, 0},
// []int{1, 0, 1},
// []int{9, 0, 1},
// []int{2, -1, 0},
// []int{3, 0, -1},
// []int{10, 0, -1},
// []int{6, -1, 0},
// []int{8, 0, 1},
// []int{5, 0, 1},
开发者ID:puzzlopia,项目名称:puzzle-solvers,代码行数:67,代码来源:developing.go
注:本文中的github.com/edgarweto/puzzlopia/puzzle-solvers/finder.SbpBfsFinder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论