From 261b14e789103b0342592c4977fe7239fdc486ad Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 19 Jun 2023 11:37:09 +0800 Subject: [PATCH] =?UTF-8?q?:boom:=20=E7=A7=BB=E9=99=A4g2d=E5=8C=85?= =?UTF-8?q?=EF=BC=8C=E5=90=88=E5=B9=B6=E5=88=B0geometry=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- planner/configexport/internal/config.go | 2 +- utils/g2d/physics.go | 42 ------------------- .../dp/distribution_pattern.go | 0 .../dp/distribution_pattern_test.go | 0 utils/{g2d => geometry}/dp/link.go | 0 utils/{g2d => geometry}/matrix/matrix.go | 0 utils/{g2d => geometry}/path/heap.go | 0 utils/{g2d => geometry}/path/landform.go | 0 .../path/landform_feature.go | 0 utils/{g2d => geometry}/path/node.go | 0 utils/{g2d => geometry}/path/path.go | 0 utils/{g2d => geometry}/path/terrain.go | 0 utils/xlsxtool/sheet.go | 2 +- 13 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 utils/g2d/physics.go rename utils/{g2d => geometry}/dp/distribution_pattern.go (100%) rename utils/{g2d => geometry}/dp/distribution_pattern_test.go (100%) rename utils/{g2d => geometry}/dp/link.go (100%) rename utils/{g2d => geometry}/matrix/matrix.go (100%) rename utils/{g2d => geometry}/path/heap.go (100%) rename utils/{g2d => geometry}/path/landform.go (100%) rename utils/{g2d => geometry}/path/landform_feature.go (100%) rename utils/{g2d => geometry}/path/node.go (100%) rename utils/{g2d => geometry}/path/path.go (100%) rename utils/{g2d => geometry}/path/terrain.go (100%) diff --git a/planner/configexport/internal/config.go b/planner/configexport/internal/config.go index ab3e02d..26f198e 100644 --- a/planner/configexport/internal/config.go +++ b/planner/configexport/internal/config.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" jsonIter "github.com/json-iterator/go" - "github.com/kercylan98/minotaur/utils/g2d/matrix" + "github.com/kercylan98/minotaur/utils/geometry/matrix" "github.com/kercylan98/minotaur/utils/str" "github.com/kercylan98/minotaur/utils/xlsxtool" "github.com/tealeg/xlsx" diff --git a/utils/g2d/physics.go b/utils/g2d/physics.go deleted file mode 100644 index 47754f1..0000000 --- a/utils/g2d/physics.go +++ /dev/null @@ -1,42 +0,0 @@ -package g2d - -// SlideDrop 侧滑掉落特定位置成员 -func SlideDrop[T any](matrix [][]T, x, y int, isStop func(start T, x, y int, data T) bool) (dropX, dropY int) { - width, height := len(matrix), len(matrix[0]) - start := matrix[x][y] - var offsetX, offsetY = -1, 1 - for { - targetX, targetY := x+offsetX, y+offsetY - if targetX < 0 || targetY == height || isStop(start, targetX, targetY, matrix[targetX][targetY]) { - dropX, dropY = targetX+1, targetY-1 - break - } - offsetX-- - offsetY++ - } - offsetX, offsetY = 1, 1 - for dropX != x && dropY != y { - targetX, targetY := x+offsetX, y+offsetY - if targetX == width || targetY == height || isStop(start, targetX, targetY, matrix[targetX][targetY]) { - dropX, dropY = targetX-1, targetY-1 - break - } - offsetX++ - offsetY++ - } - return -} - -// VerticalDrop 垂直掉落特定位置成员 -func VerticalDrop[T any](matrix [][]T, x, y int, isStop func(start T, x, y int, data T) bool) (dropX, dropY int) { - height := len(matrix[0]) - start := matrix[x][y] - var offsetY = 1 - for { - testY := y + offsetY - if testY == height || isStop(start, x, testY, matrix[x][testY]) { - return x, testY - 1 - } - offsetY++ - } -} diff --git a/utils/g2d/dp/distribution_pattern.go b/utils/geometry/dp/distribution_pattern.go similarity index 100% rename from utils/g2d/dp/distribution_pattern.go rename to utils/geometry/dp/distribution_pattern.go diff --git a/utils/g2d/dp/distribution_pattern_test.go b/utils/geometry/dp/distribution_pattern_test.go similarity index 100% rename from utils/g2d/dp/distribution_pattern_test.go rename to utils/geometry/dp/distribution_pattern_test.go diff --git a/utils/g2d/dp/link.go b/utils/geometry/dp/link.go similarity index 100% rename from utils/g2d/dp/link.go rename to utils/geometry/dp/link.go diff --git a/utils/g2d/matrix/matrix.go b/utils/geometry/matrix/matrix.go similarity index 100% rename from utils/g2d/matrix/matrix.go rename to utils/geometry/matrix/matrix.go diff --git a/utils/g2d/path/heap.go b/utils/geometry/path/heap.go similarity index 100% rename from utils/g2d/path/heap.go rename to utils/geometry/path/heap.go diff --git a/utils/g2d/path/landform.go b/utils/geometry/path/landform.go similarity index 100% rename from utils/g2d/path/landform.go rename to utils/geometry/path/landform.go diff --git a/utils/g2d/path/landform_feature.go b/utils/geometry/path/landform_feature.go similarity index 100% rename from utils/g2d/path/landform_feature.go rename to utils/geometry/path/landform_feature.go diff --git a/utils/g2d/path/node.go b/utils/geometry/path/node.go similarity index 100% rename from utils/g2d/path/node.go rename to utils/geometry/path/node.go diff --git a/utils/g2d/path/path.go b/utils/geometry/path/path.go similarity index 100% rename from utils/g2d/path/path.go rename to utils/geometry/path/path.go diff --git a/utils/g2d/path/terrain.go b/utils/geometry/path/terrain.go similarity index 100% rename from utils/g2d/path/terrain.go rename to utils/geometry/path/terrain.go diff --git a/utils/xlsxtool/sheet.go b/utils/xlsxtool/sheet.go index 9c89c36..b9216e2 100644 --- a/utils/xlsxtool/sheet.go +++ b/utils/xlsxtool/sheet.go @@ -1,7 +1,7 @@ package xlsxtool import ( - "github.com/kercylan98/minotaur/utils/g2d/matrix" + "github.com/kercylan98/minotaur/utils/geometry/matrix" "github.com/tealeg/xlsx" )