Table of Contents

DATA notes

Class Notes 8/27 Data/Discrete

Preamble:


-Your soul is now on fire!

-Brief history lesson on tables

-Discussed AI policies, don't do it

-Opening projects: abc0 and btt0, do it

-Next due project, making space invaders (msi0 and after that msi1)

-First four pct's are available as of writing. 0 and 1 are due end of tomorrow.

-Journals / Class documents available

Class Discussion:


msi0 - using malloc'ed ARRAYS of structs, make space invaders. On the screen, the player at the bottom will shoot enemies at the top of the screen. They in the form of a grid, all aligned evenly, and if the player's bolt hits the enemy, they should go away with the bolt. The enemies march to one side of the screen and move down a row. The enemies should also shoot back. The player should die and cause a game over when the enemies either hit the player head-on or if their bolt hits the enemy. Consider have a score count on screen. Other bonus features are optional, like shields or powerups.

In your struct for sprites (sprites being the things on screen), consider an X and Y for each on screen.

*Key instruction, how to form arrays with pointers: Sprite *array = NULL; array = (Sprite *)malloc(sizeof(Sprite) * 15);

msi1 - the same project, but converting msi0 to use a linked list instead of an array, possibly the conversation for Thursday 8/29

Matt's class will make you think so hard, it'll make you physically ill!

*hg log for keeping track of commits

Class Notes 8/29 Data / Discrete

Preamble:


-Shared funny meme about being tortured by the butchering of modern language in general chat.

-Accidently induced severe brainrot on the class.

-Ken and Xavier have never been seen in the same room together. Coincidence?

Class Discussion:


-Worked on projects and other things.

-Next time we will discuss linked lists for msi1.

Class Notes 9/3 Data / Discrete

Preamble:


-btt0 is coming due tomorrow. msi0 is for next Wednesday

-msi1 and msi2 are made available. After 0, we are going to switch over to using data structures. The first to explore is singly-linked lists. The idea is to take the array-based msi0 and update it to linked list stuff. Both msi1/2 are related to singly-linked lists. After 2, the project will involve double-linked lists, an evolution of space invaders maybe.

Class Discussion:


-We talk about HOW to do linked lists.

-First, we know an array has an allocated, fixed amount of space, filled with elements. Can't use more or deallocate less. Big use in C to know how much space we needed exactly. Now that we get into deeper programming, we could have scenarios where we don't know up front how much space exactly we will need. Arrays become impractical “do we need 7 or 17? etc…” In many cases, we cannot declare an array with, per se, one-million entries. In C, we can work around this using pointers and malloc, but still, an amount must be declared up front. Again, arrays can be impractical.

-The first data structure is what is known as a “linked list”. When you start with a list, that list is empty / NULL. When you need a node, you make a node. The first would point to the node, then the node would point to the end, being NULL. If you add more, the node's can point to each other and then to the end eventually. This is nice because you can give / take as many data nodes as you wish / need. The drawback is that arrays can lookup the memory easier. Such is the exchange: conveniance of use vs conveniance of lookups.

-NOT EVERY NODE IS ONE AFTER THE OTHER, ONE NODE DOES POINT TO ANOTHER, BUT AWARENESS OF CONNECTIVITY IS REQUIRED.

-You want to make a node, ideally a struct, and in the struct is the data the node will have. Nodes are the foundation of a linked list.

*In this class, we will explore only a few kinds data structures. There exist many to this day.

*The times, they are a'changin'.

-Nodes need to have a pointer. For singly-linked lists, the nodes need to at least have a “[STRUCT NAME] *next” in vircon bc there is no typedef. “next” comes highly recommended. For msi0, you are probably storing X/Y, alive status etc. These will also need to be in the pointer struct.

-Another thing that comes recommended is a tmp node pointer called tmp. This looks like:

Node *tmp 	= NULL
tmp		= (Node *)malloc(sizeof(Node));

-After creating a node, we want to make sure the next points to NULL. This is the node creation operation.

-You will also want to create a list to chain the nodes together thru appending, obtaining, and maybe inserting.

-Ideally, it would help to have a pointer fixed in place, something like:

Node *start	= NULL;

-Notice how in a singly-linked list, we can only go forawrd, but not back.

-Avoid using “for” loops, because you can't know how many there are in the list forever. Consider conditional processing like “while” loops.

-msi1: take out the array functionality, replace it with linked lists.

-msi2: making many more functions, replacing single linked lists to double linked lists.

Class Notes 9/5 Data / Discrete

Preamble:


-Interesting: Now both Ken and Xavier are missing…

-Lamenting the failures of The Acolyte.

-Discussed past projects that were due yesterday, mainly btt0.

Class Discussion:


-Worked on projects

Class Notes 9/10 Data/Discrete

Preamble:


-Class saved from the 15 minute rule by 40 seconds

-Next week's project is still the same for data and discrete. After next week's project, things will pivoting.

-Discrete's first branch project will be dsr0, “Discrete Skills Review”.

-After that, will be pnc0, “Prime Number Calculator”. This will be the same as the comporg project, minus the assembly.

-As part of msi2, there may be the availability to submit msi2 for 1 and 2 pending understanding of concepts.

-For msi3, the singly linked list becomes a doubly linked list. Where previously there was only “→next”, there will also be a “→prev” and will help tremendously with certain functions like insert() for example.

-Also msi3, expand the game to be something MORE than just Space Invaders, closer to Galaga. Have extra powerups, enemy movement, etc

Class Discussion:


-Looked at msi2 projects page. The functions will be instrumental in not only this project, but the many to come. They are the foundation for future learnings.

Example 1 (calling functions):
      
List *rmlist( List * ); // The function exists

mylist = rmlist( mylist ); // The function is called
      
mylist = obtain( mylist, &tmp ); // passing pointer by address

-When you need to make a list, use mklist().

-To make nodes, use mknode().

-To add nodes, use append() / insert().

-At the end of the process, use clearlist() and rmlist().