방향성 지정 오류 수정

This commit is contained in:
김민구
2020-12-15 18:50:22 +09:00
parent f4ddd11c7b
commit 1d32355668
7 changed files with 40 additions and 22 deletions

Binary file not shown.

View File

@@ -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)
//{

View File

@@ -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";
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.