Title: Special Topics in Problem Solving Fall 2001
1A Game Framework
- Special Topics in Problem SolvingFall 2001
- Document author Alberto Lerner
(lerner_at_cs.nyu.edu)
2Goal
- Create a proper infra-structure for the
development and the deployment of - 2-player games
- software-based players
32-player games
1. looks at the boardstate (get state)
2. considers possiblemoves (compute move)
PLAYER 1
PLAYER 2
The Board
42-player games
Is the game over?
Is there a winner?
X
PLAYER 1
PLAYER 2
The Board
5Supporting 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?
6Mixing HTML with code
getstate.php
tictactoe.php
lthtmlgt ... lt?php include(game) ?gt lt?php
board2html(...) ?gt
Function board2html() echo(lttablegt)
for(i0 ilt3 i) echo (lttdgt) ...
Independent of the game(getstate.php,
sendmove.php,etc)
One implementation pergame
7How does PHP work?
HTTP Server
Page response
(4)
Page with HTMLonly
Page request
PHPinterpreter
(3)
(1)
(2)
Page with HTML PHP
8Developing 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()
9Interactive Human Players
HTTP Server
PLAYER 1
PLAYER 2
10Players 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
11Developing 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
12Summary
- 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 htmlphp
front-end pages for interactive human or
interactive program plays using the games and
players created by the teams
13References
- PHP www.php.net
- The Game Frameworkwww.cs.nyu.edu/lerner/GameFram
eworkIndex.html