A Star Algorithm - githeim/windheim_archive GitHub Wiki
A Start Algorithm
Reference code
https://github.com/justinhj/astar-algorithm-cpp
How to use
findpath.cpp๋ฅผ ์ฐธ์กฐํ๋ค.
ํด๋น ์ฝ๋๋ฅผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ฒ๋ผ ํ์ฉํ๋ ค๋ฉด,
- stlastar.h ์ fsa.h๋ฅผ include path์ ์ถ๊ฐ
- using namespace std; ๋ฃจํด์ถ๊ฐ ๋๋ unordered_set, hash , vector ์์ชฝ์ std:: prefix๋ฅผ ๋ถ์ฌ์ค๋ค
- findpath.cpp์ world_map ์ ์ญ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ map ์ ์ฉ
- 0~5๊น์ง๋ ์ด๋ cost๊ฐ , ์ปค์ง์๋ก ์ด๋ ๋น์ฉ์ด ์ปค์ง
- 9 ์ ๊ทผ ๋ถ๊ฐ ์ง์ญ
int world_map[ MAP_WIDTH * MAP_HEIGHT ] =
{
// 0001020304050607080910111213141516171819
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 00
1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,1, // 01
1,9,9,1,1,9,9,9,1,9,1,9,1,9,1,9,9,9,1,1, // 02
1,9,9,1,1,9,9,9,1,9,1,9,1,9,1,9,9,9,1,1, // 03
1,9,1,1,1,1,9,9,1,9,1,9,1,1,1,1,9,9,1,1, // 04
1,9,1,1,9,1,1,1,1,9,1,1,1,1,9,1,1,1,1,1, // 05
1,9,9,9,9,1,1,1,1,1,1,9,9,9,9,1,1,1,1,1, // 06
1,9,9,9,9,9,9,9,9,1,1,1,9,9,9,9,9,9,9,1, // 07
1,9,1,1,1,1,1,1,1,1,1,9,1,1,1,1,1,1,1,1, // 08
1,9,1,9,9,9,9,9,9,9,1,1,9,9,9,9,9,9,9,1, // 09
1,9,1,1,1,1,9,1,1,9,1,1,1,1,1,1,1,1,1,1, // 10
1,9,9,9,9,9,1,9,1,9,1,9,9,9,9,9,1,1,1,1, // 11
1,9,1,9,1,9,9,9,1,9,1,9,1,9,1,9,9,9,1,1, // 12
1,9,1,9,1,9,9,9,1,9,1,9,1,9,1,9,9,9,1,1, // 13
1,9,1,1,1,1,9,9,1,9,1,9,1,1,1,1,9,9,1,1, // 14
1,9,1,1,9,1,1,1,1,9,1,1,1,1,9,1,1,1,1,1, // 15
1,9,9,9,9,1,1,1,1,1,1,9,9,9,9,1,1,1,1,1, // 16
1,1,9,9,9,9,9,9,9,1,1,1,9,9,9,1,9,9,9,9, // 17
1,9,1,1,1,1,1,1,1,1,1,9,1,1,1,1,1,1,1,1, // 18
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 19
};
- AStarSearch ํ ํ๋ฆฟ์๊ฒ ์ ๊ณตํ MapSearchNode ํด๋์ค ์ ์ฉ (findpath.cpp์ ์์น)
- ํ์์ ๋ง์ถฐ GetMap() ๊ตฌํ