1 / 46

Lecture 10

Lecture 10. Announcements. Next week doesn’t exist. Monday 19 th – Sunday 25 th Nothing is due There is no lecture There are no hours. cs195u – 3D Game Engines. requires cs123 lots of fun make Minecraft ! shop it!. Announcements. Questions?. Lecture 10. Embedded Scripting.

gauri
Download Presentation

Lecture 10

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. Lecture 10 Announcements

  2. Next week doesn’t exist • Monday 19th – Sunday 25th • Nothing is due • There is no lecture • There are no hours

  3. cs195u – 3D Game Engines • requires cs123 • lots of fun • make Minecraft! • shop it!

  4. Announcements Questions?

  5. Lecture 10 Embedded Scripting

  6. Content Management • Designer can make content • Iterate without recompiling • Reload content at runtime • change MMO rules with no downtime

  7. Representing Behavior • How to encode AI or map-specific gameplay? • could use Entity I/O • could use FSMs • Coulduse code to express behavior

  8. Lots of choices • General-purpose • Python (Jython) • Javascript (Rhino) • Ruby (JRuby) • Designed for embedding • Lua • Designed for games • UnrealScript • roll your own

  9. Jython • Create an interpreter • Convert Java objects into Python objects (marshaling) • can also be automatic using reflection • Run Python scripts PythonInterpreter py = newPythonInterpreter(); py.set(“x”, newPyInteger(42)); py.exec(“y = x / 6”); PyObject y = py.get(“y”); py.execfile(“myscript.py”);

  10. Why use 2 languages? • One language would be simpler • no marshaling • Could just use Python • Could just use Java • already can dynamically load code • Core engine needs to be fast • collision detection • physics • rendering • Scripts need to be sandboxed • security • convenience

  11. Complementary Features C++ Scripting language dynamically typed flexible interpreted slower at runtime protection from machine details no memory corruption • statically typed • maintainable • compiled • long build times • direct control of memory • good for CPU-intensive code

  12. Lua • simple for beginners • almost everything is a (hash)table • first-class functions • light and efficient • relatively simple C integration players = { “Peter”, “Paul”, “Mary” } scores = { Mary = 10, Paul = 7, Peter = 8 } table.sort(players, function(i, j) return scores[i] > scores[j] end)

  13. UnrealScript • used in the Unreal Engine (proprietary) • static types • networking concepts • replication • simulation • editor integration • function calls can last several frames • each Entity gets its own logical thread (not OS thread) • much easier than callbacks classFlashLightextendsSpotLightMovable; varFlashLightMyFlashLight; varrepnotifyboolbIsOn; simulatedfunction Toggle() { PlaySound(FlashLightSound); // ... } var() Color CaseColor; reliable server function Pulse() { Toggle(); sleep(0.5); Toggle(); }

  14. YourOwnLanguage • Take cs173 • Implement Python • Learn about language design tradeoffs • Mostly ignores performance • Take a compilers course • Focus more on performance • Implement optimizations • Prof. Reiss has run cs126 in the past C++ Python Haskell Java

  15. Embedded Scripting Questions?

  16. Lecture 10 Procedural Content

  17. Procedural Content WHY PROCEDURAL CONTENT?

  18. What is procedural content? • Procedural content: game content generated in an algorithmic way rather than by a designer • Procedural content generation: the generation of this content via a semi-random process

  19. Generated Content • Procedurally generated content usually implies content generated randomly • All procedural content need not be generated • Content inferred from manual designs • Common to save memory

  20. Classifying Procedural Content • Online vs offline • Necessary vs optional • Random vs parameterized • Constructed vs verified

  21. Why use procedural content? • Historically: memory restrictions required it • Generating by hand is tedious and/or expensive • In the case of procedurally generated content, provide a new experience with every game

  22. Procedural Content Questions?

  23. Procedural Content APPLICATIONS

  24. Procedural Animation • Animating every pose of a character can be difficult • Generate poses by joints and constraints • Can even animate each portion separately

  25. Dynamic Lightmaps • Lightmaps are used to store lighting information separate from textures • Provides significant graphical speedup • Rather than defining them for each object, generate them algorithmically

  26. Natural Textures and Terrain • Perlin noise: generated visual effect that simulates natural texture • Even used in CGI for flames, smoke, clouds etc • Computed by calculating distance to grid vertices then interpolating

  27. Level Generation • Create random level layouts at runtime • Can be used to make dungeons, interiors, cities, maps, etc • Algorithms are numerous and vary by purpose • Popular dungeon algorithm: subdivide dungeon in a binary tree, add a room to each

  28. Design of Level Content • Generate many enemies or weapons with different attributes, then pick those that most satisfy the scenario • Alternatively, generate many levels then evaluate them via a fitness function • Underpins most sandbox games

  29. Dynamic World Generation • Entire game world is generated on the fly • No part of the world is written to disk • Unneeded parts are immediately disposed • Hinges on deterministic generation and a single RNG seed • Used in EVE Online as well as a variety of older games

  30. Instancing In-Game Entities • Each entity has some value randomized • All entities are similar, but have some distinguishing feature • Usually used to create names, faces, item or weapon properties

  31. Dynamic Systems • Model complex behaviors with simple sets of rules • Used for weather, crowds, spreading fire, and other bottom-up effects • Starting to merge with some areas of AI, such as swarm intelligence

  32. Plot and Puzzle Generation • Think of a game’s storyline as a dependency graph • Graph dependencies can be changed • For example, move a key to a random accessible location • Graph structure can be changed • Alters order of events • Can also use natural language processing to create characters and stories

  33. Procedural Content Questions?

  34. Lecture 10 Tips for Final 2

  35. Tips for Final 2 EFFECTIVE PLAYTESTING

  36. Finding Playtesters • CS students are easy targets, try the sun lab or MS lab • Ask nicely • Don’t ask busy people • Keep your audience in mind, however • It probably isn’t all CS students

  37. Don’t Interrupt! • Be a fly on the wall • Say as little as possible • Don’t offer hints or instructions • Your game should speak for itself • You won’t be there to offer instructions when your game is released

  38. When to Interrupt • Player is frustrated or taking too long in a single area • You’re no longer getting good feedback • If the player moves on, you will resume getting good feedback

  39. Keep a Log • What is the player getting stuck on? • Make it smoother • What is the player enjoying? • Emphasize it • What is the player ignoring? • Take it out if it’s unnecessary • Consider having the game keep an automated log

  40. Tips for Final 2 Questions?

  41. Tips for Final 2 JAVA TIP OF THE WEEK

  42. Default Visibility • You already know public, private, protected • What happens when there’s no visibility modifier? • Then the field/method is visible to anything in the same package

  43. A Helpful Table

  44. Some General Visibility Tips • Use private wherever possible • “Encapsulation” • If you have a large amount of protected methods you want truly protected, consider separating them into an interface

  45. Tips for Final 2 Questions?

  46. No Playtesting? Playtest with random people this week!

More Related