Cupcake

Fu with a Side of Fries
Cupcake
Group:
Jeansun Lee
David Coulthart
Jennifer Lee
Russell Irving Klopfer, IV
Alan Yeung
Outline







Introduction
Structure of Cupcake
Sample Program
Testing
Tools Used
Future Development
What We Learned
Introduction

Purpose: create simple board games

Example: Candy Land, Chutes and Ladders




Linear progression over finite number of spaces
Turn-based
Simple winning/moving conditions
Kid-friendly language



Introduction to programming
Fun, creative, easy
Tries to mimic English
Introduction

Target language: Java


Has advantages of Java but…
Designed to be much simpler and more limited than
Java
Structure of Cupcake General Design

Grammar easily translates to Java


Supports:



Therefore TreeWalker outputs CupcakeGame.java
if ( ) { }
for i = 1 to numPlayers { Say Players[i].Name }
Avoids duplicate constructs:


switch-case
while, do-while
Structure of Cupcake Four Basic Components

Setup{…}


Start{…}


Dynamic initialization
 Number of players
 Player names
Turn{…}


Static initialization
 Board size
 Dice sides/number
Actions to perform for the currently active player
Win{…}

What to check after each turn to see if the player won
Structure of Cupcake Reserved Objects




Dice
Board
Players
CurrentPlayer
Structure of Cupcake Internal Functions

User Interaction



Game Play



Say
Ask
RollDice
WinGame
Player Movement



MoveAhead
MoveBack
MoveTo
Sample Program
Setup {
Board.Spaces = 100;
Dice.Sides = 6;
Dice.Number = 1;
}
Start {
Ask "How many players?",
Players.Number;
for i = 1 to Players.Number {
Ask "Please enter player " + i
+ “’s name.", Players[i].Name;
}
}
Turn {
RollDice;
MoveAhead Dice.Value;
if (CurrentPlayer.Space == 89) {
MoveTo 50;
}
}
Win {
if (CurrentPlayer.Position >=
Board.End) {
if (CurrentPlayer.Points >= 20)
{
Say "You won";
WinGame;
} else {
MoveTo
CurrentPlayer.PreviousPosition;
}
}
}
Sample Program - Setup
// First, the programmer sets some
// parameters for game objects.
Setup {
string Answers[]
int i;
string Answer;
string Trivias[] = { "How many months have 28
days?", "How many states in the continental US?"
};
string Answers[] = { "12", "48" };
= { "12", "48" };
Board.Spaces = 100;
Board.Spaces = 100;
Dice.Sides = 6;
Dice.Number = 1;
}
// 100 spaces on the board
// A die has six faces
// There is 1 die.
Sample Program - Start
// Things the game has to address at the beginning.
// Some of it will be default
// but the programmer can change it.
Start {
Ask "How many players will there be?",
Player.Number;
Ask “How...?", Player.Number;
for i = 1 to Player.Number {
Ask "Please enter player\t" + i + "'s name.",
Player[i].Name;
}
}
for i = 1 to Player.Number {
...
}
Sample Program - Turn
Turn {
RollDice;
MoveAhead Dice.Value;
if( CurrentPlayer.Space == 11 ) {
Ask Trivias[1], Answer;
if ( Answer == Answers[1] ) {
Say "Nice job! You got 15 points.";
CurrentPlayer.Points += 15;
} else {
Say "Nice try. YOU LOST 5 POINTS.";
CurrentPlayer.Points -= 5;
}
}
if( CurrentPlayer.Space == 38 ) {
...
}
Say "You have " + CurrentPlayer.Points + "
points.";
}
Sample Program - Win
// Specify what happens when you check to see if someone
wins.
Win {
if (CurrentPlayer.Position >= Board.End) {
if (CurrentPlayer.Points >= 10) {
Say "You won";
WinGame;
} else {
MoveTo Board.Beginning;
}
}
}
Testing

Different tests for each stage of
development



Lexer/parser
 Lots of print statements.
Tree walker
 TreeViewer
 Hand-checking the translated Java code
Compiling and running output Java code
Tools Used

ANTLR


CVS


Tree building, parsing, etc.
Collaborative programming
EMACS
Future Development

Support for more kinds of board games




Play against computer (Artificial Intelligence)
Simpler programming interface




Multiple, non-linear paths
More player interaction (e.g. Monopoly)
Drag-and-drop game elements
WYSIWYG
Improved game GUI
Animation, sound effects, graphics, etc.
What We Learned




Time management is important
Collaboration is difficult
Food makes the world go ‘round
Three Most Difficult Concepts:



#@&*$%! TreeWalker
#@&*$%! TreeWalker
#@&*$%! TreeWalker
Thanks



Chun Li, our helpful TA
Professor Aho
Terence Parr, a.k.a. Mr. ANTLR
Cupcake
…
mmmm.
You
betcha!!