Since Convolution, Running and Finite State Machines, I've spent the last couple of days focused on reading lotsa different stuff.

I'm currently alternating between a few books: *"Introduction to 3D Game Programming with DirectX10"*, which is by Frank D Luna. It's quite technical however, it's accurate and provides good perspective, particularly around the basic math such as vectors and Matrices.

I'm also reading Rautenbach's *"3D Game programming Using DirectX10 and OpenGL",* which is one of my favourites reads on the subject. I think it is primarily because it does the best coverage of 3D transformation I've ever read and its got great illustrations too.

With* "Foundations and fundamentals concepts of mathematics", * I'm taking a history lesson at the moment into the axiomatic, deductive method used throughout history in describing math. I've been reading about the development of the deductive method used by Euclid and Archimedes and some of the histories behind how varying degrees of assumptions including Axioms and Postulates and how they are used, how they were formed and it is pretty insightful. It's theoretical but/and pleasingly so.

On a more practical note, I'm now also reading "A* programmers introduction to mathematics" * where we're trying to implement a secret code sharing mechanism using polynomial theory, which is a little more practical. This book takes a little longer to read than the others but I'm quite interested in it.

Last in my round-robin of reads is *"A mind for numbers"*, which is more inspirational than technical and sits squarely within the genre of some my previous 'popular research' reads such as "Mindset" and "Bounce" as well as "The Checklist". It reads more like a novel/story than a technical book.

Apart from physical the books, which are stacked up next to me on my coffee table, I've been wondering the passages of the internet too. I recently came across a BBC learning page about computer science fundamentals.

It introduces algorithms such as those used for searching including linear and binary search methods and sorting too using methods such as bubble sort, selection sort, merge sort etc.

Its a series largely aimed at children but it has real application (just like any math would) and I found it particularly interesting and fun, which perhaps further suggests that perhaps I've not yet grown up.

It also maybe suggests that some computer science fundamentals are a little more known to children that they have ever been before as it was surprisingly well documented and entertaining as it included videos, examples and was suitable 'gamified'. The only thing missing I found was actual code implementations...

I spent some time implementing some of them for fun as I wanted to test myself.

My first test was implementing Bubble Sort - a linear time, O(n) sorting algorithm, pretty inefficient and slow but it's got a very defined and coordinated setup which makes it easily modelled.

I used a do() iteration construct, as you'll be swapping at least once and I count the number of swaps done through each iteration or 'pass' running through the list of numbers. The process ends when there are no more swapping to be done, which forms part of my exit condition in my loop and then the list is sorted:

```
public static void BubbleSort(ref int[] input)
{
int swapped;
do
{
swapped = 0;
for (int i = 0; i < input.Length-1; i++)
{
if (input[i] > input[i + 1])
{
var temp = input[i];
input[i] = input[i + 1];
input[i + 1] = temp;
swapped++;
}
}
} while(swapped > 0);
}
```

It was actually pretty fun doing this, and can surely be improved upon - Next, I tried the insertion sort:

## Insertion sort

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

This is a little more difficult because you need to 'look' back to see if any prior elements, so it needs a nested loop. One loop for the initial pass-through of each of the elements and then for each element, scan the previous elements leading up to the element. Pretty inefficient, somthing in the region of say O(n^2) I'd imagine, but totally something that can be modelled in code:

```
public static void InsertionSort(ref int[] input)
{
for (int i = 0; i < input.Length; i++)
{
for (int j = 0; j < i; j++)
{
if (input[i] < input[j])
{
var save = input[j];
input[j] = input[i];
input[i] = save;
}
}
}
}
```

These all sorted the list in-place. I stopped there but I'm going to add a few in the future, probably the more complicated and more efficient ones as it's a pretty interesting and enlightening process, and helps me practise.

So in other news, I've finally completed my Network Security course, and I'm pretty much done with the Digital Signal Processing. Actually, the last piece of work I did on it was the course work(which ultimately replaced the exam) was where I needed to implement a Circular Buffer and then use it in creating audio effects in C++ using fmod, among other things.

One example of this was creating a delayed(or time-shifted) signal effect like a flanger...

This is what I ended up doing in C++:

One of the other things I had to do, was set up an occlusion effect whereby walking in front of an object would effectively cut off sound originating from the object.

I used FMods geometry system to construct a polygon that represented a wall and positioned that in front of my object. I then registered it with the fmod system. Pretty fun as we had to import a new mesh and render it in the OpenGL - which was the first time I'd used OpenGL.

Looking back at my DSP course, I actually enjoyed it, particularly the theory but also too the C++ and the work I did on the ringbuffer. We covered aspects including:

- Logarithms, Real and complex numbers
- Sampling and Quantization analogue continuous signals into digital
- Wave theory and properties of waves
- Signal correlation and the Fourier transform: Dot product, Autocorrelation, Cross-correlation, Cross-co-variance, the Correlation coefficient
- Frequency Analysis
- Filtering and convolution

I enjoyed learning about the Fourier transform the most, and I suspect in the future I'll be using it again...

Apart from my Network Security and DSP course, which has taken a lot of my spare time, I also managed to also complete the Game Architecture course.

As a result, I've written a game engine in C# and MonoGame and produced a representable prototype to represent it. The main concepts covered include:

- Resource Management Strategy
- Character Control and Decoupled Input
- Collision Detection
- Moving and animated game elements and frame-rate independence
- The configurable game world and data-driven approach
- Decoupled removal of game objects from collision detection
- Scoring System use of event listeners
- High score or alternative state load/save mechanism
- Start-screen with FSM
- Power-ups using event listeners and re-use of base classes for game objects
- NPC opponents demonstrating FSM
- Overall game-play and presentation

I have a bit of a demonstration of a PAC-man like game which features collision detection, primitive AI and animation. It's very basic and is really just a prototype (not a whole game) to demonstrate the underlying architectural designs and concepts in the game code:

I started with a simple concept of a GameObject which takes on a lot of the functionality and responsibility of typical game situations such as calculating bounding boxes, doing collision detection and common updating routines, drawing and initializing of components etc.

Apart from the actual coding which has taken a lot of my time, I've also spent a considerable amount of time distilling the design decisions of my game engine into a report, which really helped me take stock of all the code I'd been writing, specifically the architectural aspects.

There have been a A few runs during the stay-in phase which are notable.

Yesterday, I put in Mass Effect 3 into the XBox and played a little bit, enough to cure the Krogen of the Genofage but I died like 20 times before I was able to finish the mission. But the persistence paid off!

I also upgraded my Investment Tracker application to Angular 6 from 5.2 which wasn't that bad however I'm a bit stuck now as I can't upgrade beyond that as I've got a strong dependency on a component that won't upgrade further - which I'll need to look to remove in the future but not a big issue right now.

I'm thinking of doing another project that uses my new knowledge around signal processing to implement a sort of Strava-like application in Angular 8/9 but the jury is out on the schedule of that. I've got a few weeks break before things start going again!

Comments powered by CComment