1 / 50

Artificial Intelligence (AI)

Artificial Intelligence (AI). สัปดาห์ที่ 1 Introduction to AI อ.เทพฤทธิ์ สินธำรง รักษ์ เรียบเรียง. นิยามของ Artificial Intelligence. Artificial Intelligence (AI) may be defined as the branch of computer science that is concerned with the automation of intelligent behavior

wyome
Télécharger la présentation

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) สัปดาห์ที่ 1 Introduction to AI อ.เทพฤทธิ์ สินธำรงรักษ์ เรียบเรียง

  2. นิยามของ Artificial Intelligence • Artificial Intelligence (AI) may be defined as the branch of computer science that is concerned with the automation of intelligent behavior • ซึ่งต้องมีพื้นฐานที่สำคัญของ • Data Structure • Programming • Algorithm

  3. What is AI? • ในยุคแรก คอมพิวเตอร์มีไว้เพื่อการคำนวณเท่านั้น โดยมีมนุษย์ควบคุม ป้อนคำสั่งและรอผลลัพธ์จากคอมพิวเตอร์ การตัดสินใจบางอย่างอยู่กับมนุษย์ • ต่อมามีแนวคิดที่ว่าจะทำยังไงให้คอมพิวเตอร์มีความสามารถสูงขึ้น • จึงมีการปรับเปลี่ยนการเขียนโปรแกรมโดยใช้อัลกอริทึมเพื่อเพิ่มขีดความสามารถของคอมพิวเตอร์ให้มี “กระบวนการคิดที่สมบูรณ์แบบคล้ายกับความคิดของมนุษย์” เรียกว่า “ปัญญาประดิษฐ์ หรือ AI”

  4. What is AI? • เป็นแขนงหนึ่งของวิทยาการคอมพิวเตอร์ ที่ต้องการพัฒนาเครื่องจักรกลต่าง เช่น คอมพิวเตอร์ หุ่นยนต์ ให้มีความสามารถด้านความคิด เช่น เดียวกับมนุษย์

  5. ประโยชน์ของปัญญาประดิษฐ์ประโยชน์ของปัญญาประดิษฐ์ • 1.เกม (Game) • อัลกอริทึมในการค้นหาเส้นทาง • การตัดสินใจ • 2.ระบบผู้เชี่ยวชาญ (Expert System) • การจัดการองค์ความรู้ • 3.Machine Learning • 4.Evolutionary Computing • 5.Neural Networks • 6.Planning

  6. Advantages • ใช้ตัดสินใจ (Decision) • จำแนกข้อมูล (Classify) • ค้นหา (Search) • แก้สมการ • หาระยะทาง • พยากรณ์ (Prediction) • คาดการ • เดาอย่างมีเหตุผล

  7. Language • ภาษายุคแรกที่ใช้พัฒนาปัญญาประดิษฐ์ • Lisp (By John Mccharthy) • เป็นภาษาระดับสูงในสมัยนั้น • ใช้ในการคำนวณทางคณิตศาสตร์ • PROLOG (By Alain Colmerauer) • ใช้หลักตรรกะ • Graph, Search

  8. History • 1956 John Mctarthyได้ชักชวนนักวิจัยทั่วอเมริกาที่สนใจการศึกษาด้าน Automata และ Neural Network(โครงข่ายประสาทเทียม) มาจัดสัมนาและก่อตั้งสาขาวิชานี้ว่า “ปัญญาประดิษฐ์” • 1952-1969 ยุคตื่นตัว • 1970-1980 ยุคมืด(เนื่องจาก) • 1980-ปัจจุบัน ยุคเข้าสู่อุตสาหกรรม

  9. Game History • History -1960's • First computer games • Space War! (PDP1, for two human players) (1962) • Board games (e.g. chess) against the machine

  10. Game History • History -1970's • Pong (early arcade game) (1972) • Computer controlled opponent in arcade games • Space Invaders (1978) • “AI” takes 1-2% of CPU

  11. Game History • History -1990’s • FPS and RTS games • Games about/with evolution and learning • Graphic cards take the load off the CPU • “AI” takes 10-35% of CPU

  12. Game History-Present • Computer games is big industry • Games sell for about 25 billion USD per year • Market grows with 16% per year • A game project: 2 years, 8-15 million USD • Less cheating in AI • Characters are more aware • Characters collaborate better • Focus shift from graphics towards AI • Large part of the code is AI code

  13. AI for Game • เป็นการนำปัญญาประดิษฐ์ไปประยุกต์ใช้ในซอร์ฟแวร์ด้านบันเทิง โดยส่วนใหญ่จะเป็นการนำไปใช้ในการเพิ่มประสิทธิภาพให้เกมมีความน่าสนใจมากขึ้น เป็นการเพิ่มความท้าทายให้กับผู้เล่น ช่วยให้ผู้เล่นรู้สึกเหมือนกับเกมมีระบบความคิดเป็นของตนเอง

  14. Chess Game • Deep Blue was a chess-playing computer developed by IBM. On May 11, 1997, the machine won a six-game match by two wins to one with three draws against world champion Garry Kasparov.

  15. ประเภทของเกม • RTS = Real Time Strategy ก็คือเกมแนววางแผนการรบ Red Alert • TBS = Turn-Base Strategy เกมแนววางแผนแบบผลัดกันเล่นคนละตาHero • Simulation : Microsoft Flight Simulator • FPS = First Person Shooting มุมมองบุคคลที่ 1Counter Strike. • TPS = Third Person Shooting มุมมองบุคคลที่ 3 • Side Scrolling Game : Mario • RPG =Role-Playing Game ไฟนอทแฟนตาซี • MMORPG =Massive Multiplayer Online Role-Playing Game • Sport = Sport Game Winning

  16. Typical Game AI topics • Strategically/Tactical Decisions • Against or with you • Search for best counter action • Adaptively • Simulation • of natural behavior • for animation (e.g. bird flocks) • Shortest path problems

  17. Introduction : AI in Computer Games AI in various game types Role playing games AI in enemies, bosses, party members, shopkeeper and other NPCs, ... Conversations (grammar machines) Messaging - communicate Scripting - story FSMs -state Quest generators

  18. Introduction : AI in Computer Games AI in various game types Role playing games First Person \Third Person Shooters

  19. Introduction : AI in Computer Games AI in various game types First Person \Third Person Shooters Enemies ,Weapons requires a good physics engine Cooperative agents Attention Pathfinding

  20. Introduction : AI in Computer Games AI in various game types First Person \Third Person Shooters

  21. Introduction : AI in Computer Games AI in various game types Role playing games First Person \Third Person Shooters Strategy games

  22. Introduction : AI in Computer Games AI in various game types Strategy games AI heavy (on both sides) Shortest path problems Strategical decisions Town building and resource management Planning Life Diplomacy Know thy enemy (observe and adapt)

  23. Introduction : AI in Computer Games AI in various game types Strategy games

  24. Introduction : AI in Computer Games AI in various game types Platform and sports games Platform games Since 1996 (Mario 64) in 3D Camera problems Sports games Cooperation Learning Game balance can be difficult Camera problems (harder)

  25. Introduction : AI in Computer Games AI in various game types Platform and sports games

  26. Introduction : AI in Computer Games AI in various game types Role playing games First Person \Third Person Shooters Strategy games Platform and sports games Racing games

  27. Introduction : AI in Computer Games AI in various game types Racing games Track AI Traffic (including pedestrians) Tuning NPCs and vehicle parameters Physics

  28. Theorem • Math • Finite State Machines (FSM) • Behavior • A* • For shortest path problems • Particle methods • Simulation of flocks, smoke, water, grass,... • Fuzzy Logic • Decision • Genetic Algorithm • Search • K-Nearest Neighbor • Search • Particle Swarm Intelligent • Search • Artificial Neural Network • Classify, Predict and Descript Memory

  29. Representation Systems • The function of any representation scheme is to capture the essential feature of a problem domain and make that information accessible to a problem solving procedure ตัวอย่าง The real number The decimal equivalent 3.1415927… The floating point 32426|1 The representation in computer memory 11100010

  30. Problem Representation • ปัญหาส่วนมากในโลกนั้นไม่ได้อยู่ในโครงสร้างที่ชัดเจน เช่น ทำไมผู้หญิงคนนี้ถึงสวย ทำไมผู้ชายคนนี้ถึงหล่อ • เราจึงต้องแปลงปัญหาเหล่านี้ให้อยู่ในรูปแบบของโครงสร้าง เพื่อให้ปัญญาประดิษฐ์สามารถเรียนรู้ได้ กระบวนการแปลงปัญหา โครงสร้างข้อมูล ปัญหา อัลกอริทึม

  31. Convert Problem to Structure กระบวนการแปลงปัญหา โครงสร้างข้อมูล ปัญหา อัลกอริทึม กระบวนการแปลงปัญหา ความขาวของผิว ทำไมผู้หญิงสวย อัตราส่วนระหว่างความสูงกับ นน. Fuzzy Logic

  32. Types of Problem • ปัญหาด้านปัญญาประดิษฐ์ แบ่งเป็น 2 ประเภท คือ • 1.ปัญหาของเล่น (Toy Problem) เป็นปัญหาที่มีรายละเอียดสั้น ชัดเจนไม่ซับซ้อน เช่น เกม และปัญหาเล็กๆ ทั่วไป • 2.ปัญหาในโลกของความเป็นจริง (Real-World Problem) เป็นปัญหาที่มีความซับซ้อนและรายละเอียดมาก เช่น ปัญหาการเดินทางของพนักงานขาย (Traveling Salesman Problem : TSP) ปัญหาการจัดลำดับการผลิต (Sequencing)

  33. การแก้ไขปัญหา Problem Solving • การแก้ไขปัญหาเป็นการนำปัญหามาวิเคราะห์เป็นขั้นตอน เพื่อค้นหาเป้าหมายที่ต้องการ โดยการแก้ไขปัญหาในด้านปัญหาประดิษฐ์จะมองปัญหาให้อยู่ในรูปแบบของการค้นหา เพื่อให้เราได้สรุปประเด็นของปัญหาและคำตอบรวมถึงปัจจัยควบคุมอื่นๆ นั้นก็คือการ Mapping Input/Output “เราจะจัดการน้ำยังไงให้น้ำไม่ท่วมกรุงเทพ” “เราปิดและเปิดประตูน้ำยังไงให้น้ำไม่ท่วมกรุงเทพ” “เราปิดและเปิดประตูน้ำยังไงให้น้ำไหลลงสู่ทะเลมากที่สุด”

  34. ขั้นตอนการแก้ไขปัญหา • Goal Formulation กำหนดเป้าหมายซึ่งมีความสำคัญมากที่สุดและ จะต้องอยู่ในขอบเขตที่ตั้งไว้ • Problem Formulation การอธิบายปัญหาให้อยู่ในรูปแบบ มาตราฐาน Well – Defined Problem • Select Algorithm เป็นการเลือกเทคนิคในการแก้ไขปัญหา • Execute เขียนโปรแกรมแก้ไขปัญหา

  35. Well-Defined Problem • Initial State กำหนดสถานะเริ่มต้นของปัญหา • Successor Functionsกำหนดเซตของการกระทำทั้งหมดที่เป็นไปได้ • Goal State กำหนดสถานะเป้าหมายที่เป็นไปได้ • Path Cost กำหนดค่าใช้จ่ายหรือทรัพยากรที่ใช้ทั้งหมด การจากแก้ไขปัญหา

  36. ปัญหาหุ่นยนต์ทำความสะอาดปัญหาหุ่นยนต์ทำความสะอาด • หุ่นยนต์จะทำหน้าที่ขจัดสิ่งปรกโดยการดูด (Suck) ด้วยอุปกรณ์ทำความสะอาดของหุ่นยนต์เอง กำหนดให้มีห้องจำนวนสองห้องที่หุ่นยนต์ต้องทำความสะอาด คือ ห้องฝั่งซ้าย(Left)และห้องฝั่งขวา(Right) โดยกำหนดให้สถานะเริ่มต้นคือ ตำแหน่งของหุ่นยนต์อยู่ฝั่งซ้าย เครื่องดูด

  37. ปัญหาหุ่นยนต์ทำความสะอาดปัญหาหุ่นยนต์ทำความสะอาด • Initial State : กำหนดให้ตำแหน่งหุ่นยนต์อยู่ฝั่งซ้าย • Successor Function: เซตการกระทำเป็นไปได้ 3 ทาง {Left, Right, Suck} • Goal State : พื้นของทุกห้องสะอาด • Path Cost : จำนวนการเคลื่อนที่แต่ละครั้งถือเป็น 1 Path Cost หุ่นยนต์

  38. ปัญหาเกม 8-Puzzle • Initial State : สถานะเริ่มต้นรูปทางด้านซ้ายมือ • Successor Function: 4 ทางได้แก่ {Left, Right, Up, Down} • Goal State : สถานะเป้าหมายทางด้านรูปขวา • Path Cost : จำนวนการเคลื่อนที่แต่ละครั้งถือเป็น 1 Path Cost สถานะเริ่มต้น สถานะเป้าหมาย 3 2 6 1 2 3 5 7 4 5 6 8 4 1 7 8

  39. ปัญหาเกม 8-Queen • Initial State : สถานะเริ่มต้นรูปทางด้านซ้ายมือ • Successor Function: เพิ่มจำนวน Queen(จุดสีแดง)ลงในช่องว่าง • Goal State : ตำแหน่งของ Queen ทั้ง 8 ตัวที่วางอยู่บนกระดาน หมากรุก จะต้องไม่มี Queen ตัวใดที่สามารถโจมตีกันได้ • Path Cost : เวลาในการคำนวณ

  40. ปัญหาการค้นหาเส้นทางและการขนส่งปัญหาการค้นหาเส้นทางและการขนส่ง I A • Initial State : สถานะเริ่มต้นรูปดังรูป • Successor Function: สามารถเดินทางระหว่างเมืองได้ • Goal State : เดินทางครบทุกเมือง • Path Cost : ระยะทางในการเคลื่อนที่ B D C J E F F H

  41. ปัญหาการค้นหาเส้นทางและการขนส่งปัญหาการค้นหาเส้นทางและการขนส่ง I A • Eucedian distance B D C J E F F H

  42. ประสิทธิภาพของอัลกอริทึมประสิทธิภาพของอัลกอริทึม • Completeness สามารถค้นหาคำตอบได้หรือไม่ • Optimality สามารถค้าหาคำตอบที่ดีที่สุดได้ • Time Complexity เวลาที่ใช้ในการคำนวณ • Space Complexity พื้นที่หน่วยความจำที่ใช้ • อ้างอิงจาก Russell and Norvig, 2003

  43. ยกตัวอย่างการทำงานระหว่างการเขียนโปรแกรมยกตัวอย่างการทำงานระหว่างการเขียนโปรแกรม • การเขียนโปรแกรมแบบ For Loop • การเขียนโปรแกรมแบบ Recursive • สามารถหาคำตอบได้เหมือนกัน? • แล้วแบบไหนดีกว่ากัน • ภาษามีคนอ้างว่าการเขียนแบบ Recursive อ่านง่ายกว่า Loop • ปัญหา

  44. Recursion คือ ฟังก์ชั่นที่เรียกใช้ตัวเอง ใช้ในการคำนวณทางคณิตศาสตร์ 1. n! = n * (n – 1) ! = n * (n – 1) * (n – 2) ! = n * (n – 1) * (n – 2) * (n – 3) *…….*1 2.0! = 1

  45. Recursion 4! = 4 * (4 – 1)! = 4 * 3 * (3 – 1)! = 4 * 3 * 2 * (2 – 1)! = 4 * 3 * 2 * 1 * (1 – 1)! = 4 * 3 * 2 * 1 * 0! ดังนั้น 4! = 4 * 3 * 2 * 1 = 24

  46. Recursion

  47. Code Loop Recursive //Factorail by Recursive class Fac_Recursive { public static void main(String[] args) { intans; ans=Fac(5); System.out.println(ans); } public static intFac(int n) { int result=0; if (n==0) { return 1; } else { return n*Fac(n-1); } } } //Factorial by Forloop class Fac_For { public static void main(String[] args) { int n=4; int result=1; for (inti=1;i<=n ;i++ ) { result =result*i; } System.out.println(result); } }

  48. Fibonacci Sequence http://www.youtube.com/watch?v=P0tLbl5LrJ8

  49. Fibonacci Sequence

  50. สมการ • และ

More Related