강의

멘토링

커뮤니티

Inflearn Community Q&A

spaciall3269's profile image
spaciall3269

asked

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

Sample Problem : TIC-TAE-TOE

TIC-TAC-TOE 문제 질문드립니다.

Written on

·

410

0

안녕하세요.

아래 코드에서 'o' + 'x' - turn을 인자로 넘겨주는 이유가 궁금합니다. 어떤 의미가 있는 것인가요?

minValue = min(minValue, CanWin(board, 'o' + 'x' - turn));

tic-tac-toe기술면접

Answer 2

1

Rookiss님의 프로필 이미지
Rookiss
Instructor

'o' + 'x' - turn은 turn이 'o'이면 'x'를, 'x'면 'o'를 반환합니다.
'o' 'x' 'o' 'x'를 왔다 갔다 하는 일종의 토글 기능인 것이죠.

0

int CanWin(vector<vector<char>>& board, char turn)

이 함수보면 turn 은 내가 둔 수 입니다.
board[y][x] = turn; 내가 둔수를 셋팅 햇으면
상대방이 둔 수의 결과를 봐야합니다.
minValue = min(minValue, CanWin(board, 'o' + 'x' - turn));

그게 위 코드 입니다.

spaciall3269's profile image
spaciall3269

asked

Ask a question