User Tools

Site Tools


haas:fall2023:discrete:projects:cgf0

Corning Community College

CSCS2330 Discrete Structures

PROJECT: Card Game Fun (CGF0)

OBJECTIVE

Lay the framework for exploring various discrete concepts: implement a deck of cards where you can display piles of cards, navigating through and showing each card in the deck (forward and backward).

EDIT

You will want to go here to edit and fill in the various sections of the document:

CGF0

STANDARD 52-CARD DECK

VALUES

A standard deck of playing cards has 52 cards from each of the four suits. There are 13 cards in each suit: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King, from lowest to highest value, and then it loops around.

SUITES

The four suits in a standard deck include hearts, diamonds, spades, and clubs. Spades and clubs are black colored cards, and hearts and diamonds are red. These make up the sub-classes of card types, beyond just their face value.

Structure For Doubly Linked List

A doubly linked list offers us the option to move both backward and forwards in a list. This is done by adding a pointer to the previous node. Here is an example of a structure of a doubly linked list:

struct cardnode
{
    bool Active;
    int cardID;         // Card id to call for displaying
    cardnode* next;    // Pointer to the next card node
    cardnode* prev;    // Pointer to the previous card node
};

We originally had just a pointer next for a single linked list but now we have added a pointer for prev.

Creating a Doubly-linked List

To create our doubly-linked list, we'll undergo a similar process to how we handled our singly-linked list in ttb1. First, we create the first node in our list, then we append onto it.

Creating the first node of the doubly-linked list is almost identical to our previous projects. The only change is that we need to set current→prev (our pointer to the currently selected node on the list) to NULL. Since this is the first node in our list, current→prev will always be equal to NULL.

Adding additional nodes is where it gets more complicated. Before allocating the memory for the next node and moving the current pointer, we'll need to create a temporary pointer (called temp in these examples). This will be used to link up current→prev once we move past the first node. With temp created, the general order you'll want to follow is:

  1. Set temp equal to the current pointer
  2. Allocate the structure memory into current→next.
  3. Move the current pointer to the next node.
  4. Use temp to link back up to current→prev.
  5. Set current→next to NULL.
  6. Free the memory of temp.

To create additional nodes, just repeat these steps.

Setting Up Buttons

To use a keyboard and take input you first need to call the following inside your main function but outside your game loop:

select_gamepad(0);

If you want to set up two buttons, one for moving forward in a deck and one for moving backwards then use the following line:

// Buttons to go back and forth between deck
bool nextcard = (gamepad_button_a() == 1);
bool prevcard = (gamepad_button_b() == 1);

To use button “a” press X and to use button “b” press Z.

By adding these two lines you now have set up your buttons but now need to add some if statements for when they are pressed.

Here is an example of an if statement using button “nextcard”:

if (nextcard)
{
    // Next card in the deck is displayed
}

If button “a” is clicked then the next card in the deck is displayed.

Alternatively, you can use the arrow keys to do the same thing, reading XDirection or YDirection respectively in place of “a” or “b”.

Randomizing Your Deck

To randomize your deck you can use arrays.

int array[a]
 
for (int i = 0; i < a; i++) {
     array[i] = i;
     }
 
for (int i = 0; i < a; i++) {
     int temp = array[i];
     int randomIndex = rand() % 13;
     array[i] = array[randomIndex];
     array[randomIndex] = temp;
}
 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

  • Project must be submit on time, by the deadline.
    • Late submissions will lose 33% credit per day, with the submission window closing on the 3rd day following the deadline.
  • Executed programs must display in a manner similar to provided output
    • output formatted, where applicable, must match that of project requirements
  • Processing must be correct based on input given and output requested
  • Output, if applicable, must be correct based on values input
  • Code must be nicely and consistently indented
  • Code must be consistently written, to strive for readability from having a consistent style throughout
  • Code must be commented
    • Any “to be implemented” comments MUST be removed
      • these “to be implemented” comments, if still present at evaluation time, will result in points being deducted.
      • Sufficient comments explaining the point of provided logic MUST be present
  • No global variables (without instructor approval), no goto statements, no calling of main()!
  • Track/version the source code in your lab46 semester repository
  • Submit a copy of your source code to me using the submit tool by the deadline.

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

52:cgf0:final tally of results (52/52)
*:cgf0:card structure and functional deck [26/26]
*:cgf0:ability to navigate through a dealt pile [26/26]

Pertaining to the collaborative authoring of project documentation

  • each class member is to participate in the contribution of relevant information and formatting of the documentation
    • minimal member contributions consist of:
      • near the class average edits (a value of at least four productive edits)
      • near the average class content change average (a value of at least 1024 bytes (absolute value of data content change))
      • near the class content contribution average (a value of at least 1kiB)
      • no zero-sum commits (adding in one commit then later removing in its entirety for the sake of satisfying edit requirements)
    • adding and formatting data in an organized fashion, aiming to create an informative and readable document that anyone in the class can reference
    • content contributions will be factored into a documentation coefficient, a value multiplied against your actual project submission to influence the end result:
      • no contributions, co-efficient is 0.50
      • less than minimum contributions is 0.75
      • met minimum contribution threshold is 1.00

Additionally

  • Solutions not abiding by spirit of project will be subject to a 50% overall deduction
  • Solutions not utilizing descriptive why and how comments will be subject to a 25% overall deduction
  • Solutions not utilizing indentation to promote scope and clarity or otherwise maintaining consistency in code style and presentation will be subject to a 25% overall deduction
  • Solutions not organized and easy to read (assume a terminal at least 90 characters wide, 40 characters tall) are subject to a 25% overall deduction
haas/fall2023/discrete/projects/cgf0.txt · Last modified: 2023/10/22 09:34 by 127.0.0.1