SlideShare uma empresa Scribd logo
1 de 19
인싸 알고리즘
(Flocking Algorithm)
DevRookie JINN
Flocking Algorithm = 인싸 알고리즘
이 알고리즘만 알면 나도 인싸?
• Flocking 알고리즘
동물들의 집단 움직임을 구현한 알고리즘
Boid
Flock
Boid
- 무리(Flock)를 이루는 개별 구성 요소
인싸 3요소
1. 응집 ( Cohesion )
2. 정렬 ( Alignment )
3. 분리 ( Separation )
세가지 행동 규칙(Step)으로 속도를 만들어낸다
1. 응집 ( Cohesion )
• 주변의 이웃 곁으로 가려는 성질
자신의 인식 반경 안에 있는 이웃 보이드들의 무게중심으로 이동
Cohesion(이웃들)
{
for(이웃들)
{
if (거리 (내 위치, 이웃 위치) < 응집영역범위)
{
vector += 이웃 위치
++count
}
}
if(count > 0)
{
return vector /= count;
}
else
{
return zero vector;
}
}
2. 정렬 ( Alignment )
• 주변의 보이드와 같은 방향을 향하려는 성질
인식 반경 내의, 이웃 보이드들 속도의 평균
속도 = (방향 * 힘) 이므로
이웃의 속력이 빠를 수록 정렬하려는 힘도 커짐
Align(이웃들)
{
for (이웃들)
{
if (거리(내 위치, 이웃 위치) < 응집영역범위)
{
vector += 이웃 속도
count++
}
}
if(count > 0)
{
return vector / count
}
else
{
return zero vector
}
}
3. 분리 ( Separation )
• 이웃 보이드와 거리를 두려는 성질
인식 반경 내로 이웃 보이드 진입시
이웃의 반대 방향으로 힘이 작용
분리 인식 반경이 응집 반경보다 클 경우,
이웃을 모두 배척하는 아싸 보이드가 되기 때문에 주의
Separation(이웃들)
{
for (이웃들)
{
if (거리(내 위치, 이웃 위치) < 분리 영역범위)
{
vector += (내위치 - 이웃 위치).normalize() / 거리
count++
}
}
if(count > 0)
{
return vector / count
}
else
{
return zero vector
}
}
• 3요소를 모두 결합해봅시다
Steer(deltaTime)
{
velocity += Flock()
location += (velocity * deltaTime)
}
Flock()
{
이웃들 = GetCollideBoid()
steer += Separation(이웃들) * 분리 가중치
steer += Align(이웃들) * 정렬 가중치
steer += Cohesion(이웃들) * 응집 가중치
return steer
}
문제점
• 보이드의 시야
• 영향도 수정
• 장애물 회피
• 성능 이슈
Flocking Algorithm -2-
플로킹 프로젝트 개선
DevRookie JINN
지난번 발표했던
Flock Algorithm을 구현한 프로젝트
300마리 이상 생성했을 때
에디터상에서 30프레임을 겨우 유지
성능이 심하게 떨어진다….
이것이 바다다!! 희망편
현실
사실 해보고 싶은 것은 이런 느낌이었다…
이대론 안된다 개선해보자!!
Stat Unit
Stat Game
UpdateOverlaps Time
PerformOverlapQuery Time
이름만봐도 충돌체 처리하는 부분…
단순한 구형 충돌체가 달려있을 뿐어서
솔직히 이렇게 비용이 비싼건 생각보다 의외…
콜리전 셋팅을 보니 비용이 비쌀 수밖에 없었다
발표용 프로젝트라 따로 설정을 안해줬었음
애초에 근처 다른 보이드 체크 용도의 콜리전이기때문에
Pawn을 제외한 다른 채널들은 모두 꺼주고
콜리전 범위도 어느정도 줄여줌
단순히 콜리전 설정 변경만으로도 유의미한 변화
Frame 30FPS -> 60FPS
UpdateOverlaps Time 12.3ms -> 2.53ms
PerformOverlapQuery Time 9.3ms -> 2.28ms
좁은 공간에 많은 보이드를 스폰시킬때도
프레임이 급락
스폰 범위를 넓혀 스폰 시점에
너무 많이 오버랩 되지 않도록 변경
이제 1000마리 40프레임 유지
참고자료
• http://dogfeet.github.io/articles/2012/flocking-algorithm.html
• https://www.youtube.com/watch?v=mhjuuHl6qHM
• https://www.red3d.com/cwr/boids/ &t=1561s

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

