인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

두타르's profile image
두타르

asked

[MMORPG Game Development Series with C++ and Unreal] Part 3: Data Structures and Algorithms

A* pathfinding algorithm

A*알고리즘 작성과정에서 블록 안에서 초기화를 한 이유가 궁금합니다.

Written on

·

480

0

player.cpp의 AStar 함수 내에서

//초기값

{

int32 g = 0;

int32 h = 10 * (abs(dest.y - start.y) + abs(dest.x - start.x));

pq.push(PQNode{ g + h, g, start });

best[start.y][start.x] = g + h;

parent[start] = start;

}

이렇게 { } 블록을 설정하고 그 안에서 초기화를 한 이유가 궁금합니다.

기술면접

Answer 1

0

rookiss님의 프로필 이미지
rookiss
Instructor

큰 의미가 있는 것은 아니고 초기화 하는 부분을 묶어서 보기 위함입니다.

두타르's profile image
두타르

asked

Ask a question