SlideShare a Scribd company logo
1 of 66
Dave Geurts
www.davegeurts.com
#
#
Win Prizes!!!!!
Search Area
Break your level up into any type of Grid System
Your hero needs
To get from
Point A
To
Point B
Each Square on our Grid is
Called a Node
Search Area
Break your level up into any type of Grid System
Walkable
NOT Walkable
SLOW but Walkable
Open List
and
Closed List
Shopping list of Nodes
Calculating an F score for a Node
= +
Calculating G for a Node
= +
Total Sum of F scores from the starting Point to Node
Calculating H for a Node
= +
Count # of Nodes To get to the destination * 10
heuristic
= +
Open List
and
Closed List
Search Area - Nodes
Break your level up into any type of Grid System
Walkable NOT Walkable
Recursive A* loop
Starting Node
Destination Node
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
Count Nodes To get to the destination * 10
Recursive A* loop
= +
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
= +
Recursive A* loop
Recursive A* loop
Recursive A* loop
= +
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
= +
Recursive A* loop
Recursive A* loop
Recursive A* loop
= +
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
Recursive A* loop
= +
Recursive A* loop
Recursive A* loop
Recursive A* loop
= +
Recursive A* loop
Broad Phase
Determine which things the ray might collide with.
Narrow Phase
Test the ray against each possible thing to determine
What it hits and where
Search Area
Break our level up into Nodes
Shoot Ray
Shoot out a ray from our point in an angle
Check every nth measurement
Check for collision along the angle every nth pixels
Broad Phase
List of all Nodes that the ray touches, until the length
Of the ray is reached.
Narrow Phase
Test the ray against each possible thing to determine
What it hits and where
Results!

More Related Content

Recently uploaded

Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Recently uploaded (20)

1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 

Featured

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
ThinkNow
 
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
Kurio // The Social Media Age(ncy)
 

