1 / 13

Oyun Programlama (Yol Bulma)

Oyun Programlama (Yol Bulma). Hazırlayan: Yrd.Doç.Dr.Emin BORANDAĞ. Yol Bulma. Problem Oyuncu verilen yollar içerisinden en kıza olan yolu bulması gerekmektedir. Yol Bulma Algoritması En etkin şekilde en az maliyetle en güzel yolu bulma Etkinlik Yolun Durumuna Bak Çevrenin Durumuna Bak

anika
Télécharger la présentation

Oyun Programlama (Yol Bulma)

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. Oyun Programlama(Yol Bulma) Hazırlayan: Yrd.Doç.Dr.Emin BORANDAĞ

  2. Yol Bulma • Problem Oyuncu verilen yollar içerisinden en kıza olan yolu bulması gerekmektedir. • Yol Bulma Algoritması • En etkin şekilde en az maliyetle en güzel yolu bulma • Etkinlik • Yolun Durumuna Bak • Çevrenin Durumuna Bak • Noktaları Kullan.

  3. Pseudocode Add starting node to open_list while (not_empty(open_list)) { current_node := node from open_list with lowest cost if (current_node==goal_node) { path complete } else { move current_node to closed_list for each node adjacent to current_node { if ((node is not in open_list) && (node is not in closed_list)) { move node to open_list assign cost to node } } } }

  4. Yolu Nasıl Kat Edeceğiz Add starting node to open_list while (not_empty(open_list)) { current_node := node from open_list with lowest cost if (current_node==goal_node) { path complete } else { move current_node to closed_list for each node adjacent to current_node { if ((node is not in open_list) && (node is not in closed_list)) { move node to open_list assign cost to node } } } } B A Yolun Tamamlanması yada yolda bir yer katedildiğinde hangi kodların çalışacağı liste içerisinde nasıl kullanılacağı verilmiştir.

  5. Maliyeti Nasıl Belirleyeceğiz? Maliiyet= Başlangıç Maliyeti+ Sezgisel Başlangıç Maliyeti= Başlangıç Noktasında olan maliyet Sezgisel= Hedef Düz bir çizgi gibi ulaşılabiliyormu?

  6. Örnek Adım 1: Open List: Closed List: Empty 5 4 3 2 1 Node: (2,2) Cost: 5 Distance from start: 0 End Start 1 2 3 4 5

  7. Örnek Devam Adım 2: Open List: Closed List: Node: (1,2) Cost: 7 Distance from start: 1 5 4 3 2 1 End Node: (2,1) Cost: 7 Distance from start: 1 5 Node: (3,2) Cost: 5 Distance from start: 1 7 Start 5 7 Node: (2,3) Cost: 5 Distance from start: 1 1 2 3 4 5 Node: (2,2)

  8. Örnek Devam Adım3: Open List: Closed List: Node: (1,2) Cost: 7 Distance from start: 1 5 4 3 2 1 Node: (2,1) Cost: 7 Distance from start: 1 End 5 5 Node: (2,3) Cost: 5 Distance from start: 1 7 Start 5 Node: (3,3) Cost: 5 Distance from start: 2 7 5 Node: (4,2) Cost: 5 Distance from start: 2 1 2 3 4 5 Node: (3,1) Cost: 7 Distance from start: 2 Node: (2,2) Node: (3,2)

  9. Graph Yol Bulma Maze tarzı Bir oyunda Yolbulma.

  10. Graph Yol Bulma Bir Graf oluştur. Düyümler Sistem İçerisinde Tanımanmış Olmalı

  11. Graph Path-Finding Her Birinin Belli Bir Maliyet Hesabı Olmalı. 1 7 1 1 3 1 1 1 3 3 2 2 1 6 3 3 4 4 3 3 3 3 2 2 1 4 1 1 4 1 1 1 9 1

  12. Graph Path-Finding 1 7 1 1 3 1 1 1 destination 2 3 3 2 2 1 3 3 4 4 4 3 3 3 3 2 2 1 4 1 1 3 1 1 1 1 9 1 start

  13. Graph En Kısa Yol En Kısa Yolu Bulma Algoritması Dijkstra’s Algorithm { Add starting node to open_list while (not_empty(open_list)) { current_node := node from open_list with lowest cost if (current_node==goal_node) { path complete } else { move current_node to closed_list for each node adjacent to current_node { if (node is not in closed_list) { if (node not in open_list) move node to open_list AssignCost(node) } } } } } How to AssignCost(node)? In the beginning, each node has infinite cost. When AssignCost(node), calculate the new cost of the node. New cost = Costcurrent_node + Distancecurrent_node,node If (new_cost < original_cost) cost := new_cost

More Related