Joker a Card Amusement Programming Dialect.


66 views
Uploaded on:
Description
a Card Game Programming Language. Jeffrey Eng. Jonathan Tse. Howard Chu ... card diversions. Briefly portray the guidelines of a card diversion. Make a runtime card diversion motor ...
Transcripts
Slide 1

Joker a Card Game Programming Language Jeffrey Eng Jonathan Tse Howard Chu Timothy SooHoo

Slide 2

Motivation Structure & guideline driven nature of card amusements Succinctly portray the tenets of a card diversion Create a runtime card amusement motor Framework for making standard recreations

Slide 3

Feature Overview Special Pack datatype and administrators Hierarchy revelation Program structure Java-like sentence structure

Slide 4

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

Slide 5

Pack of Cards Deck of cards is implanted in the dialect known as the "pack" sort. basically a super information structure with numerous rundown like operations as a rule, this is a gathering of cards. Can be utilized for the deck, player\'s hands, dispose of heaps, and so on

Slide 6

Pack Operators The estimation of these expressions is a reference to another pack containing the evacuated cards or the recently consolidated cards. theDeck >> 2 //pop (or, arrangement) theDeck << myHand //push theDeck += disCards //enqueue theDeck - = 5 //back-pop (dequeue) theDeck@ //mix myHand[0] //ordered access

Slide 7

War Example diversion 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; //mix the deck theDeck@; //give a large portion of the deck pack player1Hand = (theDeck >> theDeck.size/2); //give alternate ones pack player2Hand = (theDeck >> theDeck.size); }

Slide 8

War Example (cont) principle { for(int turn=0; genuine; turn++) { boolean isDone = false; card oneCard, twoCard; pack prize; int champ; while(isDone != genuine) { /IF they turn out of cards, other player is victor if( player1Hand.size < 1 ) { winner = 2; break; } else if ( player2Hand.size < 1 ) { winner = 1; break; }

Slide 9

War Example (cont) oneCard = (player1Hand >> 1)[0]; twoCard = (player2Hand >> 1)[0]; if(oneCard lt twoCard) { player1Hand += oneCard; player1Hand += twoCard; player1Hand += prize; isDone = genuine; } else if(oneCard gt twoCard) { player2Hand += oneCard; player2Hand += twoCard; player2Hand += prize; isDone = genuine; }

Slide 10

War Example (cont) else { //IF they turn out of cards, other player is victor if( player1Hand.size < 4 ) { winner = 2; break; } else if ( player2Hand.size < 4 ) { winner = 1; break; } //I pronounce war prize += oneCard; prize += twoCard; prize += player1Hand >> 3; prize += player2Hand >> 3; } } } print "The champ is "; print champ; }

Slide 11

Blackjack Example amusement Blackjack { init { int numPlayers = 4; pack DECK; pack [ numPlayers ] playerHands; } main { boolean flipMe = genuine; for (int n = 1; n < = 2; n++) { foreach playerHands as hand{ hand += (DECK >> 1); hand<bottom>.private = flipMe; } flipMe = false;

Slide 12

Blackjack Example (cont) foreach playerHands as hand { while(true) { int aggregate = 0; foreach hand as card { sum += card.value; } option (hand) hit (whole <= 21) {… } stand (entirety <= 21) {… } bust (total > 21) {… } } }

Slide 13

Lessons Learned Communication Divide and vanquish Project plan/points of reference Set sensible objectives Start early Stay concentrated on the center destinations

Recommended
View more...