Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Modelling game economy with Neo4j OSCON

1,695 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: Software
  • Be the first to comment

Modelling game economy with Neo4j OSCON

  1. 1. Modelling Game Economy with Neo4j Yan Cui (@theburningmonk)
  2. 2. 1MILLION USERS ACTIVE DAILY
  3. 3. 250MILLION DAY PER REQUEST
  4. 4. noSQL = MongoDB
  5. 5. stolefrom loves loves enemy enemy A Good Man Goes to War appeared in appeared in appeared in appeared in Victory of the Daleks appeared in appeared in companion companion enemy appeared in appeared in planet prop species species species character character character episode episode
  6. 6. source : http://db-engines.com/en/ranking_categories
  7. 7. Graph DBs are great for modelling complex domains
  8. 8. Leonhard Euler invented Graph Theory in 1736
  9. 9. Leonhard Euler invented Graph Theory in 1736 (that’s 275 years before Edgar Codd formulated the relational model)
  10. 10. Find a walk through the city that would cross each bridge once and only once.
  11. 11. Eliminate features to leave just the land masses and the bridges.
  12. 12. Land masses became vertices, and bridges became edges.
  13. 13. location
  14. 14. 500+ Spots
  15. 15. location episodic
  16. 16. Season 1 London
  17. 17. Season 2 Nan Jing
  18. 18. location episodic multi-player
  19. 19. herebemonstersgame.com iPad buddies
  20. 20. location episodic multi-player RPG
  21. 21. 4000 Items
  22. 22. 800 Recipes
  23. 23. 1500+ Quests
  24. 24. 100+ Monsters
  25. 25. game balancing
  26. 26. item Pricing
  27. 27. item Pricing
  28. 28. item Pricing
  29. 29. item Pricing
  30. 30. I’ll just change this one thing…
  31. 31. manual game balancing is SLOW
  32. 32. it is REPETITIVE
  33. 33. ERROR-PRONE! SUBJECTIVE
  34. 34. there must be a better way...
  35. 35. Hello, Neo4j
  36. 36. catchin
  37. 37. location bait attraction rate catch rate
  38. 38. as a graph in Neo4j
  39. 39. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in
  40. 40. nodes & edges can have! arbitrary properties
  41. 41. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Strength = 502! Speed = 201! Intelligence = 184 Strength = 420! Speed = 210! Technology = 240
  42. 42. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in CatchRate = 0.774
  43. 43. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Buy Price = 20BN! Sell Price = 482 Gold! Sellable = true! …
  44. 44. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in DropRate = 0.1
  45. 45. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_m ake Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hiveharvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in Peryton Fawn Decoy requires Peryton Fawn Decoy makes
  46. 46. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_m ake Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hiveharvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in Peryton Fawn Decoy requires Peryton Fawn Decoy makes
  47. 47. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_m ake Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hiveharvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in Peryton Fawn Decoy requires Peryton Fawn Decoy makes
  48. 48. Bigfoot Alice Lake exists_in Alluring Goat can_attract Bigfoot Toenail Clippings Musket-teer Trap loots can_catch Omar Lake exists_in Yowie Yeti can_catch can_catch Apprentice’s Workshop can_m ake Goat Honey Yeti Fur requires loots makes Alluring Goat Recipe requires requires Beeswax loots Bee Hiveharvests McDonald’s Farm sells loots Goat’s Milk harvests London exists_in Peryton Fawn Decoy requires Peryton Fawn Decoy makes
  49. 49. game balancing (revisited)
  50. 50. impact analysis
  51. 51. What if I increase the price of “White Bread”?
  52. 52. CRAFTS RECIPE ITEMITEM IS_USED_IN
  53. 53. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  54. 54. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb Node-[rel]->Node
  55. 55. CRAFTS RECIPE ITEMITEM IS_USED_IN Node-[rel]->Node
  56. 56. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  57. 57. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  58. 58. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  59. 59. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  60. 60. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  61. 61. RECIPE White Bread IS_USED_IN ITEM CRAFTS MONSTERATTRACTS RECIPE IS_USED_IN ITEM CRAFTS ITEM LOOTS RECIPE IS_USED_IN ITEM CRAFTS IS_USED_IN RECIPEIS_USED_IN CRAFTS
  62. 62. RECIPE White Bread IS_USED_IN ITEM CRAFTS MONSTERATTRACTS RECIPE IS_USED_IN ITEM CRAFTS ITEM LOOTS RECIPE IS_USED_IN ITEM CRAFTS IS_USED_IN RECIPEIS_USED_IN CRAFTS
  63. 63. MATCH! (wb:BaseItem { Name:"White Bread"})! -[rel:CRAFTS | IS_USED_IN*1..]! ->(i:BaseItem)! RETURN i, rel, wb
  64. 64. RECIPE White Bread IS_USED_IN ITEM CRAFTS MONSTERATTRACTS RECIPE IS_USED_IN ITEM CRAFTS ITEM LOOTS RECIPE IS_USED_IN ITEM CRAFTS IS_USED_IN RECIPEIS_USED_IN CRAFTS
  65. 65. RECIPE White Bread IS_USED_IN ITEM CRAFTS MONSTERATTRACTS RECIPE IS_USED_IN ITEM CRAFTS ITEM LOOTS RECIPE IS_USED_IN ITEM CRAFTS IS_USED_IN RECIPEIS_USED_IN CRAFTS
  66. 66. RECIPE White Bread IS_USED_IN ITEM CRAFTS MONSTERATTRACTS RECIPE IS_USED_IN ITEM CRAFTS ITEM LOOTS RECIPE IS_USED_IN ITEM CRAFTS IS_USED_IN RECIPEIS_USED_IN CRAFTS
  67. 67. scarcity analysis
  68. 68. How scarce is “Durian” compared to “Dragonfruit”?
  69. 69. EXISTS_IN FRUIT TREE SPOTFRUIT FORAGES
  70. 70. MATCH! ! (fruit)<-[:FORAGES]-(tree)-[:EXISTS_IN]->(spot)! WHERE! ! fruit.Name=‘Durian’ OR! fruit.Name=‘Dragonfruit’! RETURN fruit, tree, spot
  71. 71. MATCH! ! (fruit)<-[:FORAGES]-(tree)-[:EXISTS_IN]->(spot)! WHERE! ! fruit.Name=‘Durian’ OR! fruit.Name=‘Dragonfruit’! RETURN fruit, tree, spot Node<-[r1]-Node-[r2]->Node
  72. 72. EXISTS_IN FRUIT TREE SPOTFRUIT FORAGES Node<-[r1]-Node-[r2]->Node
  73. 73. MATCH! ! (fruit)<-[:FORAGES]-(tree)-[:EXISTS_IN]->(spot)! WHERE! ! fruit.Name=‘Durian’ OR! fruit.Name=‘Dragonfruit’! RETURN fruit, tree, spot
  74. 74. Durian Dragonfruit
  75. 75. quest lines
  76. 76. AWARDS QUEST ITEMITEM REQUIRES UNLOCKS
  77. 77. What quests come after “Year of the Horse”?
  78. 78. MATCH! (q1:Quest { Name: “Year of the Horse” })! -[:UNLOCKS]! ->(q2:Quest) ! RETURN q1, q2
  79. 79. How do you model quest progression?
  80. 80. 1. Price Items 2. Enrich Model 3. “Price” Quests
  81. 81. monster hierarchy
  82. 82. Catch me No, catch ME
  83. 83. IS_USED_IN CAN_ATTRACT ITEMMONSTER LOOTS RECIPE CRAFTSITEMMONSTER
  84. 84. MATCH! (monster1:Monster)-[:LOOTS]->(loot)! -[r:IS_USED_IN | CRAFTS*0..]->(bait)! -[:CAN_ATTRACT]->(monster2)! RETURN monster1, monster2
  85. 85. MATCH! (monster1:Monster)-[:LOOTS]->(loot)! -[r:IS_USED_IN | CRAFTS*0..]->(bait)! -[:CAN_ATTRACT]->(monster2)! RETURN monster1, monster2
  86. 86. Monster 1Monster 2 Quest 1 Quest 2 Unlocks Unlocks
  87. 87. Requires Monster 1Monster 2 Quest 1 Quest 2 Unlocks Unlocks Requires
  88. 88. successful catch = loot + gold
  89. 89. ∑(Bait Price * Attraction Rate) Input = Output ( ∑(Loot Price * Drop Rate) + Gold ) * Success Rate
  90. 90. IS_USED_IN CAN_ATTRACT ITEMMONSTER LOOTS RECIPE CRAFTSITEMMONSTER
  91. 91. NEW monster ! = More competitor for bait! = Lower attraction rate for all monsters
  92. 92. Graph DBs are great for modelling complex domains
  93. 93. impact analysis
  94. 94. fraud detection
  95. 95. social networks
  96. 96. recommendation engine
  97. 97. graphdatabases.com
  98. 98. Thank you! @theburningmonk theburningmonk.com github.com/theburningmonk

×