Geoff Klapproth
Jeremie Nieto
December 7, 2014


War! The Card Game is a fully virtual implementation to the classic card game, which also houses an extra feature. Along with the regular rules everyone who has heard of or has played, there is the addition of a betting feature like in casino-style classics. The objective of the game, of course, is to win! This is done by either destroying your opponent in brutal card warfare or stealing all of their hard-gambled cash.


Concepts Demonstrated

  • Data abstraction is used in the betting system to access account balances. It is also used to manipulate the cards.
  • Lambda in-line functions are required for GUI functionality since the button click invokes a callback function.
  • The cards were created using the box structure, which is a protected version of lists of lists, providing protection against changing any values in or to the box structures without using the defined functions.
  • Function modularity was demonstrated through defining sub-functions with specific tasks to reuse for multiple different purposes/cases.

External Technology and Libraries

The GUI code was implemented using the GUI racket library. This provided us with a window for the game containing statistics about the game play that update in real time. interactive buttons for users to click on and run the game. It gave us the drop-down menu to select a bet value for each turn.

The card library was done solely through self-written implementations using built-in functions. NO external libraries were used to drive the card system. However, some GUI code was linked/integrated into the card file when assembling the final product.

Favorite Lines of Code

  • Geoff Klapproth:
(define (update-decks deck1 deck2)
  (set-box! deck2 (cons (first (unbox deck1)) (unbox deck2)))
  (set-box! deck1 (rest (unbox deck1))))

This code takes 2 decks as arguments, deck1 to take a card from, and deck2 to add the card to. This single function updates every deck in play for every turn, using helper functions/add-ons that expand or shrink the decks as needed. This was also probably where I got lost for the longest on trying to understand box structure and manipulate it, so having this work is a thing of beauty.

  • Jeremie Nieto:
(new button% (parent panel)
             (label "WAR!")
             ; Callback procedure calls place-bet() and draw() when clicked
             (callback (lambda (button event)      
                         (smart-bet (+ (deck-getlength AI-deck) (deck-getlength AI-discard)));computer's bet
                         (send show-comp-bet set-label (cvt comp-bet))
                         (place-bet (bet-number) 1);player's bet
                         (send show-your-bet set-label (cvt your-bet))
                         (send show-your-balance set-label (cvt (get-player-balance)))
                         (send show-comp-gui-balance set-label (cvt (get-comp-balance)))
                         (send player-deck-msg-size set-label (cvt (deck-getlength player-deck)))
                         (send comp-deck-size set-label (cvt (deck-getlength AI-deck)))
                         (send AI-total-size set-label (cvt (+ (deck-getlength AI-deck) (deck-getlength AI-discard))))
                         (send player-total-size set-label (cvt (+ (deck-getlength player-deck) (deck-getlength player-discard))))
                         (send show-your-card set-label (display-card player-deck));reveal cards
                         (send show-comp-card set-label (display-card AI-deck))
                         (gameturn);drives the game and draws
                         (balance-check (get-comp-balance) 0)
                         (balance-check (get-player-balance) 1);check balances

This large block of code drives the GUI. This is the code for the "WAR!" button of the game. When this button is clicked, various functions from the betting and card implejmentation files are invoked to progress through a turn. It calls for placing bets, updating the GUI values in real-time, drawing the cards, making the comparison and displaying the right messages.

Technology Used Block Diagram

Additional Remarks

Integrating our code was easy because each of our jobs were largely independent of each other. The GUI was able to call the necessary procedures from each file without having to change the way we implemented the cards or the betting system.