Design Patterns for Games Proceedings of the 33 rd SIGCSE technical symposium on Computer Science Education Melisa Tyira SE510.

Slides:



Advertisements
Similar presentations
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Advertisements

Design Patterns for Games Stephen Wong Dung Nguyen Rice University.
 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Copyright © Active Frameworks, Inc.. - All Rights Reserved - V2.0 Introduction - Page L1-1 PS95&96-MEF-L1-1 Dr. M.E. Fayad Creationa l Paradigm.
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Software Engineering I Object-Oriented Design Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
1 FM Overview of Adaptation. 2 FM RAPIDware: Component-Based Design of Adaptive and Dependable Middleware Project Investigators: Philip McKinley, Kurt.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010.
Introduction to software design patterns For CSE 3902 By: Matt Boggus.
 A set of objectives or student learning outcomes for a course or a set of courses.  Specifies the set of concepts and skills that the student must.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Behavioral Patterns  Behavioral patterns are patterns whose purpose is to facilitate the work of algorithmic calculations and communication between classes.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse.
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 A Discipline of Software Design.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Design Patterns: Introduction. Creational Design Patterns General and reusable solutions to common problems in software design Software University
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Abstract Factory Design Pattern making abstract things.
The Generic Gaming Engine Andrew Burke Advisor: Prof. Aaron Cass Abstract Games have long been a source of fascination. Their inherent complexity has challenged.
Model-Driven Analysis Frameworks for Embedded Systems George Edwards USC Center for Systems and Software Engineering
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
Chapter 10 Analysis and Design Discipline. 2 Purpose The purpose is to translate the requirements into a specification that describes how to implement.
GoF Sections Design Problems and Design Patterns.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns Gang Qian Department of Computer Science University of Central Oklahoma.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Design Patterns Introduction General and reusable solutions to common problems in software design SoftUni Team Software University
ECE450S – Software Engineering II
CSC 480 Software Engineering Design With Patterns.
DESIGN PATTERNS -BEHAVIORAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
Design Patterns Introduction
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 31. Review Creational Design Patterns – Singleton Pattern – Builder Pattern.
Lecture 13.  Failure mode: when team understands requirements but is unable to meet them.  To ensure that you are building the right system Continually.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
Unit II-Chapter No. : 5- design Patterns
Chapter 10 Design Patterns.
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
Design Patterns Introduction
Behavioral Design Patterns
Design Patterns for Games
Design Patterns for Games
Informatics 122 Software Design II
Patterns.
CSC 480 Software Engineering
Design Patterns for Games
Informatics 122 Software Design II
CSC 480 Software Engineering
Design Patterns for Games
Presentation transcript:

Design Patterns for Games Proceedings of the 33 rd SIGCSE technical symposium on Computer Science Education Melisa Tyira SE510

Presentation Topics Design Patterns Overview Design Patterns Overview Intended Purpose of this article Intended Purpose of this article Design Patterns discussed in this article Design Patterns discussed in this article Generalizations Generalizations The Model The Model The Strategy Pattern The Strategy Pattern The State Pattern The State Pattern The Visitor Pattern The Visitor Pattern Min-Max Principle Min-Max Principle Model View Controller Pattern Model View Controller Pattern Tic-Tac-Toe Example Tic-Tac-Toe Example Conclusion Conclusion Questions Questions

Design Patterns Overview Definition: describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution over and over, without ever doing it the same way twice.

Four Essential Elements of a Design Pattern Pattern Name - increases our design vocabulary Pattern Name - increases our design vocabulary Problem – describes when to apply the pattern Problem – describes when to apply the pattern Solution – describes the elements that make up the design Solution – describes the elements that make up the design Consequences – the results and trade-offs of applying the pattern Consequences – the results and trade-offs of applying the pattern

Purpose of Design Patterns Creational – concern the process of object creation Creational – concern the process of object creation Structural – deal with the composition of classes or objects Structural – deal with the composition of classes or objects Behavioral – characterize the ways in which classes or objects interact and distribute responsibility Behavioral – characterize the ways in which classes or objects interact and distribute responsibility

Intended Purpose of Article This article’s intent is to describe the apparent benefits of using design patterns to create two player games that can be easily modified, upgraded, or adapted. While using design patterns to create a design at an abstract level, code can be easily generated and reused.

Design Patterns Discussed in this Article Model View Controller Pattern – the game model, the user interface and the controller between the two Model View Controller Pattern – the game model, the user interface and the controller between the two State Pattern – state of the game board State Pattern – state of the game board Visitor Pattern – provides methods that correspond to various states of the game board Visitor Pattern – provides methods that correspond to various states of the game board Strategy Pattern – implements the min-max algorithm Strategy Pattern – implements the min-max algorithm Command Pattern – communication between the model and the view Command Pattern – communication between the model and the view

