User Tools

Site Tools


Sidebar

projects

pct0 (bonus; due 20230823)
wcp1 (due 20230823)
abc0 (due 20230830)
btt0 (due 20230830)
pct1 (bonus; due 20230830)
pct2 (due 20230830)
wcp2 (due 20230830)
mpg0 (due 20230906)
pct3 (bonus; due 20230906)
wcp3 (due 20230906)
pct4 (due 20230913)
ttb0 (due 20230913)
wcp4 (due 20230913)
pct5 (bonus; due 20230920)
ttb1 (due 20230920)
wcp5 (due 20230920)
dap0 (due 20230927)
gfo0 (due 20230927)
pct6 (due 20230927)
wcp6 (due 20230927)
cgf0 (due 20231004)
pct7 (bonus; due 20231004)
wcp7 (due 20231004)
bwp1 (bonus; due 20231018)
cgf1 (due 20231018)
pct8 (due 20231018)
wcp8 (due 20231018)
cgf2 (due 20231025)
pct9 (bonus; due 20231025)
wcp9 (due 20231025)
cgf3 (due 20231101)
gfo1 (due 20231101)
pctA (due 20231101)
wcpA (due 20231101)
pctB (bonus; due 20231108)
waq0 (due 20231108)
wcpB (due 20231108)
pctC (due 20231115)
waq1 (due 20231115)
wcpC (due 20231115)
bwp2 (bonus; due 20231129)
pctD (bonus; due 20231129)
wcpD (bonus; due 20231129)
gfo2 (due 20231206)
pctE (bonus; due 20231206)
wcpE (bonus; due 20231206)
EoCE (due 20231214)
haas:fall2023:data:projects:ttb1

Corning Community College

CSCS2320 Data Structures

PROJECT: Transition To Breakout (TTB1)

OBJECTIVE

With a functioning breakout game, replace the malloc'ed array of structs with a singly-linked list of nodes, preserving the same overall functionality.

EDIT

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

TTB1

NODE STRUCT

What is a node struct? A node struct is used to represent an element, in our case, a brick, within a list. The brick structure is mostly unchanged since ttb0, however there is now the addition of the next pointer, which makes it a node struct.

Here's an example of our brick structure with the node struct:

struct BrickNode
{
    bool Active;
    int X, Y;          // Position on screen
    int Width, Height; // Size of hitbox for brick
    BrickNode* next;   // Pointer to the next brick node
};

The purpose of the next pointer is to be the connective tissue that holds our list together. Without it, we will not be able to access the following items in the list.

NODE POINTER

In order to access our list in key areas, we need to create pointers that point towards specific brick structures in our list. For a singly-linked list, we need two pointers:

  • One Pointer that always points towards the very start of the list. We'll call it “start” for these examples.
  • One Pointer that points towards whatever is the last node currently in the list. We'll call it “temp.”

To create these pointers, we set them to the type of our brick structure. That way, after dereferencing the pointer, we'll be able to access any of the variables we assign inside our struct. The code looks like:

BrickNode* start;
BrickNode* temp;

MALLOC A NODE

What is meant by malloc a node? while it is when you dynamically allocate memory and create a new node in a list.

here is an example of what it could possibly look like:

// Creates a new node for each brick
BrickNode* newBrick = (BrickNode*)malloc(sizeof(BrickNode));

Here is a breakdown of what is happening on the left side of the equal sign:

 BrickNode* newBrick 

This declares a pointer variable called newBrick which is of the type BrickNode.

LINKING NODES TOGETHER

Format for linking nodes together:

newBrick->next = BrickList;

This line of code is linking the new brick node into the list. here's how it works:

newBrick

which is a node for each brick, is set to point to the current head of the list essentially putting a new node at the beginning of the list. This is done with

->next = BrickList

TRAVERSING LIST

In a singly-linked list, we can only move in one direction through the list — forward. To move through the list, we need to move our temp pointer to instead point to the next item within the list. This is where our next pointer within our BrickNode struct comes in handy.

If your list is set up properly, ``temp→next`` should be pointing towards another BrickNode structure or a NULL value (if you're at the end of the already-created list). Only traverse through the list if there's a known node to move to, otherwise you'll end up setting temp to NULL. And we don't want that. If all is good, the following command should move the pointer properly and you'll be looking at the next node:

temp = temp->next;

WARNING: Once you've moved the temp pointer forward, there is no way to move it backwards in a singly-linked list! You'll need to set it back to the start pointer at the start of the list!

INSERTING NODE INTO LIST

AT START OF LIST
IN THE MIDDLE OF THE LIST

APPENDING NODE INTO LIST

AT END OF LIST
IN THE MIDDLE OF THE LIST

REMOVING A NODE FROM THE LIST

One of the ways to delete a specific Node from a linked list is to create a function that searches for the node by its properties (e.g. x, and y) and then removes it. The psudo-code would look something like this.

  deleteNode(Node** start-of-list, int x, int y) {
  Node* current =*start-of-list;
  Node* previous= NULL;
  while(current!=NULL){
    if (current_node->x == x && current_node->y == y) {
      if(previous==NULL){
        //node we want to delete from the list is the first node in the list
        *start-of-list =current->next;
      } else{
        //set the previous node's pointer to the current node's pointer
      }
      free(current)
      return;
    }
    //itterate to next brick
    previous= current;
    current=current->next;
  }
  }

In essence we are itterating through the different nodes, and checking if they are the node we want to delete. Make sure to have a catch case for the first node in the list.

AT THE START OF LIST
IN THE MIDDLE OF THE LIST
AT END OF LIST
 

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:

39:ttb1:final tally of results (39/39)
*:ttb1:functional breakout game [13/13]
*:ttb1:linked list implemented and used [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/data/projects/ttb1.txt · Last modified: 2023/09/10 21:02 by 127.0.0.1