1 / 26

Artificial Intelligence (AI)

Artificial Intelligence (AI). สัปดาห์ที่ 6 Chasing and Evading อ.เทพฤทธิ์ สินธำรงรักษ์ เรียบเรียง. Topics. Basic rules of chasing and evading Line of sight chasing Chasing and evading in continuous environments Line of sight chasing in tiled environments

freja
Download Presentation

Artificial Intelligence (AI)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Artificial Intelligence (AI) สัปดาห์ที่ 6Chasing and Evading อ.เทพฤทธิ์ สินธำรงรักษ์ เรียบเรียง

  2. Topics • Basic rules of chasing and evading • Line of sight chasing • Chasing and evading in continuous environments • Line of sight chasing in tiled environments • Line of sight chasing in continuous environments • Intercepting : stopped enemy

  3. Basic Chasing(การไล่ล่า) and Evading(การหนี) If (predatorX > preyX){ predatorX--; } else if (predatorX < preyX){ predatorX++; } If (predatorY> preyY){ predatorY--; } else if (predatorY< preyY){ predatorY++; }

  4. Basic tile-based chase

  5. Problem • เมื่อไหร่เราจะเริ่มไล่ล่า (Chasing) และเริ่มหนี (Evading) • หลักการง่ายๆให้คิดระยะทางระหว่างจุดที่ผู้ล่าอยู่ (Predator) กับเหยื่อ (Prey) ถ้าเท่ากับหรือน้อยกว่าระยะสายตาให้ทำการเริ่มไล่ล่า Line of sight Chasing • SQRT เป็นค่าระยะสายตา • โดยการเคลื่อนที่ไปหาเหยื่อจะมีแบบเป็นช่องตาราง (Tile) กับแบบต่อเนื่อง (Continuous)

  6. Line-of-Sight • If the prey is not moving –the path followed is a straight line • Limited of direction • Tile-base movement can appear jaggy

  7. Line-of-Sight • The predator always takes a straight line path towards the prey • The predator always moves towards the prey’s current position • Result: movement appears natural.

  8. Line to move • Simple chase versus line-of-sight chase

  9. Bad Good

  10. Bresenham’s Algorithm Xk+1,Yk+1 Xk,Yk Xk+1,Yk คำถามคือจะเดินผ่านสีส้มหรือสีแดง

  11. Bresenham’s Algorithm (Xk+1,Yk+1) Y=mX+b d2 d1 Y=mX+b (Xk,Yk) (Xk+1,Yk)

  12. Summary • ได้สมการเป็น Pk+1 = Pk + 2ΔY(Xk+1 - Xk) - 2ΔX(Yk+1 - Yk) • ขั้นตอนการคำนวณ • InputFirst Point, End Point • Plot First Point • Cal ΔX,ΔY,2ΔY and 2ΔY- 2ΔX • Cal P0 = 2ΔY- ΔX • Loop Until Xk=XEndPoint If Pk >= 0 Choose (Xk+1,Yk+1) Pk+1 = Pk+ 2ΔY - 2ΔX If Pk < 0 Choose (Xk+1,Yk) Pk+1 = Pk+ 2ΔY

  13. ExampleจงPlot จุดจาก (5,8) ไป (10,11) 11 10 9 8 10 5 6 7 8 9

  14. Digital Differential Analyzer (DDA) • มี 4 กรณี • 1.m <= 1 (และมากกว่า 0) • 2.m > 1 • 3.m <=-1 • 4.m > -1 (และน้อยกว่า 0)

  15. กรณี m <= 1 กรณี M>1 กรณี M>=-1 กรณี M<-1

  16. ตัวอย่าง DDA

  17. Type 1: Using delta values • function chasing(){ • deltaX=px2-px1; • deltaY=py2-py1; • px1=px1+deltaX*velocityPredator; • py1=py1+deltaY*velocityPredator; • }

  18. Types 2:Using normalizing vector • delta[0]=Pos_prey[0]-Pos_predator[0]; • delta[1]=Pos_prey[1]-Pos_predator[1]; • deltaManitude=Math.sqrt(Math.pow(delta[0],2)+Math.pow(delta[1],2)); • Pos_predator[0]+=delta[0]/deltaManitude*Vpredator[0]; • Pos_predator[1]+=delta[1]/deltaManitude*Vpredator[1];

  19. Intercepting Predator find/calculate point of intercepting

  20. Types 3:Intercepting Scenario1 • Vr = Vprey – Vpredator ;Vrคือ ความสัมพันธ์ระหว่างความเร็วผู้ล่าและเหยื่อ • Sr = Sprey – Spredator ;Srคือ ระยะทางระหว่างผู้ล่ากับเหยื่อ • tc = |Sr|/|Vr| ;tcคือ เวลาเฉลี่ยที่ผู้ล่าจะวิ่งไปถึงเหยื่อ • St = Sprey + (Vprey)(tc); St คือ จุดที่คาดคะเนที่เหยื่อจะเดินทางไป

  21. Line-of-Sight Chasing in Continuous Environments

  22. Intercepting

  23. Types 4:Intercepting Scenario2

  24. Types 4:Intercepting Scenario2

  25. References • David M. Bourg and Glenn Seemann. Creating Intelligent behavior in Games. 2004. ISBN: 0-596-00555-5

  26. จบการนำเสนอ

More Related