07 | Adding AI and Other Extras to the Game Michael “Mickey” MacDonald | Indie Game Developer Bryan Griffiths | Software Engineer/Game Developer Module Overview • Assessing What You Need • Common Pitfalls • The Basics Of An AI Agent • Stepwise Implementation • Tweaking It • Wrapping Up Assessing What You Need • Start by picking out all of the parts of your game that could benefit from an artificial intelligence. – Enemies (Bosses / Grunts) – NPCs (Squad Mates / Critters / Civilians) – The Game’s Narrator – The Level / Map Generator – The Chat System – The Match Making System – The Auction House – Etc. Assessing What You Need • Of those, which are critical, nice to have, and not required for your game to be completed? – Do those goldfish in the fountains of the Inferno map in Counter-Strike: Source really need a flocking system to avoid the players that are trying to knife them during a bomb plant? • Now rank them on how complex and how many states or actions you feel each AI system needs. – Do the shopkeepers really need to stock the shelves, sweep the floors/sidewalks, man the cash registers, go home at night, and chase shoplifters with their brooms? Or can you get by with just minding the cash register and occasionally chasing a shoplifter? Common Pitfalls • Losing focus of the point of an AI in a game. – To be an opponent when we have none. – To present a challenge to the player. – To appear real, but fallible. • Designing It > Playing It • Perceived as cheating. • Too predictable. • Too smart for its own good. • It exploits your game. The Basics of an AI Agent • Simple Reflex Agent – They perceive the game world through one or more sensors. – Based on the state of the current perceived world they decide what they should do. – They move or affect the world through a set of actuators. – They don’t reflect on past history of events or actions. – Typically, they don’t do well when all of the information isn’t constantly available. The Basics of an AI Agent • For our game a Simple Reflex Agent should be suitable. • Currently the AI can’t perceive the environment in any fashion. • It can sense where the player is at all times. • Other than that it decides how it feels at the start of each match and then carries out certain actions in ways that befit its chosen behavior. • Lets take a look at how we got it to this point through a stepwise implementation. (A great way to create and test this kind of AI.) Stepwise Implementation • The first maneuver we want our Sumo AI to do is to try and push the player out of the ring and win the game! • To do this we added a new class called AISumoBlock that inherits from the SumoBlock class gaining everything it had. • We gave it a new function called DetermineAIAction() in which it calculated the vector towards the player and then took a step. • This action was called during the UpdateDynamics() function because it essentially moves the AI which should be taken into account during the physics update step. DEMO The first maneuver: walk. Stepwise Implementation • For the next maneuver we chose a circle-strafing dodge mechanic to help it turn the tables on the player and avoid being eliminated as easily. • However, since it can’t perceive the edge of the mat at the moment we chose to set up a randomized timer that allows the AI to switch between this maneuver and the walk maneuver. • So we implemented our enumeration for the maneuvers knowing that we would expand it at least one more time and then the timer system. DEMO The second maneuver. Stepwise Implementation • Finally we chose to add a harder push since the player can effectively push harder than the AI at the moment. • In essence, this maneuver is a simple copy and paste of the walk function, but with two times the force. • The side effect of adding this behavior is that the AI agent now dodges less than it used to, but that’s ok. It feels less like it is trying to just run around avoiding the player and more like it is trying to do something to the player. • The illusion of intelligence and the players’ perception of what your AI does, are more important than how “smart” it actually is. DEMO The third maneuver. Tweaking It • At this stage the AI agent is a decent opponent for such a simple game. • Balancing the time ranges for changing its maneuvers and the strength of its push become the main balancing factors at this point. • However, the AI Agent feels just a little bit shallow after you play it a few times and we wanted to fix that to give the game a bit more depth across multiple play sessions. • Enter the behavior attribute, which decides how we apply or alter certain maneuvers each match. DEMO Randomized behavior demo. Tweaking It • The AI agent is already a competent opponent. – It does present a challenge to the player. – It appears to be intelligent as you play it a few times. – It is fallible and can dodge off the mat accidentally. • All of this from the most basic level of AI agent that can only perceive the player’s position. • So where do we go from here? Or do we leave it as is? • Should we move it up to the next level of AI agent? The Modelbased reflex agent? Or simply add more behaviors and maneuvers? Wrapping Up • DirectX 11 FPS Game Project (A great next step from here!): – http://code.msdn.microsoft.com/windowsapps/Metro-style-DirectX18f98448 • DirectX APIs (Direct3D, DirectXMath, Xinput, etc.) – http://msdn.microsoft.com/enus/library/windows/desktop/ee663274(v=vs.85).aspx • Another simple tutorial that takes you from vertices to rendering. – http://msdn.microsoft.com/en-us/library/windows/apps/jj651551.aspx Wrapping Up • DirectX 11 is a powerful suite of APIs that can enable you to create the craziest game you could ever dream of. • The learning curve is a little steep, but it will also introduce you to some very low level and intricate pieces of engineering. • Many of the AAA companies use it as a mainstay piece of technology and it has been around for a long time, meaning if you learn it you will have a higher employability rating. • Feel free to take this project, grow it and put your own spin on it. • Can’t wait to see what you make on the Windows Store. • WACK stands for the Windows App Certification Kit • To give your app the best chance of getting certified, validate and test it on your computer before you submit it for certification and listing in the Windows Store • You must install Windows App Certification Kit version 3.1, which is included in the Windows Software Development Kit (SDK) for Windows 8.1 • Steps for using the Windows App Certification Kit interactively 1. From the Start menu, search Apps, find Windows Kits, and click Windows App Cert Kit. 2. From the Windows App Certification Kit, select the category of validation you would like to perform. For example: If you are validating a Windows Store app, select Validate a Windows Store app. 3. Select the Windows Store app you want to test, and then click Next. • Steps for using the Windows App Certification Kit interactively - continued 4. From the next screen, select the tests you want to run on your Windows Store app and click Next. The Windows App Certification Kit begins validating the app. 5. At the prompt after the test, enter the path to the folder where you want to save the test report. The Windows App Certification Kit creates an HTML along with an XML report and saves it in this folder. • Steps for using the Windows App Certification Kit interactively - continued 6. Open the report file and review the results of the test. Test name Possible test results Certification requirements tested Crashes and Hangs test Pass/Fail Crashes and hangs App manifest compliance test Pass/Fail App manifest Windows security features test Pass/Fail Binary analyzer Banned file analyzer Private code signing Supported Windows Store API test Pass/Fail Supported APIs Performance test Pass/Fail Bytecode generation Optimized binding references Performance launch Performance suspend App manifest resources test Pass/Fail App resources validation Branding validation Debug configuration test Pass/Fail Debug configuration Test name Possible test results Certification requirements tested File encoding test Pass/Fail UTF-8 file encoding Direct3D feature level test Pass/Fail Direct3D feature level support Direct3D Trim after suspend App capabilities Pass/Fail Special use capabilities Windows Runtime metadata validation Pass/Fail ExclusiveTo attribute test Type location test Type name case-sensitivity test Type name correctness test General metadata correctness test Properties test Package Sanity check Pass/Fail Platform appropriate files Supported directory structure check Read more about the tests preformed by the WACK After you have built your app's packages, and tested the app with the Windows App Certification Kit, you're ready to begin the submission process. To submit an app, you'll need to sign into your Windows Store Dashboard. (You can get there by clicking the "Dashboard" link near the top of any page in the Windows Store apps Developer Center.) 1. In your Windows Store Dashboard and click Submit an app. This takes you to the Release summary page, which lists the steps that get your app ready for Windows Store certification. Note: If you've already reserved an app name, you will see a tile on the Dashboard for that app. If that's the case, click the app tile instead of Submit an app 2. Click App Name to enter and reserve the name of your app, if you haven't already done so. 3. Click Selling details to supply info such as your app's price, category and subcategory, and markets. 4. Click Services to configure features such as push notifications and in-app purchases. 5. Click Age rating and ratings certificates to select the age rating for your app and upload any ratings certificates. 6. Click Cryptography to declare whether your app uses any cryptography. 7. Click Packages to upload your app's packages. 8. Click Description to enter your app's description. 9. Click Notes to testers to provide the certification testers with info that will help them test your app. 10. Finally, Click Submit for certification to submit your app. • Start playing with and learning the exciting advanced features of Unity (unity3d.com/learn) • Enhancing your game with some of the Windows Store and Windows Phone platform features like: – Tiles & push notifications – Splash Screen Image – Share and Search • Bring your game to the Windows Store and become famous (Become a Windows Phone & Windows Store Developer) ©2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
© Copyright 2025 Paperzz