Joker a card game programming language
Download
1 / 13

Joker a Card Game Programming Language - PowerPoint PPT Presentation


  • 547 Views
  • Updated On :

Joker a Card Game Programming Language. Jeffrey Eng Jonathan Tse Howard Chu Timothy SooHoo. Motivation. Structure & rule-driven nature of card games Succinctly describe the rules of a card game Create a runtime card game engine Framework for creating standard games. Feature Overview.

Related searches for Joker a Card Game Programming Language

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Joker a Card Game Programming Language' - Sophia


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Joker a card game programming language l.jpg

Jokera Card Game Programming Language

Jeffrey Eng

Jonathan Tse

Howard Chu

Timothy SooHoo


Motivation l.jpg
Motivation

  • Structure & rule-driven nature of card games

  • Succinctly describe the rules of a card game

  • Create a runtime card game engine

  • Framework for creating standard games


Feature overview l.jpg
Feature Overview

  • Special Pack datatype and operators

  • Hierarchy declaration

  • Program structure

  • Java-like syntax


Compiler architecture l.jpg
Compiler Architecture

*.jkr

Lexer

Parser

Tree Walker

Java Backend Classes

DEALR


Pack of cards l.jpg
Pack of Cards

  • Deck of cards is embedded in the language

  • known as the "pack" type.

  • essentially a super data structure with many list-like operations

  • In general, this is a grouping of cards. Can be used for the deck, player's hands, discard piles, etc.


Pack operators l.jpg
Pack Operators

  • The value of these expressions is a reference to a new pack containing the removed cards or the newly combined cards.

  • theDeck >> 2 // pop (or, deal)

  • theDeck << myHand // push

  • theDeck += disCards // enqueue

  • theDeck -= 5 // back-pop (dequeue)

  • theDeck@ // shuffle

  • myHand[0] // indexed access


War example l.jpg
War Example

game War {

init {

pack theDeck;

hierarchy : { A(14), K(13), Q(12), J(11), 10(10), 9(9), 8(8), 7(7), 6(6), 5(5), 4(4), 3(3), 2(2) } by

{ spades(1).hearts.clubs.diamonds } into theDeck;

// shuffle the deck

theDeck@;

// give half the deck

pack player1Hand = (theDeck >> theDeck.size/2);

// give the other ones

pack player2Hand = (theDeck >> theDeck.size);

}


War example cont l.jpg
War Example (cont)

main {

for(int turn=0; true; turn++) {

boolean isDone = false;

card oneCard, twoCard;

pack prize;

int winner;

while(isDone != true) {

// IF they turn out of cards, other player is winner

if( player1Hand.size < 1 ) {

winner = 2;

break;

}

else if ( player2Hand.size < 1 ) {

winner = 1;

break;

}


War example cont9 l.jpg
War Example (cont)

oneCard = (player1Hand >> 1)[0];

twoCard = (player2Hand >> 1)[0];

if(oneCard lt twoCard) {

player1Hand += oneCard;

player1Hand += twoCard;

player1Hand += prize;

isDone = true;

}

else if(oneCard gt twoCard) {

player2Hand += oneCard;

player2Hand += twoCard;

player2Hand += prize;

isDone = true;

}


War example cont10 l.jpg
War Example (cont)

else {

// IF they turn out of cards, other player is winner

if( player1Hand.size < 4 ) {

winner = 2;

break;

}

else if ( player2Hand.size < 4 ) {

winner = 1;

break;

}

// I declare war

prize += oneCard;

prize += twoCard;

prize += player1Hand >> 3;

prize += player2Hand >> 3;

}

}

}

print "The winner is ";

print winner;

}

}


Blackjack example l.jpg
Blackjack Example

game Blackjack {

init {

int numPlayers = 4;

pack DECK;

pack [ numPlayers ] playerHands;

}

main {

boolean flipMe = true;

for (int n = 1; n < = 2; n++) {

foreach playerHands as hand{

hand += (DECK >> 1);

hand<bottom>.private = flipMe;

}

flipMe = false;


Blackjack example cont l.jpg
Blackjack Example (cont)

foreach playerHands as hand {

while(true) {

int sum = 0;

foreach hand as card {

sum += card.value;

}

option (hand)

hit (sum <= 21) {…}

stand (sum <= 21) {…}

bust (sum > 21) {…}

}

}


Lessons learned l.jpg
Lessons Learned

  • Communication

  • Divide and conquer

  • Project schedule / milestones

  • Set realistic goals

  • Start early

  • Stay focused on the core objectives