From aac9d8a9fca9bcbbc482d569bf0116b2c5fb2aa6 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Wed, 7 Jun 2023 16:03:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=80=E4=B8=AA=E5=AE=BD?= =?UTF-8?q?=E9=AB=98=E5=8F=AF=E8=A1=A8=E8=BE=BE=E7=9A=84=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=89=B9=E5=AE=9A=E5=B0=BA=E5=AF=B8=E4=BB=A5=E4=B8=8A=E7=9A=84?= =?UTF-8?q?=E7=9F=A9=E5=BD=A2=E5=BD=A2=E7=8A=B6bug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/g2d/shape.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/utils/g2d/shape.go b/utils/g2d/shape.go index 9c33f09..948029b 100644 --- a/utils/g2d/shape.go +++ b/utils/g2d/shape.go @@ -1,6 +1,7 @@ package g2d import ( + "fmt" "github.com/kercylan98/minotaur/utils/g2d/shape" "sort" ) @@ -529,6 +530,10 @@ func SearchNotRepeatFullRectangle(minWidth, minHeight int, xys ...[2]int) (resul for _, point := range points { px, py := PositionArrayToXY(point) ox, oy := px+x, py+y + if ox >= len(rectangleShape) || oy >= len(rectangleShape[0]) { + rectangleShape := GenerateShape(xys...) + fmt.Println(rectangleShape) + } if record[ox][oy] || !rectangleShape[ox][oy] { find = 0 break @@ -584,6 +589,7 @@ func GetExpressibleRectangle(width, height int) (result [][2]int) { // - 返回值表示了每一个矩形右下角的x,y位置(左上角始终为0, 0) // - 矩形尺寸由大到小 func GetExpressibleRectangleBySize(width, height, minWidth, minHeight int) (result [][2]int) { + sourceWidth := width if width == 0 || height == 0 { return nil } @@ -601,8 +607,12 @@ func GetExpressibleRectangleBySize(width, height, minWidth, minHeight int) (resu if width == height { width-- } else if width < height { - width++ - height-- + if width+1 == sourceWidth { + height-- + } else { + width++ + height-- + } } else if width > height { width-- }