DevRookie 플로킹 알고리즘.pptx

  • 2. Flocking Algorithm = 인싸 알고리즘 이 알고리즘만 알면 나도 인싸?
  • 3. • Flocking 알고리즘 동물들의 집단 움직임을 구현한 알고리즘
  • 5. 인싸 3요소 1. 응집 ( Cohesion ) 2. 정렬 ( Alignment ) 3. 분리 ( Separation ) 세가지 행동 규칙(Step)으로 속도를 만들어낸다
  • 6. 1. 응집 ( Cohesion ) • 주변의 이웃 곁으로 가려는 성질 자신의 인식 반경 안에 있는 이웃 보이드들의 무게중심으로 이동 Cohesion(이웃들) { for(이웃들) { if (거리 (내 위치, 이웃 위치) < 응집영역범위) { vector += 이웃 위치 ++count } } if(count > 0) { return vector /= count; } else { return zero vector; } }
  • 7. 2. 정렬 ( Alignment ) • 주변의 보이드와 같은 방향을 향하려는 성질 인식 반경 내의, 이웃 보이드들 속도의 평균 속도 = (방향 * 힘) 이므로 이웃의 속력이 빠를 수록 정렬하려는 힘도 커짐 Align(이웃들) { for (이웃들) { if (거리(내 위치, 이웃 위치) < 응집영역범위) { vector += 이웃 속도 count++ } } if(count > 0) { return vector / count } else { return zero vector } }
  • 8. 3. 분리 ( Separation ) • 이웃 보이드와 거리를 두려는 성질 인식 반경 내로 이웃 보이드 진입시 이웃의 반대 방향으로 힘이 작용 분리 인식 반경이 응집 반경보다 클 경우, 이웃을 모두 배척하는 아싸 보이드가 되기 때문에 주의 Separation(이웃들) { for (이웃들) { if (거리(내 위치, 이웃 위치) < 분리 영역범위) { vector += (내위치 - 이웃 위치).normalize() / 거리 count++ } } if(count > 0) { return vector / count } else { return zero vector } }
  • 9. • 3요소를 모두 결합해봅시다 Steer(deltaTime) { velocity += Flock() location += (velocity * deltaTime) } Flock() { 이웃들 = GetCollideBoid() steer += Separation(이웃들) * 분리 가중치 steer += Align(이웃들) * 정렬 가중치 steer += Cohesion(이웃들) * 응집 가중치 return steer }
  • 10. 문제점 • 보이드의 시야 • 영향도 수정 • 장애물 회피 • 성능 이슈
  • 11. Flocking Algorithm -2- 플로킹 프로젝트 개선 DevRookie JINN
  • 12. 지난번 발표했던 Flock Algorithm을 구현한 프로젝트 300마리 이상 생성했을 때 에디터상에서 30프레임을 겨우 유지 성능이 심하게 떨어진다….
  • 13. 이것이 바다다!! 희망편 현실 사실 해보고 싶은 것은 이런 느낌이었다… 이대론 안된다 개선해보자!!
  • 15. UpdateOverlaps Time PerformOverlapQuery Time 이름만봐도 충돌체 처리하는 부분… 단순한 구형 충돌체가 달려있을 뿐어서 솔직히 이렇게 비용이 비싼건 생각보다 의외…
  • 16. 콜리전 셋팅을 보니 비용이 비쌀 수밖에 없었다 발표용 프로젝트라 따로 설정을 안해줬었음 애초에 근처 다른 보이드 체크 용도의 콜리전이기때문에 Pawn을 제외한 다른 채널들은 모두 꺼주고 콜리전 범위도 어느정도 줄여줌
  • 17. 단순히 콜리전 설정 변경만으로도 유의미한 변화 Frame 30FPS -> 60FPS UpdateOverlaps Time 12.3ms -> 2.53ms PerformOverlapQuery Time 9.3ms -> 2.28ms
  • 18. 좁은 공간에 많은 보이드를 스폰시킬때도 프레임이 급락 스폰 범위를 넓혀 스폰 시점에 너무 많이 오버랩 되지 않도록 변경 이제 1000마리 40프레임 유지