SlideShare a Scribd company logo
1 of 13
Tetris
Artificial Intelligence Applied to Tetris
Jisha Kambo
Spandana Govindgari
Sam Chen
Introduction
Tetris is a classic tile-matching puzzle game.
Originally developed by Alexey Pajitnov, an artificial
intelligence researcher.
Culturally significant.
Tetris is NP-Complete
- Tetris is NP-complete to:
- Maximize the number of cleared rows
- Maximize the number of tetrises
- Minimize the maximum height of an occupied
square
- Maximize the number of pieces placed before the
game ends.
Therefore, we use heuristics to evaluate each step of the
game!
Apply Greedy Best First Search
Heuristic function defined by (H(f)):
f is possible state of the game board
h(f) = c0*h0 + c1*h1 + c2*h2 +c3*h3 + c4*h4 + c5*h5
where ci , i<= 0 <=5
h0 = the number of holes in the playfield
h1 = the altitude of the higher full cell in the playfield
h2 = the number of full cells in the playfield
h3 = the value of the higher slope in the playfield
h4 = the roughness
h5 = the number of full cells in the playfield weighted by altitude
The ideal state is the one with the lowest heuristic score!
Generating possibilities
Depth 1
Generate possibilities for all
positions and orientations of the
piece.
Depth 2
For each depth 1 board, generate
possibilities with the next piece.
It works!
DEMO
Experimentation
1. Compare game play with different weights for the
heuristic function against baseline.
2. Compare depth 1 with depth 2 heuristic search
Baseline
1. pick orientation and position that leaves least number
of buried holes
2. random dropping
Game Scoring: 10 point/per piece dropped + # rows
cleared*100
Scores
In general, Depth 2 performs much better than Depth 1
Best Scores of AI:
- Depth 1 Searching: 1750 with 11 rows cleared and slope = 0.02
- Depth 2 Searching: 1850 with 12 rows cleared and slope = 20 and
roughness 0
Some Interesting Results
Our AI performs much better than the random baseline as
well as baseline where we optimize for number of holes
Pile Height: With regards to the full cell altitude, the higher
the weight the lower is the score and the lower the weight
the greater is the score (inversely proportional).
Analysis contd..
Roughness: Increasing the weight for number of holes
increases the score (directly proportional).
Full Cell count: For full cells, the more the weight the
better is the score (directly proportional).
Increasing Search Depth
Search Depth: Increasing the search depth by two overall,
increases the score however for some special cases.
Too much information can be sometimes bad.
Providing roughness as a heuristic is detrimental for depth
2 search.
Questions?
References
1. Tetris GUI Implementation: https://github.com/jakesgordon/javascript-tetris
2. http://totologic.blogspot.com/2013/03/tetris-ai-explained.html
3. Tetris AI Generation Using Nelder-Mead and Genetic Algorithms by D. Rollinson and G. Wagner
https://www.andrew.cmu.edu/user/drollins/Dave%20Rollinson/16-899C%20ACRL/DB3B8757-
423A-4E88-A495-EC1BB32DEE04_files/tetris_writeup.pdf
3. http://www.cs.uml.edu/ecg/pub/uploads/AIfall10/eshahar_rwest_GATetris.pdf
4. http://erikdemaine.org/papers/Tetris_TR2002/
5. https://codemyroad.wordpress.com/2013/04/14/tetris-ai-the-near-perfect-player/
6. http://www.colinfahey.com/tetris/tetris.html
7. https://www.atagar.com/applets/tetris3D/tetrisAI.php

More Related Content

What's hot

Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 
AI search techniques
AI search techniquesAI search techniques
AI search techniquesOmar Isaid
 
How to make people love your game in 90 seconds or less
How to make people love your game in 90 seconds or lessHow to make people love your game in 90 seconds or less
How to make people love your game in 90 seconds or lessDori Adar
 
Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)Falak Chaudry
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAsst.prof M.Gokilavani
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data StructureJeanie Arnoco
 
NN_02_Threshold_Logic_Units.pdf
NN_02_Threshold_Logic_Units.pdfNN_02_Threshold_Logic_Units.pdf
NN_02_Threshold_Logic_Units.pdfchiron1988
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sortKrish_ver2
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data StructureMeghaj Mallick
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
Quick sort-170316064200
Quick sort-170316064200Quick sort-170316064200
Quick sort-170316064200ifeanyiokeke3
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingShakil Ahmed
 

What's hot (20)

Big o notation
Big o notationBig o notation
Big o notation
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
AI search techniques
AI search techniquesAI search techniques
AI search techniques
 
How to make people love your game in 90 seconds or less
How to make people love your game in 90 seconds or lessHow to make people love your game in 90 seconds or less
How to make people love your game in 90 seconds or less
 
Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)Alpha-beta pruning (Artificial Intelligence)
Alpha-beta pruning (Artificial Intelligence)
 
AI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptxAI_Session 7 Greedy Best first search algorithm.pptx
AI_Session 7 Greedy Best first search algorithm.pptx
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
 
Computer chess
Computer chessComputer chess
Computer chess
 
