SlideShare une entreprise Scribd logo
1  sur  70
Télécharger pour lire hors ligne
Writing a
Tile-Matching Game
FP Style
Hakim Cassimally
@osfameron, @lambdamcr
(({:colour :red} {:colour :red} {:colour :red} {:colour :blue} {:colour :blue})
({:colour :green} {:colour :green} {:colour :red} {:colour :red} {:colour :blue})
({:colour :red} {:colour :green} {:colour:blue} {:colour :blue} {:colour :blue})
({:colour :green} {:colour :green} {:colour :green} {:colour :green} {:colour :blue})
({:colour :red} {:colour :green} {:colour :green} {:colour :red} {:colour :blue}))
{:colour :blue
:type :candy}
Match 3
(map (partial partition-by :colour))
(map (partial partition-by :colour))
(map match)
(defn match [groups]
(filter
#(>= (count %) 3)
groups))
(map match)
(defn match [groups]
(filter
#(>= (count %) 3)
groups))
(filter seq)
Er...
[0 0][
[0 0][ [1 0]
[0 0][ [1 0] [2 0]
[0 0][ [1 0] [2 0] [3 0]
[0 0][ [1 0] [2 0] [3 0] [4 0] ]
zip
(defn zip [list1 list2]
(map vector list1 list2))
(defn zip-over-grid [list1 list2]
(map zip list1 list2))
(zip )
(zip )
(zip )
(zip )
(repeat (range)) (map repeat (range))
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
+
=
(defn transpose [m]
(apply map vector m))
(defn points [runs]
(->> runs
(map count)
(apply +)))
= 19
Filling
Filling
Filling
Filling
er....?
Filling
Filling
Filling
Filling
Filling
Filling
Filling
State or Change?
State or Change?
State or Change?
{:colour :blue
:pos [0 1]
:to [1 1]
:animate :fall}
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
{:score 0}
:grid
}
{:score 0}
:grid
}
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
{:score 0}
:grid
:matches
}
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
{:score 0}
:grid
:matches
}
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
{:score 5}
:grid
}
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
{:score 5}
:grid
}
Display
User
Input
Check
Matches
Remove
Matches
Adjust
Score
Fall/Fill
(animate)
{:score 5}
:grid
}
THANK YOU!
Any Questions?

Contenu connexe

Plus de osfameron

Plus de osfameron (8)

Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real World
 
Oyster: an incubator for perls in the cloud
Oyster: an incubator for perls in the cloudOyster: an incubator for perls in the cloud
Oyster: an incubator for perls in the cloud
 
Semantic Pipes (London Perl Workshop 2009)
Semantic Pipes (London Perl Workshop 2009)Semantic Pipes (London Perl Workshop 2009)
Semantic Pipes (London Perl Workshop 2009)
 
Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)Functional Pearls 4 (YAPC::EU::2009 remix)
Functional Pearls 4 (YAPC::EU::2009 remix)
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
Functional Pe(a)rls
Functional Pe(a)rlsFunctional Pe(a)rls
Functional Pe(a)rls
 
Readable Perl
Readable PerlReadable Perl
Readable Perl
 
Bigbadwolf
BigbadwolfBigbadwolf
Bigbadwolf
 

Dernier

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
 

Dernier (20)

Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
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)
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
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
 
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...
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
SQL Injection Introduction and Prevention
SQL Injection Introduction and PreventionSQL Injection Introduction and Prevention
SQL Injection Introduction and Prevention
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024Secure Software Ecosystem Teqnation 2024
Secure Software Ecosystem Teqnation 2024
 
The Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test AutomationThe Strategic Impact of Buying vs Building in Test Automation
The Strategic Impact of Buying vs Building in Test Automation
 
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
 
AI Hackathon.pptx
AI                        Hackathon.pptxAI                        Hackathon.pptx
AI Hackathon.pptx
 
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
 
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
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 

Writing a Tile-Matching Game - FP Style