Generalizations Two-dimensional game boards Two-dimensional game boards Two Players Two Players Rules of the game define the legal board configurations plus the winning and the draw configurations Rules of the game define the legal board configurations plus the winning and the draw configurations

The Model IBoardModel – interface that abstractly “knows” how to transition from one legal board configuration to another and will reject a request for an illegal move. Each representation represents different types of games INextMoveStrategy – an interface that contains the algorithms used to compute the next move from a board configuration

IBoardModelINextMoveStrategy GameModel

The Strategy Pattern Described by the relationship between GameModel and INextMoveStrategy Described by the relationship between GameModel and INextMoveStrategy Separation of the rules of the game (IBoardModel) and the strategy to make a move (INextMoveStrategy) provides flexibility to reuse the same strategy for different types of games Separation of the rules of the game (IBoardModel) and the strategy to make a move (INextMoveStrategy) provides flexibility to reuse the same strategy for different types of games

The State Pattern Draw Game Player 1 Wins Player 0 Wins Terminal States Non-Terminal StateNo Winner Yet Valid Move State Invalid Move State

The state pattern is used to model both concrete states and superstates The state pattern is used to model both concrete states and superstates Superstates are depicted as abstract superclasses of the concrete states they contain Superstates are depicted as abstract superclasses of the concrete states they contain States and Superstates are contained in an interface, IBoardState States and Superstates are contained in an interface, IBoardState The State Pattern (Cont.)

The Visitor Pattern Used to provide state-dependent abstract behaviors Used to provide state-dependent abstract behaviors The interface, IBoardStatusVisitor contains methods corresponding to the various states of the game board and the game board provides the means to execute the visitors The interface, IBoardStatusVisitor contains methods corresponding to the various states of the game board and the game board provides the means to execute the visitors Only the method associated with the current state of the board is called when the visitor is accepted Only the method associated with the current state of the board is called when the visitor is accepted

Logic (State Pattern and Visitor Pattern) Algorithm to determine the state is executed Visitor’s appropriate method is called Virtual State Virtual State – the visitor’s method is called that corresponds to the state that was determined, without setting the system into a static concrete state

Min-Max Principle V(s) computes the value of a state s V(s) computes the value of a state s V(s) = 1, s is a winning state for that player 1, s is a winning state for that player 0, s is a draw state 0, s is a draw state -1, s is a losing state for that player -1, s is a losing state for that player No Winner Yet: No Winner Yet: max[V(c) | c is a child valid move state of s] if that player moves next max[V(c) | c is a child valid move state of s] if that player moves next min[V(c) | c is a child valid move state of s] if the other player moves next min[V(c) | c is a child valid move state of s] if the other player moves next

Model View Controller Pattern Model Three public methods Must be able to accept a request to make a move by a player to a particular location on the board Must be able to accept a request to make a move by a player to a particular location on the board Must reset to an initial condition Must reset to an initial condition Must be told which player it represents Must be told which player it representsView Four public methods Must be able to be notified of a valid move Must be able to be notified of a valid move Must be told that a specific player has won Must be told that a specific player has won Must be told that the game ended in a draw Must be told that the game ended in a draw Must reset to an initial condition Must reset to an initial condition Needs mechanism for communicating a rejected move

Tic-Tac-Toe Example Game Model – two player board game two player board game does not contain code specific to Tic-Tac-Toe does not contain code specific to Tic-Tac-Toe Moderates the interactions between the board (IBoardModel) and the strategy (INextMoveStrategy) Moderates the interactions between the board (IBoardModel) and the strategy (INextMoveStrategy) States – Terminal Superstate – ATerminalState Terminal Superstate – ATerminalState Concrete States – Player0WonState, Player1WonState, DrawState Concrete States – Player0WonState, Player1WonState, DrawState Virtual States – Invalid Move and Valid Move Virtual States – Invalid Move and Valid Move Visitors - Handle communication to and from the GameModel and the IBoardModel Handle communication to and from the GameModel and the IBoardModel Visitors Visitors IBoardStatusVisitor IBoardStatusVisitor ICheckMoveVisitor ICheckMoveVisitor IBoardLambda IBoardLambda

Conclusion Design patterns are used to achieve proper abstractions and decoupling Design patterns are used to achieve proper abstractions and decoupling The system design can be easily modified, upgraded or adapted The system design can be easily modified, upgraded or adapted Code for one game can easily be changed to handle another game Code for one game can easily be changed to handle another game Single use, “throw away” code is not created as a result of this process Single use, “throw away” code is not created as a result of this process REUSE

Nguyen, D. and Wong, S. “Design Patterns For Games”, Proceedings of the 33 rd SIGCSE technical symposium on Computer Science Education, Volume 34, Issue 1, March 2002, Pages 126 – 130.

Questions