Selection sort
Selection sortSelection sort
Selection sort
 
Optimization Using Evolutionary Computing Techniques
Optimization Using Evolutionary Computing Techniques Optimization Using Evolutionary Computing Techniques
Optimization Using Evolutionary Computing Techniques
 
Greedy method
Greedy method Greedy method
Greedy method
 
NN_02_Threshold_Logic_Units.pdf
NN_02_Threshold_Logic_Units.pdfNN_02_Threshold_Logic_Units.pdf
NN_02_Threshold_Logic_Units.pdf
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Quick sort-170316064200
Quick sort-170316064200Quick sort-170316064200
Quick sort-170316064200
 
Quadratic probing
Quadratic probingQuadratic probing
Quadratic probing
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Hash table
Hash tableHash table
Hash table
 

More from Spandana Govindgari

More from Spandana Govindgari (7)

Recap: OSCON 2015
Recap: OSCON 2015Recap: OSCON 2015
Recap: OSCON 2015
 
Case for Diversity In Tech
Case for Diversity In TechCase for Diversity In Tech
Case for Diversity In Tech
 
GoLang Introduction
GoLang IntroductionGoLang Introduction
GoLang Introduction
 
Case for cornellitix outsourcing
Case for cornellitix outsourcingCase for cornellitix outsourcing
Case for cornellitix outsourcing
 
Sensors for detection
Sensors for detectionSensors for detection
Sensors for detection
 
Playful Presentation
Playful PresentationPlayful Presentation
Playful Presentation
 
Calculus BC
Calculus BCCalculus BC
Calculus BC
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 

Making a computer play Tetris

  • 1. Tetris Artificial Intelligence Applied to Tetris Jisha Kambo Spandana Govindgari Sam Chen
  • 2. Introduction Tetris is a classic tile-matching puzzle game. Originally developed by Alexey Pajitnov, an artificial intelligence researcher. Culturally significant.
  • 3. Tetris is NP-Complete - Tetris is NP-complete to: - Maximize the number of cleared rows - Maximize the number of tetrises - Minimize the maximum height of an occupied square - Maximize the number of pieces placed before the game ends. Therefore, we use heuristics to evaluate each step of the game!
  • 4. Apply Greedy Best First Search Heuristic function defined by (H(f)): f is possible state of the game board h(f) = c0*h0 + c1*h1 + c2*h2 +c3*h3 + c4*h4 + c5*h5 where ci , i<= 0 <=5 h0 = the number of holes in the playfield h1 = the altitude of the higher full cell in the playfield h2 = the number of full cells in the playfield h3 = the value of the higher slope in the playfield h4 = the roughness h5 = the number of full cells in the playfield weighted by altitude The ideal state is the one with the lowest heuristic score!
  • 5. Generating possibilities Depth 1 Generate possibilities for all positions and orientations of the piece. Depth 2 For each depth 1 board, generate possibilities with the next piece.
  • 7. Experimentation 1. Compare game play with different weights for the heuristic function against baseline. 2. Compare depth 1 with depth 2 heuristic search Baseline 1. pick orientation and position that leaves least number of buried holes 2. random dropping Game Scoring: 10 point/per piece dropped + # rows cleared*100
  • 8. Scores In general, Depth 2 performs much better than Depth 1 Best Scores of AI: - Depth 1 Searching: 1750 with 11 rows cleared and slope = 0.02 - Depth 2 Searching: 1850 with 12 rows cleared and slope = 20 and roughness 0
  • 9. Some Interesting Results Our AI performs much better than the random baseline as well as baseline where we optimize for number of holes Pile Height: With regards to the full cell altitude, the higher the weight the lower is the score and the lower the weight the greater is the score (inversely proportional).
  • 10. Analysis contd.. Roughness: Increasing the weight for number of holes increases the score (directly proportional). Full Cell count: For full cells, the more the weight the better is the score (directly proportional).
  • 11. Increasing Search Depth Search Depth: Increasing the search depth by two overall, increases the score however for some special cases. Too much information can be sometimes bad. Providing roughness as a heuristic is detrimental for depth 2 search.
  • 13. References 1. Tetris GUI Implementation: https://github.com/jakesgordon/javascript-tetris 2. http://totologic.blogspot.com/2013/03/tetris-ai-explained.html 3. Tetris AI Generation Using Nelder-Mead and Genetic Algorithms by D. Rollinson and G. Wagner https://www.andrew.cmu.edu/user/drollins/Dave%20Rollinson/16-899C%20ACRL/DB3B8757- 423A-4E88-A495-EC1BB32DEE04_files/tetris_writeup.pdf 3. http://www.cs.uml.edu/ecg/pub/uploads/AIfall10/eshahar_rwest_GATetris.pdf 4. http://erikdemaine.org/papers/Tetris_TR2002/ 5. https://codemyroad.wordpress.com/2013/04/14/tetris-ai-the-near-perfect-player/ 6. http://www.colinfahey.com/tetris/tetris.html 7. https://www.atagar.com/applets/tetris3D/tetrisAI.php