commit 7a9418e7504739b2182166a120e6b0ad56d06fa4 Author: Trevor Maze Date: Tue Mar 31 09:59:05 2026 -0400 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0023a53 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..ddbb6c6 --- /dev/null +++ b/Package.swift @@ -0,0 +1,15 @@ +// swift-tools-version: 6.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "A-Star", + targets: [ + // Targets are the basic building blocks of a package, defining a module or a test suite. + // Targets can depend on other targets in this package and products from dependencies. + .executableTarget( + name: "A-Star" + ), + ] +) diff --git a/Sources/A-Star/A_Star.swift b/Sources/A-Star/A_Star.swift new file mode 100644 index 0000000..a64af39 --- /dev/null +++ b/Sources/A-Star/A_Star.swift @@ -0,0 +1,45 @@ +@main +struct A_Star { + static func main() { + print("Hello, world!") + } + + func A_Star(start: Vector2, goal: Vector2) { + var openSet: [Vector2] = [start] + + var cameFrom: Dictionary = [:] + + var gScore: Dictionary = [:] + gScore[start] = 0 + + var fScore: Dictionary = [:] + fScore[start] = h(start) + + while openSet.count != 0 { + var current: Vector2 = getLowest(openSet) + } + } + + func h(_: Vector2) -> Int { + return 0 + } + + func getLowest(_: [Vector2]) -> Vector2 { + for + } +} + +struct Vector2: Hashable { + var x: Int + var y: Int + + static func == (lhs: Vector2, rhs: Vector2) -> Bool { + return lhs.x == rhs.x && lhs.y == rhs.y + } + + func hash(into hasher: inout Hasher) { + hasher.combine(x) + hasher.combine(y) + } +} +