simulating
play

SIMULATING A FREEZING SOCIETY BUILDING THE AI OF FROSTPUNK HELLO - PowerPoint PPT Presentation

SIMULATING A FREEZING SOCIETY BUILDING THE AI OF FROSTPUNK HELLO IM MACIEJ CZERWONKA GAMEPLAY PROGRAMMER | SIMULATION TEAM GAME DEVELOPER FOR 15 YEARS @Calveit WE ARE HIRING FROSTPUNK AI BUILDING BLOCKS PERFORMANCE FROSTPUNK


  1. SIMULATING A FREEZING SOCIETY BUILDING THE AI OF FROSTPUNK

  2. HELLO I’M MACIEJ CZERWONKA GAMEPLAY PROGRAMMER | SIMULATION TEAM GAME DEVELOPER FOR 15 YEARS @Calveit

  3. WE ARE HIRING

  4. FROSTPUNK AI BUILDING BLOCKS PERFORMANCE

  5. FROSTPUNK

  6. SIMULATION

  7. AI BUILDING BLOCKS

  8. AGENTS

  9. Agent Core simulation element ● Represents a citizen ● Interacts with environment ●

  10. State Agent memory and needs ● Private set of data ● Accessable only for decision ● tree

  11. Perception Eyes and ears of the agent ● Translates environment to ● format usable by decision tree

  12. Decision tree Agent brain ● Has access to state and ● perception Behaviour tree ● Affects the state ●

  13. ACTIVITIES

  14. Activity Verb of a simulation ● Not atomic ● Not an action ●

  15. Activity tree Action factory (produce actions ● for agents) Behaviour tree ● Multiple agents allowed ●

  16. Target selector Matcher (assigns agents to ● objects)

  17. Priority Number ● Decides the order ● Easy to change ● ! Hard to maintain

  18. Activity list One dimensional list ● Decides the order ● Transparency ● Visibility ● ● Cheap maintenance

  19. Preferences Set of values ● Agent decision ● Fallback activities always in the ● collection

  20. Action Controlling agent ● Can influence state ● Can influence visuals ●

  21. Plan Collection of actions ● FIFO ● Fed by activity tree ● Consumed by agent when ● current action is finished

  22. POINT OF INTEREST

  23. Point of interest POI ● Agents perform activities here ● Attached to building or other ● place in the game ● Place can have more than 1 POI

  24. Activity Activity type available at POI ● Each POI declares an activity ●

  25. Conditions Collection of expressions ● Evaluates to boolean value, ● which decides if active

  26. Space Range (eg. 1-10) ● How many agents can perform ● activity here

  27. Target Agent always has a target ● Binds agent with POI ● Idle agents have target ● Dead agents have target ●

  28. Is this model good enough? Doctors leave their patients to build a road ● Children fight in Fight Club ● Hunters return from 3-day expedition to get a snack ● Guards join the protest, they were supposed to disperse ● Prison workers leave their work to bury the dead, letting convicts escape ● No, it is not. We need to distinguish agents!

  29. AGENTS

  30. AGENTS

  31. AGENTS

  32. AGENTS

  33. Features Collection of Label objects ● Label is just a string, can be ● anything Examples: OnExpedition, Female, ● Engineer, Disabled, etc.

  34. POI spaces Collection of Space objects ● Count below minimum is ● forbidden Count over maximum is ● forbidden Only agents with labels in ● Required collection are accepted Agents with labels present on ● Prohibited collection are denied

  35. We have model. What now? Let’s assign agents to POIs.

  36. How to assign agents?

  37. Assignment problem The assignment problem deals with assigning machines to tasks, workers to jobs, soccer players to positions, and so on. The goal is to determine the optimum assignment that, for example, minimizes the total cost or maximizes the team effectiveness. Reference: http://www.hungarianalgorithm.com

  38. Hungarian algorithm Solves assignment problem, ● Developed by Harold Kuhn in 1955, ● Based on work of Hungarian mathematicians ● Dénes K ő nig and Jen ő Egerváry (thus the name Hungarian), Fairly easy to understand, ● Our implementation is based on Topcoder ● article. Reference: http://www.convexoptimization.com

  39. Assignment problem - example Reference: http://www.hungarianalgorithm.com

  40. Assignment problem - example Reference: http://www.hungarianalgorithm.com

  41. Formulating assignment problem

  42. COST FUNCTION? DISTANCE

  43. One activity at a time

  44. One activity at a time

  45. Occupied POIs

  46. Rebalancing

  47. Invalid assignment POI

  48. Minima satisfaction

  49. Minima satisfaction algorithm

  50. Hungarian algorithm

  51. Eliminate POIs with broken minima

  52. Sort spaces by saturation level

  53. Saturate spaces

  54. Results

  55. Targeting overview Determine a target for each agent ● Centralized process, not an agent decision ● One activity at a time ● All agents at a time ● All POIs at a time ● Rebalancing ● Satisfy POI minima ● Kicking an agent is also targeting ● Agent death is also targeting ●

  56. We have model. We have targeting. Are we good?

  57. Let’s see People change houses every day ● Families do not stay together ● People change work every day ● Patients who are almost cured get kicked out of medical posts ● Why does it happen? Distance is not universal cost descriptor!

  58. Target selectors Function which matches agents with POIs ● Activity may want to override default target selector ● Target selector should have its own cost function ● Target selector should decide if it wants rebalancing ● Transparent for targeting ●

  59. Target selector examples NEAREST ● ● Cost descriptor: distance ● No rebalancing ● Use case: construction PERSISTENT ASSIGNMENT ● ● Cost descriptor: assignment ● No rebalancing ● Use case: work MEDICAL TREATMENT ● ● Cost descriptor: distance, but heal the almost cured in the first place, prefer patients who are gravely ill ● Rebalancing ● Use case: healing

  60. Does it work? ● Mass protests are attended by 3 people ● Convict decides not to show up on his execution ● Idle citizens just „stand” there ● Production output is unpredictable Living city still miss reliability Smoke and mirrors!

  61. IDLE BEHAVIOURS

  62. DIRECTED SCENES

  63. INDEPENDENT ECONOMY

  64. INDEPENDENT ECONOMY

  65. INDEPENDENT ECONOMY

  66. PERFORMANCE

  67. Event Driven Behaviour Trees

  68. Budgeting and distributed update

  69. Parallel targeting

  70. Limit number of processed entities Update only dirty agents ● Dirty - kicked out of its POI or changed its preferences since last update ○ Update only dirty points of interest ● Dirty - constructed, upgraded, targeted/left by an agent, state changed ○ Not possible with rebalancing ●

  71. Lessons learned From the very beginning of development, we focused too much on the simulation, failing to achieve living city reliability and economy stability. What we really wanted was not simulation, but experience . We wanted the player to believe that what he/she sees is a city populated with people who behave in reliable manner. We also wanted to have stable economy, which is a core system for a city-builder survival game. Doing this by parametrizing simulation is hard. Having said that, we should not have put most of our effort into the simulation. We should have focused more on player perception of the living city.

  72. THANK YOU

Recommend


More recommend