支持为形状添加标记
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
package g2d
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kercylan98/minotaur/utils/g2d/shape"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMatrixShape(t *testing.T) {
|
||||
var m = [][]int{
|
||||
{1, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{1, 1, 1, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 1, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 1, 1, 1, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 1, 0, 0, 0, 0, 0, 0, 0},
|
||||
{0, 1, 1, 1, 0, 0, 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
}
|
||||
s := shape.NewShape()
|
||||
s.AddPoints(shape.NewPointWithArrays([][2]int{{0, 0}, {0, 1}, {1, 1}, {2, 1}}...)...)
|
||||
fmt.Println(s)
|
||||
result := MatrixShapeSearchWithYX(m, []*shape.Shape{s}, func(val int) bool {
|
||||
return val == 1
|
||||
})
|
||||
fmt.Println(len(result))
|
||||
}
|
||||
Reference in New Issue
Block a user