joker a card game programming language l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Joker a Card Game Programming Language PowerPoint Presentation
Download Presentation
Joker a Card Game Programming Language

Loading in 2 Seconds...

play fullscreen
1 / 13

Joker a Card Game Programming Language - PowerPoint PPT Presentation


  • 606 Views
  • Uploaded 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.

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

Joker a Card Game Programming Language


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
    1. Jokera Card Game Programming Language Jeffrey Eng Jonathan Tse Howard Chu Timothy SooHoo

    2. 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

    3. Feature Overview • Special Pack datatype and operators • Hierarchy declaration • Program structure • Java-like syntax

    4. Compiler Architecture *.jkr Lexer Parser Tree Walker Java Backend Classes DEALR

    5. 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.

    6. 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

    7. 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); }

    8. 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; }

    9. 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; }

    10. 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; } }

    11. 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;

    12. 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) {…} } }

    13. Lessons Learned • Communication • Divide and conquer • Project schedule / milestones • Set realistic goals • Start early • Stay focused on the core objectives