Featured (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...
 

UtahDigiCon 2014 - Bringing Life to your Games

Editor's Notes

  1. Welcome Everybody…This session is about Bringing Life Into your Games My name is Dave Geurts and my Twitter handle is sims11tz
  2. We have been asked to encourage all of you to tweet about what you are learning and having fun.. So pull out those cell phones and tweet away The hash tag for the conference is #UtahDigiConI’m going to start off by tweeting a pic of all you
  3. We are going to have pop quizes throughout the session and we will keep score… you can win prizes so pay attention!!!!!!
  4. Really quick intro for myself… - I started in the Games Industry when I was in highschool working at Access Software and Microsoft doing QA and Photoshop work on I then learned Flash and did some games for mtv.com back in 99-2000 and some other Marketing flash games for Books and CompaniesThen I moved to Waterford Institute and worked on Educational Games for young children
  5. Now I work for a Game Studio called Smart Bomb Interactive
  6. We have a browser flash kids MMO called AnimalJam
  7. We also released an Ios / Android Game called TunnelTown that reached the top 10 in the ios charts for a while
  8. We also released a game called AjJump for IOS and Android that also briefly reached the top 3 games for Ipad
  9. Explain the Quiz and the scoring systemLoad Quiz #1
  10. Ok so lets get started into good stuff - We are gonna talk about how to bring life into your games - Games would be super boring without any type of Artificial Intelligence or Smart Enemies in your gamesWe are gonna learn about Pathfinding which is how enemies chase you down in games or navigate levels to do tasksWe will also learn about RayCasting which is one way you can make your Enemies have eyes and see things and can also be used to Shoot bullets out of guns in your game.
  11. First of we are gonna talk about PathFinding Some examples of pathfinding would be -Enemies in a Zelda Temple running around finding their through a room trying to kill you-Enemies in a 3d space like in Minecraft where the Zombies, Creepers and Skeletons run around trying to find you and kill you-Or even in a 2d side scroller like Terraria where the different baddies try to find and hurt you-This concept can also be used for other things then enemies like in Star Craft when you select troops and Command them to attack yourEnemies base,… they have to be able to find the best way to run around obstacles and find their way to the destination of your command.Pathfinding is in almost all games and GAMES would be boring without it
  12. One of the most common basic and effective Path finding algorithms is called A StarYou have a level in your gameYou have a hero and they need to get from Point A to Point BThe first thing in A* , is you need to break your game up into a grid system which we call our Search AreaYou don’t have to show the grid to your players visually and you don’t have to do squares, you can use any shape.
  13. Our Search Area Grid system is made up of squares that we call nodes-Nodes need property that says if they are Walkable – Nodes that blocks on them are not walkable-To make your levels more fun, You can also add nodes that have things like sand on them or water or Tall Grass that are walkable but take longer to walk across
  14. The next thing we need to learn about in A* is that you have List’s an Open List and a Closed List - These lists are basically Arrays that we use to keep track of Nodes we want to use in our path or nodes we don’t want to walk on. Kind of like a shopping list of nodes we are considering moving our character on. - The open list are Nodes that we are currently considering as nodes that will be in our path. - The closed list are Nodes that we have made a finalized decision on for better or worse
  15. The next concept that we need to know is how to Calculate an F score for a Node The magic algorithm to find an F score is F = G + HSimply put G = the movement cost to move from the Starting point to the Node in questionH = the distance from the Node in question to the Finish Point - the easiest way to find H is count the number of horizontal and vertical moves it takes to get the finish point
  16. Like I was saying G is the movement cost to move from the Starting point to the Node in questionThe starting point is the green square that has a score of 1We then move to the Node in question which is pink … Its super easy… 1 + 2 + 4 = 7So the G score for the Pink Node is 7----We will talk more later about to initally calculate the G Score
  17. The H score is a bit more difficult to calculate and there a lot of different ways to calculate it. Some more accurate then others. First off The H is in the opposite direction of the G… - The G was from the Starting point to the target Node… - the H is from the pink target Node to the Yellow Destination Node We will use the Manhattan Method , Which is very simple and accurate enough The Manhattan Method is counting the number of Horizontal/Vertical only moves it takes to get from the target Node to the Destination Node and then multiply by 10 So basically if you count from the Pink Target node you must move left 3 nodes and up 2 nodes to get the Yellow Destination.So our count is 5 we then multiply our count by 10 and we have your H score of 50H ignores non walkable zones
  18. The entire recipe for A* is Breaking your level up into a search area that is made up of nodes that are walkable and nodes that are not walkableNext you need an open and closed listThen you need to be able to caclulate an F scoreRise and RepeatOk lets look at an example
  19. Okay now that we know all of the concepts (open lists/close lists… F = G + H) we can find a path from 1 Node to another Node in any level !Lets walk through this with an example. We are going to find the shortest path from the Green Starting Node to the Yellow destination Node for our hero.
  20. First We add our Starting Node to the Open List and set it as the Target Node and then we enter the Recursive A* loop A recursive loop is a section of code or a function that calls itself over and over until it is done processing its algorithm
  21. After we have a Target Node We need to look at all off the Target Nodes Neighbors and calculate an F Score for each of them So lets walk through calculating all of the F scores in detail
  22. First we calculate all of the G Scores of the starting points Neighbors We didn’t previously learn what the definition of a G score is we charge 10 movement points for a Horizontal/Vertical Moveand we charge 14 points for a Vertical Movement as walking to a vertical Node is a little bit Further distanceEarlier I mentioned that you could also have Nodes like Long grass or Sand that are slow to walk on and you would give them a high G score like 20
  23. Next we calculate all of the H – hueristic scores for all the starting nodes neighbors - Like we learned earlier we count the number of horizontal+vericle moves it takes to get the the Destination Node - We count non walkable nodes just as walkable nodes - And then we multiply the count by 10
  24. - Now that we have the G and H scores for all of the neighbors we can easily calculate their F scores
  25. Here are all of the neighbors to the Starting Node and all of their F ScoresSo the next step is that we find the neighbor with the lowest F Score
  26. The neighbor with the lowest f score is Node N2
  27. Next we find all of the Node 2’s neighbors that are walkable and not already in the open list and not in the closed listWe add n10 and n11 to our open listYou will notice to the upper left diagnol there is a white walkable node but we don’t add this because in our game we don’t allow youTo walk through block nodes even while going diagnol
  28. So we start with N10 we need to calculate the G score… this is all previous F scores to get to here added together plus 10 for a Vertical moveSo the G score for N10 is 44
  29. Now we get N10’s H score… so we count 2 moves to the left (Remember we go through non walkable blocks for H Score)
  30. Sooooooo 44 + 30 = 74 so N10’s F score is 74
  31. Now we get the G Score for the next neighbor N11So 34 + 14 for a diagonal move is 48
  32. Then we get the H score for N11 so 3 moves to the left and 1 down… yet again for the H score we go through non walkable nodes
  33. So 40 + 48 = 88…. So the F Score for n11 is 88
  34. Next we select the neighbor to our Target Node (N2) with the lowest F ScoreSo We make n5 the Current Target node and add it to the closed listTHIS is the point we recursively call our logic again… so now we go through the whole process again with our updated open and closed lists and N5 as our Target Node
  35. Next we find all of the Target Node 5’s neighbors that are walkable and not already in the open list and not in the closed listThese are Node 12 and Node 13 so we add nodes 12 and 13 to the open list
  36. First we look at N12…So we add 40 from N5 and then add 10 for a horizontal moveSo the G score for n12 is 50
  37. For the H score We got left 1 node and up 1 node and multiply by 10So the H score for n12 is 20
  38. We add 50 and 20 together and get 70 for n12’s F Score
  39. Next we look at n13We add 40 form n5 + 54 from n7 and add 10 for a horizontal move we get 104 for the G Score
  40. We go left one and up 2 multiplied by 10 And we get 30 for the h score for n13
  41. So we add 104 + 30 and get 134 for the F score for Node 13
  42. Next we select the neighbor with the lowest F score and make it the Target Node!!!!That would be Node 12 with an F score of 70So we make Node 12 the next target Node and add it to the closed lsit
  43. Now we enter the recursive loop again and do all of the logic all over… Don’t worry we are almost there!!!We get all of the Target nodes walkable neighbors that are not in the open list and not in the closed list which is n14 and n15We cant walk directly to the destination Node by going upper left because it has a block in its diagonal
  44. So the G for n14 is 40 from n5 + 70fomr n12 + 10 for 1 horizontal movementAnd we get G Score of 120
  45. The h is easy… 1 veritcal movement mulitplied by 10
  46. So 120 + 10 = 130 so n14 has an F score of 130
  47. So we add 40 from n5 and 70 from n12 and add 14 for a diagonal movement and getA g score of 124 for n15
  48. Then for the h it is 2 up moves multiplied by 10 for an H score of 20
  49. So 124 + 20 = an F score of 144 for n15
  50. So now we make the neighbor with the lowest F score the Target Node which is n14Now we check all the neighbors and one of them is our destination node!!!!!!
  51. We have the shortest possible path from one Node to another !!!!!!!!!!!!!!!!!!!!!!!!Woooooooooohoooooooooooooo
  52. Next we are going to learn about a concept called Raycasting it is essentially drawing a straight line or shooting out a ray from 1 point and when it collides with something it stops and tells your code what it collided with you can do a lot of fun things with this you can shoot a ray out of shotgun and when it hits something that’s where the bullets hit you can shoot a ray out of your hero like in terraria and when it hits terrain that is where your hookshot sticks in you can shoot a ray out of enemies and when they hit the hero they fire!!! Like the turrets in portalOr you could use them to detect how far away an enemy is from a hero so it knows how far to jump and things like that
  53. So you will see the green circle is an enemy in our game and the blue are walls… if you we shoot 2 rays out and slightly offset angles we get a realistic field of vision that the human eyes would see- This makes it so that we could sneak up on an enemy in a game as their 2 ray casts wouldn’t hit the hero if they go from behind
  54. Raycasting. broad phase: determine which things (tiles and objects) the ray might collide with. narrow phase: test the ray against each thing to determine collision information, such as the point of intersection
  55. So we have a level…. And we have to break our level up into a grid of nodes called a Search Area just like in path findingOur Enemy is the blue dot and the green squares are walls in our levelHe is trying to scan the level for the hero so he can path find and kill him!
  56. So our enemy is a robot and he uses his eyes and looks in a direction… to do this we shoot a ray out
  57. It seems like the simplest thing to do would be to test for collisions every x amount of pixels but this has issues you cant look at all measurements asIt would run very slow and if you can see if we don’t have our checks close enough together the pink circles miss the green squares sometimesSo this would either be accurate and VERY slow to process or quick and not accurate
  58. So we first use a Broad phase search… we detect all of the nodes that our line hits, this is easy because we know the width and height of a nodeSo we can easily determine all the nodes we touch and still process it fast enough
  59. Next we do the narrow phase…. Where we do collision detection on all of the broad phase nodes against all of the walls this is a very quick operation