SlideShare a Scribd company logo
1 of 126
Download to read offline
Modelling Game Economy
with Neo4j
Yan Cui (@theburningmonk)
1MILLION USERS
ACTIVE
DAILY
250MILLION DAY
PER
REQUEST
noSQL = MongoDB
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
source : http://db-engines.com/en/ranking_categories
Graph DBs are great for
modelling complex domains
Leonhard Euler
invented Graph Theory in 1736
Leonhard Euler
invented Graph Theory in 1736
(that’s 275 years before Edgar Codd
formulated the relational model)
Find a walk through the city that would cross
each bridge once and only once.
Eliminate features to leave just the land masses
and the bridges.
Land masses became vertices, and bridges
became edges.
location
500+ Spots
location
episodic
Season 1 London
Season 2 Nan Jing
location
episodic
multi-player
herebemonstersgame.com
iPad
buddies
location
episodic
multi-player
RPG
4000 Items
800 Recipes
1500+ Quests
100+ Monsters
game
balancing
item
Pricing
item
Pricing
item
Pricing
item
Pricing
I’ll just change this one thing…
manual game
balancing is SLOW
it is REPETITIVE
ERROR-PRONE!
SUBJECTIVE
there must be a
better way...
Hello, Neo4j
catchin
location bait
attraction rate
catch rate
as a graph in Neo4j
Bigfoot
Alice Lake
exists_in
Alluring Goat
can_attract
Bigfoot Toenail Clippings
Musket-teer Trap
loots
can_catch
Omar Lake
exists_in
nodes & edges can have!
arbitrary properties
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
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
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!
…
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
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
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
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
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
game
balancing
(revisited)
impact analysis
What if I increase
the price of
“White Bread”?
CRAFTS
RECIPE ITEMITEM
IS_USED_IN
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
Node-[rel]->Node
CRAFTS
RECIPE ITEMITEM
IS_USED_IN
Node-[rel]->Node
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
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
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
MATCH!
(wb:BaseItem { Name:"White Bread"})!
-[rel:CRAFTS | IS_USED_IN*1..]!
->(i:BaseItem)!
RETURN i, rel, wb
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
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
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
scarcity analysis
How scarce is
“Durian”
compared to
“Dragonfruit”?
EXISTS_IN
FRUIT TREE SPOTFRUIT
FORAGES
MATCH! !
(fruit)<-[:FORAGES]-(tree)-[:EXISTS_IN]->(spot)!
WHERE! !
fruit.Name=‘Durian’ OR!
fruit.Name=‘Dragonfruit’!
RETURN fruit, tree, spot
MATCH! !
(fruit)<-[:FORAGES]-(tree)-[:EXISTS_IN]->(spot)!
WHERE! !
fruit.Name=‘Durian’ OR!
fruit.Name=‘Dragonfruit’!
RETURN fruit, tree, spot
Node<-[r1]-Node-[r2]->Node
EXISTS_IN
FRUIT TREE SPOTFRUIT
FORAGES
Node<-[r1]-Node-[r2]->Node
MATCH! !
(fruit)<-[:FORAGES]-(tree)-[:EXISTS_IN]->(spot)!
WHERE! !
fruit.Name=‘Durian’ OR!
fruit.Name=‘Dragonfruit’!
RETURN fruit, tree, spot
Durian
Dragonfruit
quest lines
AWARDS
QUEST ITEMITEM
REQUIRES
UNLOCKS
What quests come
after “Year of the
Horse”?
MATCH!
(q1:Quest { Name: “Year of the Horse” })!
-[:UNLOCKS]!
->(q2:Quest) !
RETURN q1, q2
How do you model
quest progression?
1. Price Items
2. Enrich Model
3. “Price” Quests
monster hierarchy
Catch me
No, catch ME
IS_USED_IN
CAN_ATTRACT
ITEMMONSTER
LOOTS
RECIPE
CRAFTSITEMMONSTER
MATCH!
(monster1:Monster)-[:LOOTS]->(loot)!
-[r:IS_USED_IN | CRAFTS*0..]->(bait)!
-[:CAN_ATTRACT]->(monster2)!
RETURN monster1, monster2
MATCH!
(monster1:Monster)-[:LOOTS]->(loot)!
-[r:IS_USED_IN | CRAFTS*0..]->(bait)!
-[:CAN_ATTRACT]->(monster2)!
RETURN monster1, monster2
Monster 1Monster 2
Quest 1 Quest 2
Unlocks
Unlocks
Requires
Monster 1Monster 2
Quest 1 Quest 2
Unlocks
Unlocks
Requires
successful
catch
= loot + gold
∑(Bait Price * Attraction Rate)
Input = Output
( ∑(Loot Price * Drop Rate) + Gold ) * Success Rate
IS_USED_IN
CAN_ATTRACT
ITEMMONSTER
LOOTS
RECIPE
CRAFTSITEMMONSTER
NEW monster !
= More competitor for bait!
= Lower attraction rate for all monsters
Graph DBs are great for
modelling complex domains
impact analysis
fraud detection
social networks
recommendation
engine
graphdatabases.com
Thank you!
@theburningmonk
theburningmonk.com
github.com/theburningmonk

More Related Content

More from Yan Cui

How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
Yan Cui
 

More from Yan Cui (20)

How to win the game of trade-offs
How to win the game of trade-offsHow to win the game of trade-offs
How to win the game of trade-offs
 
How to choose the right messaging service
How to choose the right messaging serviceHow to choose the right messaging service
How to choose the right messaging service
 
How to choose the right messaging service for your workload
How to choose the right messaging service for your workloadHow to choose the right messaging service for your workload
How to choose the right messaging service for your workload
 
Patterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdfPatterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdf
 
Lambda and DynamoDB best practices
Lambda and DynamoDB best practicesLambda and DynamoDB best practices
Lambda and DynamoDB best practices
 
Lessons from running AppSync in prod
Lessons from running AppSync in prodLessons from running AppSync in prod
Lessons from running AppSync in prod
 
Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspective
 
How to ship customer value faster with step functions
How to ship customer value faster with step functionsHow to ship customer value faster with step functions
How to ship customer value faster with step functions
 
How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
 
Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSync
 
Build social network in 4 weeks
Build social network in 4 weeksBuild social network in 4 weeks
Build social network in 4 weeks
 
Patterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applicationsPatterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applications
 
How to bring chaos engineering to serverless
How to bring chaos engineering to serverlessHow to bring chaos engineering to serverless
How to bring chaos engineering to serverless
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Building a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQLBuilding a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQL
 
FinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economyFinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economy
 
How to improve lambda cold starts
How to improve lambda cold startsHow to improve lambda cold starts
How to improve lambda cold starts
 
What can you do with lambda in 2020
What can you do with lambda in 2020What can you do with lambda in 2020
What can you do with lambda in 2020
 
A chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage awayA chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage away
 
How to debug slow lambda response times
How to debug slow lambda response timesHow to debug slow lambda response times
How to debug slow lambda response times
 

Recently uploaded

Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Marc Lester
 

Recently uploaded (20)

OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
COMPUTER AND ITS COMPONENTS PPT.by naitik sharma Class 9th A mittal internati...
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
What is an API Development- Definition, Types, Specifications, Documentation.pdf
What is an API Development- Definition, Types, Specifications, Documentation.pdfWhat is an API Development- Definition, Types, Specifications, Documentation.pdf
What is an API Development- Definition, Types, Specifications, Documentation.pdf
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
Reinforcement Learning – a Rewards Based Approach to Machine Learning - Marko...
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptx
 

Modelling game economy with Neo4j OSCON