diff --git a/.vs/PathFinding/v17/.suo b/.vs/PathFinding/v17/.suo index a5741b3..d24c415 100644 Binary files a/.vs/PathFinding/v17/.suo and b/.vs/PathFinding/v17/.suo differ diff --git a/.vs/PathFinding/v17/Browse.VC.db b/.vs/PathFinding/v17/Browse.VC.db index ecd1374..62cc319 100644 Binary files a/.vs/PathFinding/v17/Browse.VC.db and b/.vs/PathFinding/v17/Browse.VC.db differ diff --git a/.vs/PathFinding/v17/DocumentLayout.json b/.vs/PathFinding/v17/DocumentLayout.json index 529c888..4c9273c 100644 --- a/.vs/PathFinding/v17/DocumentLayout.json +++ b/.vs/PathFinding/v17/DocumentLayout.json @@ -7,8 +7,8 @@ "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:PathFinding.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Node.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Node.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Pathfinding.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Pathfinding.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Maze.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", @@ -19,12 +19,12 @@ "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Maze.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Node.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Node.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Node.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Node.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Pathfinding.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Pathfinding.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Node.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{2E29F4AA-3298-430E-8DAE-7FDF9DCECC38}|PathFinding.vcxproj|solutionrelative:Node.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" } ], "DocumentGroupContainers": [ @@ -44,14 +44,14 @@ "RelativeDocumentMoniker": "PathFinding.cpp", "ToolTip": "C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\PathFinding.cpp", "RelativeToolTip": "PathFinding.cpp", - "ViewState": "AQIAAHgAAAAAAAAAAAAAAIAAAAAeAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAIAAAAAeAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-04-13T05:55:35.151Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 5, + "DocumentIndex": 1, "Title": "Pathfinding.h", "DocumentMoniker": "C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Pathfinding.h", "RelativeDocumentMoniker": "Pathfinding.h", @@ -70,7 +70,7 @@ "RelativeDocumentMoniker": "Maze.h", "ToolTip": "C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Maze.h", "RelativeToolTip": "Maze.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAAAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAyAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", "WhenOpened": "2024-04-13T06:19:48.736Z", "EditorCaption": "" @@ -83,14 +83,14 @@ "RelativeDocumentMoniker": "Maze.cpp", "ToolTip": "C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Maze.cpp", "RelativeToolTip": "Maze.cpp", - "ViewState": "AQIAABoAAAAAAAAAAAAAABwAAAALAAAA", + "ViewState": "AQIAACwAAAAAAAAAAAAAADoAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-04-13T06:20:09.473Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 4, + "DocumentIndex": 5, "Title": "Node.h", "DocumentMoniker": "C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Node.h", "RelativeDocumentMoniker": "Node.h", @@ -103,7 +103,7 @@ }, { "$type": "Document", - "DocumentIndex": 1, + "DocumentIndex": 4, "Title": "Node.cpp", "DocumentMoniker": "C:\\Users\\Agrim Budakoti\\Desktop\\Playground\\Cpp\\Projects\\PathFinding\\Node.cpp", "RelativeDocumentMoniker": "Node.cpp", diff --git a/.vs/PathFinding/v17/ipch/AutoPCH/4ff28bea261a0d70/MAZE.ipch b/.vs/PathFinding/v17/ipch/AutoPCH/4ff28bea261a0d70/MAZE.ipch index dbc57b7..aa36434 100644 Binary files a/.vs/PathFinding/v17/ipch/AutoPCH/4ff28bea261a0d70/MAZE.ipch and b/.vs/PathFinding/v17/ipch/AutoPCH/4ff28bea261a0d70/MAZE.ipch differ diff --git a/.vs/PathFinding/v17/ipch/AutoPCH/cde213dea2fc84df/PATHFINDING.ipch b/.vs/PathFinding/v17/ipch/AutoPCH/cde213dea2fc84df/PATHFINDING.ipch index da7cbfe..7fc233b 100644 Binary files a/.vs/PathFinding/v17/ipch/AutoPCH/cde213dea2fc84df/PATHFINDING.ipch and b/.vs/PathFinding/v17/ipch/AutoPCH/cde213dea2fc84df/PATHFINDING.ipch differ diff --git a/Maze.cpp b/Maze.cpp index 6b472d2..3c76f7f 100644 --- a/Maze.cpp +++ b/Maze.cpp @@ -54,4 +54,12 @@ std::array Maze::getNeighbours(Node* target) { right = grid[y][x + 1]; std::array result{ left, top, right, bottom }; return result; +} + +int ManhattanDistance(Node* point1, Node* point2) { + int x1 = point1->coords[0]; + int y1 = point1->coords[1]; + int x2 = point1->coords[0]; + int y2 = point1->coords[1]; + return std::abs(x1 - x2) + std::abs(y1 - y2); } \ No newline at end of file diff --git a/Maze.h b/Maze.h index 3b55aac..d0e4b2e 100644 --- a/Maze.h +++ b/Maze.h @@ -14,3 +14,4 @@ class Maze { std::array getNeighbours(Node* target); void display(); }; +int ManhattanDistance(Node* point1, Node* point2); \ No newline at end of file diff --git a/PathFinding.cpp b/PathFinding.cpp index 4551f92..1f299c6 100644 --- a/PathFinding.cpp +++ b/PathFinding.cpp @@ -120,10 +120,10 @@ int main(){ } static bool solve(Maze &maze, Node* &start, Node* &goal) { + // Breadth first search std::deque frontier; frontier.push_back(start); - int counter{ 0 }; while (true) { if (frontier.empty()) { std::cerr << "No solution\n"; diff --git a/PathFinding/x64/Debug/PathFinding.ilk b/PathFinding/x64/Debug/PathFinding.ilk index 1189a72..2e5a067 100644 Binary files a/PathFinding/x64/Debug/PathFinding.ilk and b/PathFinding/x64/Debug/PathFinding.ilk differ diff --git a/PathFinding/x64/Debug/PathFinding.tlog/PathFinding.write.1u.tlog b/PathFinding/x64/Debug/PathFinding.tlog/PathFinding.write.1u.tlog index 18637f7..8e553a5 100644 Binary files a/PathFinding/x64/Debug/PathFinding.tlog/PathFinding.write.1u.tlog and b/PathFinding/x64/Debug/PathFinding.tlog/PathFinding.write.1u.tlog differ diff --git a/PathFinding/x64/Debug/vc143.idb b/PathFinding/x64/Debug/vc143.idb index bf7288a..aadf4f6 100644 Binary files a/PathFinding/x64/Debug/vc143.idb and b/PathFinding/x64/Debug/vc143.idb differ diff --git a/PathFinding/x64/Debug/vc143.pdb b/PathFinding/x64/Debug/vc143.pdb index 30db7d1..ff51a8e 100644 Binary files a/PathFinding/x64/Debug/vc143.pdb and b/PathFinding/x64/Debug/vc143.pdb differ diff --git a/x64/Debug/PathFinding.pdb b/x64/Debug/PathFinding.pdb index 01d9753..ec2d73a 100644 Binary files a/x64/Debug/PathFinding.pdb and b/x64/Debug/PathFinding.pdb differ