130 likes | 143 Views
A Game Framework. Special Topics in Problem Solving Fall 2001 Document author: Alberto Lerner (lerner@cs.nyu.edu). Goal. Create a proper infra-structure for the development and the deployment of 2-player games software-based players. X. 3. chooses a move (send move). Tic-Tac-Toe.
E N D
A Game Framework Special Topics in Problem SolvingFall 2001 Document author: Alberto Lerner (lerner@cs.nyu.edu) Special Topics in Problem SolvingFall 2001
Goal • Create a proper infra-structure for the development and the deployment of • 2-player games • software-based players Special Topics in Problem SolvingFall 2001
X 3. chooses a move(send move) Tic-Tac-Toe 2-player games 1. looks at the boardstate (get state) 2. considers possiblemoves (compute move) PLAYER 1 The Board PLAYER 2 Special Topics in Problem SolvingFall 2001
1. looks at the boardstate (get state) ... Tic-Tac-Toe 2-player games Is the game over? Is there a winner? X PLAYER 1 The Board PLAYER 2 Special Topics in Problem SolvingFall 2001
Supporting several games • There is a get state, compute move and send move tasks in most 2-player games • But for each game, the way each one is done changes How can one infra-structure support several games? Special Topics in Problem SolvingFall 2001
Mixing HTML with code getstate.php tictactoe.php <html> ... <?php include($game); ?> <?php board2html(...) ?> Function board2html(…) { … echo(“<table>”); for($i=0; $i<3; $i++) { echo (“<td>”); ... Independent of the game(getstate.php, sendmove.php,etc) One implementation pergame Special Topics in Problem SolvingFall 2001
How does PHP work? HTTP Server Page response (4) Page with HTMLonly Page request PHPinterpreter (3) (1) (2) Page with HTML+ PHP Special Topics in Problem SolvingFall 2001
Developing a game tictactoe.php • Developing a game means implementing the necessaryfunctions for that game in PHP • The framework accepts newgames files via an option on itsmain page • The file is parsed and saved under the name of the game • Interactive play can then be arranged among interested players function newgame() function loadgame()function savegame()function board2html() function board2xml() function mov2html() function mov2xml() function getplayer() function getemail() function getmsg() function whoseturn()function sendmove() Special Topics in Problem SolvingFall 2001
(1) CreateGame.php (2) GetState.php (3) Thinking time (4) SendMove.php E-mail notification (5) Interactive Human Players HTTP Server PLAYER 1 PLAYER 2 Special Topics in Problem SolvingFall 2001
Players can be software (1) PHP spawns an interpreteror an executable program HTTP Server (2) The board state is sent thrustdin (3) Thinkingtime PHPinterpreter (4) The move issent thru stdout PLAYER 1 PLAYER 2 Special Topics in Problem SolvingFall 2001
Developing a player player.??? • Developing a player means implementing the move choicein any tool that can communicatevia pipes • The framework accepts newplayers files via an option on itsmain page • The player file is saved undera player name • Software players can be chosen as adversaries in human-softwareor software-software plays read board state from stdin compute move send move to stdout Special Topics in Problem SolvingFall 2001
Summary • The architecture team implements the necessary back-end php functions for a game and stores it in the framework • The other teams build the software based players and stores them in the framework • The framework provides the necessary html+php front-end pages for interactive human or interactive program plays using the games and players created by the teams Special Topics in Problem SolvingFall 2001
References • PHP www.php.net • The Game Frameworkwww.cs.nyu.edu/~lerner/GameFrameworkIndex.html Special Topics in Problem SolvingFall 2001