This project is to reinforce the basic concepts of scheme that you have learned over the last week and a half. You will only need to use what you have learned so far in lab. In addition, you will learn about another large idea in computer science: data abstraction.
What is data abstraction? Data abstraction is a way of thinking in computer science that allows programmers to not worry about the direct representation of data within the programs that they are writing. One large component of using data abstraction is the concept of "selectors." Selectors are a way to access parts of the data independent of how the internal representation of the data is actually done. In this project, you'll be using selectors to access parts of your poker hand.
In this project, you are forbidden to use the following: recursion, higher-order-functions, as well as anything else not from the first week and a half of lab. Any previous code that you have written is fair game to use, as well as any code that was in the difference between dates case study.
This project is a solo project. No collaboration between students is allowed and any violation of this will be taken as cheating.
In this project, you will be classifying and comparing poker hands. Since we are limited in our tools, we will be working with 3 card poker hands. The following are the types of hands we will be working with (in order of rank):
Card representation: In this project, a hand of 3 cards will be represented by a sentence of 3 words. Each word, representing a card will have a number followed by a suit. We will not use 'a', 'k', 'q', 'j' as in the outranks homework, but the numbers themselves. The suits will be d = diamonds, s = spades, h = hearts, and c = clubs. For example: a hand consisting of "3 of clubs, ace of hearts, jack of clubs" will be represented as (1h 3c 11c). You may assume in this project that all hands are sorted by number. The lowest number will be first and the highest will be the last card. If they are the same number, there is no order of the suits.
Part 1: The first part of the project will be to classify the card hand as defined above. We have given you the skeleton code for the "classify-hand" method. Your job is to define the functions in the skeleton code to make it functional. Inside your definitions, we expect you to USE THE SELECTORS that we have provided for you in the code in order to access the cards/numbers/suits. If not, we will deduct points from the project. You will also find it very annoying if you don't use them.
Part 2: The second part of the project will be to compare two poker hands and return the higher hand. You may use any method you want to do this. However we HIGHLY suggest you use the "classify-hand" method that you wrote in part 1 to do this and then assign each type of hand a value (using a helper function). Hand rankings are defined as above in the project overview, with straight flush being highest. Higher numbers are high (ace is lowest and king is highest), while suit ranking (from lowest to highest) is: diamonds, clubs, hearts, spades. Ties between hand types will be settled accordingly:
The framework code can be found here. Do NOT change the framework code or selectors that we have given you.
The following is a set of sample calls and the outputs you should have. Please adhere to these, as the autograder will be following this.
This project is due one week from now, on July 7, 11:59 pm. You have 3 slip days but use them wisely. To submit the project type "submit mp1" from unix. The filename should be called mp1.scm. Include in the file all code. Your testing file will be called poker-hand-tests.scm