Slide 14
Slide 14 text
勝利条件
dfs <- function(board, player, visited, row, col) {
size <- nrow(board)
if (visited[row, col] || board[row, col] != player) {
return(FALSE)
}
visited[row, col] <- TRUE
neighbors <- get_neighbors(row, col, size)
for (neighbor in neighbors) {
if (dfs(board, player, visited, neighbor[1], neighbor[2])) {
return(TRUE)
}
}
return(FALSE)
}
Check winner
DFS(深さ優先探索)で
ゴリ押し
面白味なし!