User Tools

Site Tools


notes:data:spring2024:projects:cgfx

This is an old revision of the document!


CGFX

STANDARD 52-CARD DECK

VALUES

A standard deck has 13 values on the face of the card:

  • Ten “Number Values”, starting at the Ace “A”, and going up to 10.
  • Three “Face Values”, which are the Jack, Queen, and King.

SUITES

A standard deck of playing cards are divided into four suits, which are also grouped into colors:

  • Red:
  • Diamonds
  • Hearts
  • Black:
  • Spades
  • Clubs

doubly linked stack

A doubly linked list is nearly similar to a singly linked list, as it is a list of structs, where each struct has a pointer to the next struct in the list.

However, in a doubly linked list, each struct also has a pointer which points to the last struct in the list. This means functions can be used to go back and forth through the list, instead of just going one way.

Stack Struct

A separate struct can be created specifically for the stack. This struct will need pointers to the structs being used for the cards and piles.

Another option is to initialize the stack using the pile struct. since the stack is it's own pile, it does not need to be in a list with other piles.

Function to Create Stack

struct Pile {
    // Other Data Needed for Pile
    Card* firstCard;
};
 
void main(void) {
 
    Pile* Stack = (Pile*)malloc(sizeof(Pile));
 
    // Set Stack to be Empty
    Stack->firstCard = NULL;
}

LIFO/FILO

LIFO and FILO are both used to describe a way to insert and retrieve data from a data structure.

LIFO stands for Last In First Out, which means the last element to be put into the data structure is the first to be retrieved. This is the main method for pushing and popping data from a stack.

FILO stands for First In Last Out, which is another term for the same process.

size: bounded vs unbounded

top

push

stack overflow

When pushing data to the stack, it is important to not push too much data onto the stack, as a stack overflow can occur.

In a stack overflow, there are so many elements pushed onto it, that the stack data starts overlapping with the program data in RAM, which can cause severe errors when the program then tries to read that data.

To solve this, make sure that whatever gets pushed to the stack gets popped at some point before moving on.

pop

stack underflow

peek

card game: freecell

foundations

Foundation logic

storage

tableau

pile

notes/data/spring2024/projects/cgfx.1710252341.txt.gz · Last modified: 2024/03/12 14:05 by rspringe