Yu-Gi-OhInScheme

John Stone
Nicholas Muszynski
December 7, 2014

Overview

Yu-Gi-Oh! in Scheme enables players to play the game without owning the cards. Advanced users can also add new cards, and create new decks to play with.

Screenshot

  • Lists are a fundamental part of the program. Almost all of the information are stored in them.
  • Because of the extensive use of lists, a healthy amount of Recursion was implemented as well to traverse them.
  • Last, but not least, the iconic concept of Scheme: Lambda, which was used for button events, saving namespace, and looking really cool.

External Technology and Libraries

  • Racket/GUI The GUI library was the main library used to design the interface of the program.
  • Racket/Draw The Draw library was used to assign pictures to variables, which were to be used in the GUI library.
  • External data The external data used in the program were pictures of the cards, taken from various websites.

Favorite Lines of Code

Each partner should identify a favorite line of code, Scheme expression, or entire procedure written by himself / herself in the entire project, and explain what it does. E.g.:

  • John Stone:

(define (shuffle-and-load decklist)

  (clear-cards)
  (set! deck (shuffle decklist)))

This is a simple but effective way of shuffling and loading a new deck. (clear-cards) erases all the cards from all the game zones. After that the list of cards decklist is loaded and shuffled by the built in function (shuffle).

  • Nicholas Muszynski:

list - The specific list of cards you want to access (e.g., your hand).

zone-position - The place in the list of the card you want to access (e.g., the third card).

mode - What version of the picture do you want? (e.g., 0 is face-down, 1 is face-up).

(define (get-card-image list zone-position mode)

  (if (not (eq? list '()))                                       ;If the list isn't null...
      (if (> zone-position 1)                                    ;...And if you're not at the right position yet...
          (get-card-image (cdr list) (- zone-position 1) mode)   ;...Then move to the next position and go through procedure again.
          (card-check (get-name list) mode))                     ;...Else, return the image of the card that you're looking for.
      (begin (get-card-image-error)                              ;...If the list is null, then make a pop-up error message...
             EmptySmall)))                                       ;...And give back a blank image as consolation.

This is my favorite part of the GUI code, because of how integral it is to everything. Nearly everything in the code calls this function in some way or another, because it gives the caller the image that represents a specific card. Something else somewhat related to this that I find very interesting, is that the images are given to a function that 'sets' the label for a card. Normally, a label is a string, but if you pass it an image, it will accept that as well, and cover the button (aka. the card you click on) with the image that represents that card. However, if you pass it an integer, it throws an error. Will take a picture, but won't take a number.

Technology Used Block Diagram