User Tools

Site Tools


blog:fall2015:kdarling:start

Kyle Darling's SEMESTER Opus

What's Good

Introduction

I had no clue the Opus made a return but why not start now? I'm Kyle, I have experience in Java, C/C++, and UNIX/Linux. I enjoy programming and playing games as well.

September 03, 2015

< Again sorry for just noticing blog, either I missed a day where we announced this would be the new Opus >

Today in class we reviewed some things on our newest project, these things are the menu's that will be used with it.

The Basic List Operations will be - append - insert - obtain - display

Each of these will represent it's own function, append being added to either the end of between the list after a desired position.

Insert will be inside the list, the very start of the list or before the position given for the program.

Obtain will be grabbing a variable then promptly display it from the list and remove it from the list by setting it equal to NULL and free up the memory.

Display is maybe the hardest part depending on conditions, in this case it's pretty easy by displaying it in a certain manner.

There are more Node operations ( This is at the time I thought it was going to be using Node's and not an Array ).

Node Operations:


- create - copy -remove

Create will create a new node, later we use mknode.

Copy will copy a specific node and throw it into a list.

Remove will throw the desired node out of the list and simply deallocate by freeing the node and set it to NULL for now.

Overall List Structure? - Create - Copy - Clear ( Clear List –> Deallocate everything and to NULL ) - Insert - Append - Obtain

New functions Node *tmp = setpos(myList, i); ( Sets the position ) int i = getpos(myList, tmp); ( Gets the position )

Structure to use struct list {

   struct list *start;
   struct list *end;
   int qty;

}

Here's the overall notes taken, check out /home/kdarling/kdarling/src/Class\ Notes/CProgramming/Notes_On_Project.txt for more information.

September 10, 2015

The following week we reviewed a lot about the GDB debugger for C.

< Some helpful text documents exist between September 8th –> September 10th > < Located: /home/kdarling/kdarling/src/Class\ Notes/CProgramming/ >

GDB.txt

Commands


1. help –> Displays some helpful commands. 2. help all –> Displays all commands. 3. list –> List 10 lines of your program. 4. list # –> Lists current line and content specified. 5. break __ –> Breaks program at given function, value, line, anything. 6. run –> Runs program. 7. where –> Where an error has occured. 8. print # –> Prints function value, regular value, anything. 9. step/next –> Executes the next line of code. 10. display –> Automatically display a group of variables. [ Very Useful! ] 11.

Notes


- Setting a break point, it will enable the user to manipulate and display variables that are listed in the program.

More GDB Coammands

bt –> Back trace from previous break point or list?

print variableName –> Prints out practically the value of anything in the program.

step – > proceed by each line ( Next Instruction: Even proceed into the function )

next –> Same as step ( Difference: Doesn't jump into a function )

continue –> Jumps to break point.

set var –> Set variable ( set var $i = 10 )

These are the notes taken for this week.

September 17th, 2015

This week will be kind of short regarding notes, basically the notes that were supposed to be stored have magically evaporated, probably by my doing for some reason.

We reviewed more on Nodes and started acting upon them featuring our latest project sln1

This project will be focused on the functions - mknode - cpnode - rmnode

Along with other applications we can use to play with these newly created functions and how they work.

Basically a Node contains information and is a one way street with addresses ( For Now )

Take Node *tmp = mknode(5);

This function just created a new node with the value inside it, 5.

If we were to say tmp → after = mknode(6);

The new order from start to finish of the Node tmp is 5 → 6 but hey what about

tmp = tmp → after; tmp = mknode(10);

That works right? No, matter of fact you just deleted 6 and replaced it with 10, you could've said tmp → after = mknode(10); This does what you were probably aiming for, awesome!

Remember, don't directly write over a node, you may make it lose it's address and all sorts of awesome stuff will happen, right????

September 24th, 2015

This week is like every other, more NODES!

We are moving now into project sll0 which we are faced with a new challenge, INSERT.

I know I'm writing this from the future, with that all misunderstanding with blog being the new Opus but it's all good. These new functions to be created are one of a kind, they deal heavily of what we used before and can cause major problems if they aren't properly built. THANK YOU UNIT CHECK!

The functions in question for sll0 are - Insert ( Big boy) - Mklist - Displayf - Pos

The biggest function is Insert, to start off, create mklist → displayf → pos → insert, insert thrives on position along with other functions created previously and currently.

As you might have noticed, lists?

A list to us now houses the first and last node of a series of well, Nodes.

These two variables help control and position the start or end of these nodes and help us guide through it.

Now let's talk functions folks.

Mklist's job is to merely create a new list and allocate a NULL node for the first and last Node's. Display is simple, display the list being passed and display there current position if asked. Position is a little bit more difficult but quite possible, simply the two functions are -getpos -setpos

getpos returns an integer that is passed through the parameter of where to go, a simple while loop will do.

setpos can get a little sticky but still, a while loop and return the current where abouts of the Node.

Insert is the big one, we will get to that next week (October 1st entry)

Basically these should do for now, sorry for being so short but traveling back in time sure does a number.

October 1st, 2015

This week we ventured into finishing up Insert which was probably my toughest assignment to date, mainly logical issues and forgetting simple things which tends to happen depending on the hours of sleep you had the night before.

Insert list was probably the edge of this iceberg but no tip compared to what's about to hit, a major glitch.

Basically what happened was after completing an assignment, you type make upgrade-whateverprojectisnow

This will upgrade you to the newest project that will transfer your old WORKING code to this newest project, well that didn't quite happen, matter of fact everything nearly broke.

What happened was myself and the other Kyle L. of the class upgraded our projects, his from that day and mine from the night before, both broke in a matter of seconds. I didn't realize it then but my Insert function broke completely and basically made it obsolete until a small overhaul was needed to fix it. The other Kyle's on the other hand broke significantly and the strangest part about the whole thing is that my function worked on my computer, mine on his did not.

The whole directory must've done something to cause such a fanatical error to occur inside a program built and not to ever experience an error such as this.

While working on my cplist function, that's when I noticed my Insert.c was glitched and had to be fixed, hopefully this error is resolved by everyone's help so it doesn't occur again.

October 6th, 2015

I'm not too sure if we are supposed to do these every class session or every week like in the old Opus but why not for today? It was chalk full of new things coming about and possible errors.

To start off about the discussion of our newest project, we will be covering several functions such as… - Swap ( Talk about this later - Clearlist ( Ez and again, talk about this later ) - Sort ( Best one yet )

These two functions were in my particular favor to look at.

To begin, swap will be dealing with more than likely swapping the node, not the info as that's WAY to easy.

The clearlist is actually probably the easiest of them all, depending on what's being asked. Before, I created this function that set every address and freed them up, then proceeded to make them NULL for new memory to access. When display was called, it simply didn't even come close to referencing odd addresses as the memory was freed up and vanished!

The Sort will be for sure the hardest but best yet, I have an incredible experience with sorting lists and it goes in my top 3 favorite things to do with numbers/calculations. 1. Statistics ( More on betting where I come out with a ton of money near the end ) 2. SORTING ( I've created a ton of programs where sorting is used so this is simply a no brainer ) 3. Data Analysis, you may say stats go under this but I'm saying for video games such as Super Smash Brothers: Melee where I study the pixel length and everything so I have the overall advantage over someone.

Anyways, back on topic. My sort function already, if this is in the realm of what we are supposed to use. I'll be using… cpnode() : This will be used for copying nodes to the list mklist() : This will be used for list creation of the new sorted list append() : This will be used to append within the list, not necessarily at the end insert() : This will insert before a node

Anyways, those functions will be used to sort. Basically what I do is go through the list and say, if current nodes info is greater than the node currently on (It goes through each node of the newly created list) append to that position.

I have the list Old List contains 10 - 2 - 9 - 5 - 6 - 6 New List will be like [ Sorting least to greatest ] Pass 1. Take 10, 10 is less than nothing

      New List contains 10

Pass 2. Take 2, 2 is less than 10, insert to start at current position

      New List contains 2 - 10
      

Pass 3. Take 9, 9 is greater than 2, move. 9 is less than 10, insert at current position

      New List contains 2 - 9 - 10
      

Pass 4. Take 5, 5 is greater than 2, move. 5 is less than 9, insert at current position

      New List contains 2 - 5 - 9 - 10
      

Pass 5. Take 6, 6 is greater than 2, move. 6 is greater than 5, move. 6 is less than 9, insert at current position

      New List contains 2 - 5 - 6 - 10
   

Pass 6. Take 6, 6 is greater than 2, move. 6 is greater than 5, move. 6 equals 6, insert at current position

      New List contains 2 - 5 - 6 - 6 - 10
      
      
      

That's it for the recently added project.

Now I've been “done” with sll1, well not really. The last one, position outputs 2 but should be 3 is completely wrong as of right now.

Through vast amounts of error checking, I still yet to ever have it come near 3.

October 22nd, 2015

This week was pretty laid back after the week long break, essentially it was all work.

Finishing up SLL2, my sort method didn't work to the fullest extent that it was capable of, mainly due to errors that would need to be ironed out.

Section A: SLL2 Project 1. We had to iron out the inner workings of append and other functions that the program rotated about, mainly append. After working that out, we found that sort had another issue which we ironed out some more. Eventually leading to palindrome working properly, as it should.

2. After that, sort was in order for being next, pretty easy actually. The code int sort = 0; while(sort < 100) {

   if(tmp -> info = sort) add to list;
   tmp = tmp -> after;
   sort++;

}

That was the code that had least to greatest sorting achieved, only problem was higher numbers. For whatever reason, if you were to exceed over 100, it would multiply what it got and add on ridiculous amounts of information.

3. For the greatest to least sort, take the code above and reverse it, that will give the greatest to least.

Section B: SLL3 Probably the easiest of all time, SLL3 literally was appending 2 lines to every file to accommodate the new qty = 0; variable and the new after pointer for lists.

That was it, nothing too special.

Section C: SLL4 This one is a little bit harder than the previous projects, mainly because everything truly feeds off of everything that it tests on. This in time makes it so you have to be as precise as possible in order to achieve the correct format of what the unit test is checking for, no errors.

Still currently working on it though and having to revisit ldisplay in order to check if lsetpos works and so on, pretty tough stuff.

October 29th, 2015

So for whatever reason, my post here did not save. Basically from about two weeks ago it was before Halloween so we were working on Grouped lists?

The idea behind this is that you have a hierarchy of

Groups

List

Nodes

Nodes being at the bottom and groups being at the top.

What the groups do exactly is that they are comprised of lists that those lists are comprised of individual nodes linked together in that list. The idea behind using Groups is that maybe you will have different groups of items for one part of a game then another group of items for another part of your game.

Example would be Group A List 1 - Advanced Armour Set –> Helmet (Node), Body (Node), and Legs (Node) List 2 - Starter Armour Set –> Helmet (Node), Body (Node), and Legs (Node)

Group B List 1 - Potion Set –> Health (Node), Strength (Node), and Agility (Node) List 2 - Food Set –> Chicken (Node), Bacon (Node), and Beef (Node)

These groups are comprised of there own individual categories.

November 12th, 2015

These past two weeks have been quite hectic and I'll be explaining why, each week at a time.

Week 1 (Last Week), we introduced a new project that uses lists more but in a doubly linked list fashion. Think of a doubly linked list such as a backwards compatible program that works in Windows 7 and Windows XP, though this is merely far stretched. The true meaning of a doubly linked list is the ability to go forwards and backwards freely without any interruption. Basically, instead of starting everytime from the front with Singly linked lists, the Doubly linked list may start anywhere it pleases and move freely without any restarts. The bad side of this, more work has to be done in order to correctly organize the list without destroying it.

These functions that need updating are Append, Insert, Obtain, Swap, Compare, and Sort. Along with our basic Node functions such as mknode, cpnode, rmnode, mklist, cplist, and rmlist but I won't get into these.

Append


Append now requires the user/developer to link the previous and after together properly in an organized fashion that won't completely destroy the list, only temporarily disconnect it to be reconnected again in the next step. The main focus of the list is to make sure it appends onto last correctly and to update last, so a check for it will need to be done.

Insert


Insert focuses on inserting at the start or anywhere in the list, with this said, the main focus will be myList → first to be updated properly once inserted there. Other than that, insert may insert anywhere freely but with the same precaution as Append.

Obtain


Obtain will be focusing on grabbing a part of the list and removing it safely, when doing so though, you will have to check for first and last. If first is grabbed, the after pointer of the node will now be first. Vice versa with last, the prior pointer of the node of that list will now be the myList → last. Any other part of the node list may be taken out but you must disconnect tmp → prior = NULL and tmp → after = NULL.

Compare


Not going through this entirely but Compare will be taking our old compare and using it, same with swap and sort so no other explaining is needed.

Overall though, double pointers are being introduced. No more using single pointers in the list, you will have to dereference the node/list to a single one in order to manipulate it.

Think of double pointers as

Function that calls Bobs Function —> Bobs Function Function that calls Bobs Function passes an integer with the value 0. This requires an '&' in order to do so. Bobs function now takes that integer and sets it equal to 5. When the function completes, the function that called bobs function, there integer is now 5. You can also think of it as recycling, one side inputs then the inside translates then outputs.

Overall thats the week 1, week 2 is the same exact thing but for updating.

November 19th, 2015

This week was kind of slow, the only thing really new from the whole experience is the introduction of stacks and queues. Stacks only contain a list who has a separate node attached to the struct that points to the end of that list, thus the stack.

The queue on the other hand has a struct exactly the same as stack but it also includes a first and replacing stacks top with bottom.

These two applications may be used in many real world scenarios, stacks are less prominent where processes are forced on top of each other and are “stacked” to be executed, though I'm not a fan of that approach. Queues on the other hand I enjoy actually quite a bit with the idea of having a line of data

1 - 2 - 3 - 4 - 5 - 6. 7 comes in and the list now looks like 1 - 2 - 3 - 4 - 5 - 6 - 7, now a process is free to take 2 processes to be well, processed so 1 and 2 are now out

3 - 4 - 5 - 6 - 7, then 3 more processes are added to the pool so now it's

3 - 4 - 5 - 6 - 7 - 1 - 2 - 8, if we are conserving numbers here?

That's the idea of a Queue, I'll be implementing it into my game that I am currently working on where it will be handy for a boot loader into the game, not loading every level at once and slowly doing so as the game progresses.

The idea

Game Pool of Levels Queue: Menu - World Level 1 (Main) - World Level 2 (Sky) - World Level 3 (Underworld)

These four classes will be added to the queue and a separate thread will be loading the contents of them as you play the game.

There will be two functions Force Load and Resume Load

Force Load will Force a level/menu to be loaded (Basically when the game starts Force Load will enact Menu)

blog/fall2015/kdarling/start.txt · Last modified: 2015/08/27 09:44 by 127.0.0.1