Modelling game economy with Neo4j

31,366 views

Published on

In this talk I discussed the various ways in which we utilise Neo4j and data modelling with graphs to helps us model and automate the complex in-game economy in our MMORPG title Here Be Monsters.

Published in: Technology

Modelling game economy with Neo4j

  1. 1. Modelling game economy ! with Neo4j
  2. 2. agenda
  3. 3. Hi, my name is Yan Cui.
  4. 4. 1MDAILY ILLION USERS ACTIVE
  5. 5. 250 MILLION DAY REQUEST PER
  6. 6. location
  7. 7. 500+ Spots
  8. 8. location episodic
  9. 9. London 2012
  10. 10. Nan Jing 2013
  11. 11. location episodic multi-player
  12. 12. herebemonstersgame.com iPad buddies
  13. 13. location episodic multi-player RPG
  14. 14. 4000 Items
  15. 15. 800 Recipes
  16. 16. 1500+ Quests
  17. 17. 100+ Monsters
  18. 18. game balancing
  19. 19. item Pricing
  20. 20. item Pricing
  21. 21. item Pricing
  22. 22. item Pricing
  23. 23. manual game balancing is SLOW
  24. 24. it is REPETITIVE
  25. 25. ERROR-PRONE! SUBJECTIVE
  26. 26. there must be a better way...
  27. 27. Hello, Neo4j The rabbit hole sounds pretty good right about now!
  28. 28. catching BIGFOOT
  29. 29. catch rate location bait attraction rate
  30. 30. as a graph in Neo4j
  31. 31. Bigfoot Alice Lake exists_in exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake
  32. 32. Bigfoot Alice Lake exists_in exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake Strength = 502! Speed = 201! Intelligence = 184 Strength = 420! Speed = 210! Technology = 240
  33. 33. Bigfoot Alice Lake exists_in exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake CatchRate = 0.774
  34. 34. Bigfoot Buy Price = 20BN! Sell Price = 482 Gold! Sellable Alice = Lake true! … exists_in exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake
  35. 35. DropRate = 0.1 Bigfoot Alice Lake exists_in exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake
  36. 36. Bigfoot Alice Lake exists_in exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake
  37. 37. Bigfoot Alice Lake exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_make Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hive harvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in requires Peryton Fawn Decoy Recipe Peryton Fawn Decoy makes
  38. 38. Bigfoot Alice Lake exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_make Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hive harvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in requires Peryton Fawn Decoy Recipe Peryton Fawn Decoy makes
  39. 39. Bigfoot Alice Lake exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_make Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hive harvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in requires Peryton Fawn Decoy Recipe Peryton Fawn Decoy makes
  40. 40. Bigfoot Alice Lake exists_in can_attract Alluring Goat Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_make Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hive harvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in requires Peryton Fawn Decoy Recipe Peryton Fawn Decoy makes
  41. 41. 8000+ Nodes
  42. 42. 40000+ Edges
  43. 43. game balancing (revisited)
  44. 44. impact analysis
  45. 45. What’s the impact of upping the price of “White Bread”?
  46. 46. ITEM ITEM CRAFTS RECIPE IS_USED_IN
  47. 47. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  48. 48. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! Node-[rel]->Node RETURN i, rel, wb
  49. 49. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  50. 50. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  51. 51. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  52. 52. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  53. 53. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  54. 54. scarcity analysis
  55. 55. How scarce is “Durian” compared to “Dragonfruit”?
  56. 56. FRUIT SPOT EXISTS_IN FORAGES FRUIT TREE
  57. 57. MATCH! ! (fruit)<-[:FORAGES]-(tree)! -[:EXISTS_IN]->(spot)! WHERE! ! fruit.Name=‘Durian’ OR! fruit.Name=‘Dragonfruit’! RETURN fruit, tree, spot
  58. 58. MATCH! ! (fruit)<-[:FORAGES]-(tree)! -[:EXISTS_IN]->(spot)! Node<-[WHEREr1]-! ! Node-[r2]->Node fruit.Name=‘Durian’ OR! fruit.Name=‘Dragonfruit’! RETURN fruit, tree, spot
  59. 59. MATCH! ! (fruit)<-[:FORAGES]-(tree)! -[:EXISTS_IN]->(spot)! WHERE! ! fruit.Name=‘Durian’ OR! fruit.Name=‘Dragonfruit’! RETURN fruit, tree, spot
  60. 60. quest lines
  61. 61. ITEM ITEM AWARDS QUEST REQUIRES UNLOCKS
  62. 62. What quests come after “Year of the Horse”?
  63. 63. MATCH! (q1:Quest { Name: “Year of the Horse” })! -[:UNLOCKS]! ->(q2:Quest) ! RETURN q1, q2
  64. 64. How do you model quest progression?
  65. 65. 2. Enrich Model 1. Price Items 3. “Price” Quests
  66. 66. monster hierarchy
  67. 67. Catch me first. No, catch ME first.
  68. 68. MONSTER ITEM IS_USED_IN LOOTS RECIPE CRAFTS MONSTER ITEM CAN_ATTRACT
  69. 69. MATCH! (monster1:Monster)-[:LOOTS]->(loot)! -[r:IS_USED_IN | CRAFTS*0..]->(bait)! -[:CAN_ATTRACT]->(monster2)! RETURN monster1, monster2
  70. 70. Σ(Bait Price * Attraction Rate) Input = Output Σ(Loot Price * Drop Rate) + Gold
  71. 71. MONSTER ITEM IS_USED_IN LOOTS RECIPE CRAFTS MONSTER ITEM CAN_ATTRACT
  72. 72. NEW monster ! = More competitor for bait! = Lower attraction rate for all monsters
  73. 73. getting data into NEO4J
  74. 74. version control Game Design data
  75. 75. What changed! When did it change! Why did it change! Who changed it
  76. 76. allow multi-user editing
  77. 77. GitFlow! ! - branching strategy for Git! - used by all our developers!
  78. 78. Publisher - Validate! - Localize! - Publish
  79. 79. Publisher Flash iOS Server Neo4j
  80. 80. test data changes in isolation
  81. 81. preview changes on live
  82. 82. Localization
  83. 83. more text than first three Harry Porter books!
  84. 84. Step 1. ! ingest gettext file
  85. 85. Step 2. ! intercept string property setters
  86. 86. Step 3. ! replace string
  87. 87. Step 4. ! repeat for next language
  88. 88. intercept string property setters
  89. 89. intercept string property setters
  90. 90. replace string
  91. 91. replace string
  92. 92. target all DTOs!
  93. 93. auto-tuning trapping stats
  94. 94. Monster strength! speed! intelligence Trap strength! speed! technology
  95. 95. Monster strength! speed! intelligence Trap strength! speed! technology Catch Rate %
  96. 96. trial-and-error
  97. 97. error-prone trial-and-error laborious sub-optimal
  98. 98. genetic algorithms (in F#)
  99. 99. auto-tuning baits
  100. 100. auto-tuning baits
  101. 101. LONDON 2.0 we rewrote the entire season 1 ! quests to make them better.
  102. 102. TWICE THE FUN
  103. 103. SEASON 1 SEASON 1! (POST-REWRITE) SEASON 2
  104. 104. MORE STREAMLINED
  105. 105. QUALITY > QUANTITY
  106. 106. TWICE THE AMOUNT SUPPORT TO
  107. 107. Neo4j to the rescue!
  108. 108. Thank you!
  109. 109. theburningmonk.com @theburningmonk github.com/theburningmonk

×