diff --git a/.vs/AStarPathFinding/v16/.suo b/.vs/AStarPathFinding/v16/.suo index e522ab3..a6613cd 100644 Binary files a/.vs/AStarPathFinding/v16/.suo and b/.vs/AStarPathFinding/v16/.suo differ diff --git a/AstarPathFinder.cs b/AstarPathFinder.cs index d5d00c2..07eb133 100644 --- a/AstarPathFinder.cs +++ b/AstarPathFinder.cs @@ -225,6 +225,9 @@ namespace AStarPathFinding { for (int i = 0; i < 8; i++) { + // 방향성 초기 값 + Form1.Direction = "Up"; + AstarNode openNode; //예비 자식이 될 노드들의 좌표 계산 @@ -287,32 +290,32 @@ namespace AStarPathFinding // continue; //} - if (dicOpenList.ContainsKey(focusNode.axis) & tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad) - { - openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; - openNode.SetParent(focusNode); - openNode.SetGCost(gCost + openNode.parent.R); - openNode.SetHCost(openNode.parent.R - 1000); - openNode.ParentDirection = neerAxis[i]; + //if (dicOpenList.ContainsKey(focusNode.axis) & tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad) + //{ + // openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; + // openNode.SetParent(focusNode); + // openNode.SetGCost(gCost + openNode.parent.R); + // openNode.SetHCost(openNode.parent.R - 1000); + // openNode.ParentDirection = neerAxis[i]; - dicOpenList.Add(tempChildAxis, openNode); - tableStateData[tempChildAxis.X, tempChildAxis.Y] = eTileState.Open; + // dicOpenList.Add(tempChildAxis, openNode); + // tableStateData[tempChildAxis.X, tempChildAxis.Y] = eTileState.Open; - Form1.Direction = false; + // //Form1.Direction = false; - //dicCloseList.Remove(focusNode.axis); - //dicOpenList.Add(focusNode.axis, focusNode); - //tableStateData[focusNode.axis.X, focusNode.axis.Y] = eTileState.Close; + // //dicCloseList.Remove(focusNode.axis); + // //dicOpenList.Add(focusNode.axis, focusNode); + // //tableStateData[focusNode.axis.X, focusNode.axis.Y] = eTileState.Close; - continue; - } + // continue; + //} //만일 클로즈 리스트에 있어도 무시한다. if (dicCloseList.ContainsKey(tempChildAxis)) continue; // !!!길일 때 오픈리스트에 넣어준다. - if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == true) + if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == "Right") { openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; openNode.SetParent(focusNode); @@ -326,7 +329,7 @@ namespace AStarPathFinding continue; } - if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == false) + if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.RRoad & Form1.Direction == "Left") { openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; openNode.SetParent(focusNode); @@ -340,7 +343,7 @@ namespace AStarPathFinding continue; } - if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == true) + if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == "Right") { openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; openNode.SetParent(focusNode); @@ -354,7 +357,7 @@ namespace AStarPathFinding continue; } - if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == false) + if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.LRoad & Form1.Direction == "Left") { openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; openNode.SetParent(focusNode); @@ -368,6 +371,21 @@ namespace AStarPathFinding continue; } + if (tableStateData[tempChildAxis.X, tempChildAxis.Y] == eTileState.URoad & Form1.Direction == "Up") + { + openNode = tableNodeData[tempChildAxis.X, tempChildAxis.Y]; + openNode.SetParent(focusNode); + openNode.SetGCost(gCost + openNode.parent.U); + openNode.SetHCost(openNode.parent.U - 1000); // 휴리스틱 값 수정해서 길 따라갈 수 있게 점수를 낮춰줌 수정 + + openNode.ParentDirection = neerAxis[i]; + + dicOpenList.Add(tempChildAxis, openNode); + tableStateData[tempChildAxis.X, tempChildAxis.Y] = eTileState.Open; + + continue; + } + ////대각선일시 자신의 주변을 체크 후 벽이있다면 무시한다(벽끼고 대각선이동 불가) //if (gCost == 14) //{ diff --git a/Form1.cs b/Form1.cs index 8260d37..e9fab2d 100644 --- a/Form1.cs +++ b/Form1.cs @@ -17,7 +17,7 @@ namespace AStarPathFinding public partial class Form1 : Form { - public static bool Direction { get; set; } // 방향 설정!!! + public static string Direction { get; set; } // 방향 설정!!! //구조체===================== struct stCurrentAction//사용자의 세팅(타일배치)종류 확인용 구조체 @@ -417,14 +417,14 @@ namespace AStarPathFinding SetCurrentAction(null, eTileState.None); pathFinder.PathFind(pn_Table, startPoint, goalPoint); clickState = false; - Direction = false; + Direction = "Up"; } else { SetCurrentAction(null, eTileState.None); pathFinder.PathFind(pn_Table, goalPoint, startPoint); clickState = true; - Direction = true; + Direction = "Up"; } } } diff --git a/bin/Debug/AStarPathFinding.exe b/bin/Debug/AStarPathFinding.exe index 89acd1a..42e4349 100644 Binary files a/bin/Debug/AStarPathFinding.exe and b/bin/Debug/AStarPathFinding.exe differ diff --git a/bin/Debug/AStarPathFinding.pdb b/bin/Debug/AStarPathFinding.pdb index cea4894..df48373 100644 Binary files a/bin/Debug/AStarPathFinding.pdb and b/bin/Debug/AStarPathFinding.pdb differ diff --git a/obj/Debug/AStarPathFinding.exe b/obj/Debug/AStarPathFinding.exe index 89acd1a..42e4349 100644 Binary files a/obj/Debug/AStarPathFinding.exe and b/obj/Debug/AStarPathFinding.exe differ diff --git a/obj/Debug/AStarPathFinding.pdb b/obj/Debug/AStarPathFinding.pdb index cea4894..df48373 100644 Binary files a/obj/Debug/AStarPathFinding.pdb and b/obj/Debug/AStarPathFinding.pdb differ