Sidebar Menu

Projects

  • Dashboard
  • Research Project
  • Milestones
  • Repository
  • Tasks
  • Time Tracking
  • Designs
  • Forum
  • Users
  • Activities

Login

  • Login
  • Webmail
  • Admin
  • Downloads
  • Research

Twitter

Tweets by stumathews
Stuart Mathews
  • Home
  • Blog
  • Code
  • Running
  • Gaming
  • Research
  • About
    • Portfolio
    • Info

C, 64, Triple Black, Resource Management and a Game Prototype

Details
Category: Blog
By Stuart Mathews
Stuart Mathews
11.May
11 May 2019
Last Updated: 11 May 2019
Hits: 3281
  • Programming
  • Running
  • Game development
  • C++
  • Cloud

Since Retro sounds, Event Manager and some running I've been focusing on a few things lately:

  • Game programming - implemented a Resource Manager using C++/TinyXml2
  • My Tuesday programming course on C in the City
  • Formulation of my frameworks on "Now" and "Zen"
  • Meeting protocol
  • DK Money book
  • University study (Continuing professional development)
  • Avengers: End Game

Let's start off from the top.

I implemented a resource manager for my prototype game which is responsible for cataloguing all the images and music files that my game uses.

Basically, to strategically load and unload game assets during the game, you need to know where they are, what they are and which level they belong to.

All this information is centralised into an XML file that holds this information:

<?xml version="1.0" encoding="utf-8"?>
<Assets>
  <Asset uid="1" level="1" name="MainTheme.wav" type="fx" filename="Assets/Music/MainTheme.wav"></Asset>
  <Asset uid="2" level="2" name="scratch.wav" type="fx" filename="Assets/scratch.wav"></Asset>
  <Asset uid="3" level="3" name="high.wav" type="fx" filename="Assets/high.wav"></Asset>
  <Asset uid="4" level="4" name="medium.wav" type="fx" filename="Assets/medium.wav"></Asset>
  <Asset uid="5" level="5" name="low.wav" type="fx" filename="Assets/low.wav"></Asset>
  <Asset uid="6" level="6" name="maze1r.png" type="graphic" filename="Assets/maze1r.png"></Asset>
</Assets>

And the manager basically loads it up and stores this metadata in memory in the form of a list of "Resources" which is what the resource manager does - it deserialises the XML into Resource objects and caches them:

#pragma once
#include <string>
#include <map>
#include "Resource.h"
#include "tinyxml2.h"
#include <memory>
#include "tinyxml2.h"
using namespace std;
using namespace tinyxml2;


class ResourceManager
{
    public:
        static ResourceManager& getInstance()
        {
            static ResourceManager instance;			
            return instance;
        }
		ResourceManager(ResourceManager const&)  = delete;
        void operator=(ResourceManager const&)  = delete;
		std::shared_ptr<Resource> GetResource(string name);
    private:
        ResourceManager() 
		{
			// Load the resources on creation of the Resource Manager
			LoadResources();
		}
		void LoadResources();
		
		// Record the asset in the catalog of assets
		void RecordAsset(tinyxml2::XMLElement * assetElement);
		
		// Make Asset from Asset XMLElement
		std::shared_ptr<Resource> GetAsset(XMLElement* element);

		// catalog of assets managed by this manager
		std::map<std::string, std::shared_ptr<Resource>> m_resources;        
};

So now, I can strategically remove things that are in memory that don't need to be - I'll know exactly what the resources are and thus I'll be able to unload them appropriately and load new resources using the path meta-data in the resource objects. 

I had to learn how to use TinyXML2 which is supposed to be super fast. it probably is but its a bit weird to use.

For example, you can't just iterate through all the "asset" elements, you need to find the first asset element, then iterate through the remaining 'siblings'. This is probably because the XML file's DOM is stored as a linked-list in memory I think. See TinyXML2

This is how I turn the XML previously shown into the list of Resource objects previously mentioned:

#include "ResourceManager.h"
#include "tinyxml2.h"
#include <iostream>
#include <map>
#include "Resource.h"
using namespace tinyxml2;
using namespace std;

std::shared_ptr<Resource> ResourceManager::GetResource(string name)
{
	auto resource = m_resources[name];
	return resource;
}

void ResourceManager::LoadResources()
{	
	std::cout << "Loading all the resources from the Resources.xml ..." << std::endl;;
	
	XMLDocument resourceFile;

	// Load the resource file into memory
	resourceFile.LoadFile( "resources.xml" );		
	
	// Get first Asset
	auto pRoot = resourceFile.FirstChildElement();
	auto pFirstAssetElement = pRoot->FirstChildElement("Asset");
			
	RecordAsset(pFirstAssetElement);

	// Get remaining assets elements
	auto pNextAsset = pFirstAssetElement->NextSiblingElement();
	do
	{		
		RecordAsset(pNextAsset);
	}
	while ((pNextAsset = pNextAsset->NextSiblingElement()) != nullptr);
}

void ResourceManager::RecordAsset(tinyxml2::XMLElement * pNextAsset)
{
	auto nextAsset = GetAsset(pNextAsset);
	m_resources.insert(std::pair<string, std::shared_ptr<Resource>>(nextAsset->m_name, nextAsset));
}

std::shared_ptr<Resource> ResourceManager::GetAsset(XMLElement* element)
{
	int uuid;
	const char* type;
	const char* path;
	const char* name;
	int level;

	element->QueryIntAttribute("uid", &uuid);
	element->QueryStringAttribute("type", &type);
	element->QueryStringAttribute("filename", &path);
	element->QueryStringAttribute("name", &name);
	element->QueryIntAttribute("level", &level);
	auto asset = std::shared_ptr<Resource>(new Resource(uuid, name, path, type, level));

	std::cout << "Fetched Asset " << asset->m_name << "of type " << asset->m_type << std::endl;
	return asset;
}

I also turned this into a Singleton and used the same pattern in my event manager that I created previously in Retro sounds, Event Manager and some running. I then substituted the global reference that I previously used for a single EventManager::getInstance() throughout the code. It's all quite elementary but fun.

Apart from that, I've not made other major inroads were made however I'm still scheming...

I'm reading "Game Engine design and Implementation" by Alan Thorn which inspired me to turn my event manager into a singleton and implement the resource manager. It's quite an old book but the main gaming concepts remain the same throughout the years it appears.

 I attended the 2nd lecture on C programming on Tuesday and learnt some interesting perspectives about binary and one very quick and easy way of converting to/from binary or Hex.

The other interesting thing that I learnt was about 24bit pictures in relation to how many bits are used to store a single colour in an image. I always find these lateral concepts surprise me from time to time. This is all very serendipitous as I'm loading bitmaps into my game prototype. The other interesting thing I learnt was that another student works for the same company as I do, which is remarkably coincidental.

While studying my course work for "Continuing Professional Development", I've found it quite interesting to learn about some of the emerging and current theories out there around the processes involved in learning. I've become fairly interested in some of the material.

Currently, I'm developing a framework, based on all the study material, that I might use to better reflect on past learning encounters/experiences. I've drawn it up and its currently in the draft stages. I'm calling it my "then framework" as it draws on strategies to reflect on the past.

In parallel, I'm developing a framework to assess situations, which is a precursor to the "then" framework which I'm calling my "now" framework. I know, I'm quite original.

This framework is about understanding or being aware of the current situation, the nature of your strategies and behaviours in these situations and basically defining them so you can better know yourself fundamentally and how you can potentially learn to change these tendencies/strategies etc. moving forward.

Quite interesting really.

On the running front, I'm still loving it. posted a 64 VO2max record last week so things are looking good:

VO2Max record 3.0 hoo-rey! pic.twitter.com/9pmGhvhvCj

— Stuart Mathews (@stumathews) May 9, 2019

As I've mentioned in one of my tweets, I've got another case of Lateral Shoe Disease, which I've now determined is probably because of a few things.

  1. I under-pronate quite a bit causing excess strain on the sides
  2. I don't look after my shoes enough after running.

Yeah, regarding point 2, I think what is happening is that the material on the outside as shown below is becoming brittle and weaker because of the dust that I pick up while running. My theory is that this settles within the fabric and then forms clumps that fill in the mesh-like fabric making it harder and more easily prone to tearing. In short, I need to clean my shoes.

Another victim of LSD ie.lateral shoe disease. Subject C : pic.twitter.com/GcwwWDLVTR

— Stuart Mathews (@stumathews) May 4, 2019

And as such, I bought a new pair of trainers. These are not replacements but until the LSD is fully set in, I can delay the onset of eventual demise by using other shoes to run in and hence decrease the frequency of strain those poor old shoes have to endure.

So its a matter of setting up running shoe round robin really.

I did a lot of research on these new running shoes (As I do) and I decided on the Adidas Ultra Boost 4.0 Triple Black. Now, as my Pegasus 33, as shown above, are pretty much the flagship Nike running shoe and I've gone through 2 (almost 3) due to excessive wear and tear, I figured I'd switch brands. So I opted for Adidas' running equivalent.

These are they:

Coming soon on #adidas US.
adidas Ultra Boost 4.0 Triple Black.
Releasing Monday, December 3.
—> https://t.co/9hgziDNgfU pic.twitter.com/feiFpv7zWR

— adidas alerts (@adidasalerts) November 15, 2018

So, In other news, I've also been thinking about developing a new project that effectively defines and constrains meetings.

I often find meetings to be painful and ultimately just talky-talky and usually only benefiting some - or maybe everyone else! So I've been thinking of a meeting protocol such that it defines how one should run a meeting. Specifically, what process to follow and prevent skipping steps. Almost like a workflow, I guess. 

It's more of an application that shows meeting attendees where they are in the meeting process and looks to include all participants equally instead of just the ones you shouts the loudest. Quite interesting idea. So that's something I'm keen to do and I'll probably use Angular 6 and deploy it to the cloud. I'm really enjoying this technology at the moment. 

I also watched Avengers: End Game and I enjoyed it. I wouldn't say I was excited or absolutely spell-bound by it but that is to be expected - it's not a new movie so I didn't get new-movie-vibe type excitement. I got an appropriate level of awesomeness and for over $1 Billion spent on the film. I'd hope it was appropriate!

I'm not really a serious movie critic however but I like what I like.

 

Easter, Heroku, Postmodernism, DataFlow, Math and Software Engineering

Details
Category: Blog
By Stuart Mathews
Stuart Mathews
21.Apr
21 April 2019
Last Updated: 22 April 2019
Hits: 3193
  • Programming
  • Running
  • Gym
  • Angular.JS
  • Asp.Net Core
  • .Net Standard
  • Design patterns
  • Software Engineering
  • Docker
  • Cloud
  • Software Architecture
  • Data flow architectural pattern
  • Heroku

I've had quite a productive easter this weekend:

  • Went to the gym and went for a run
  • Read up about modernism and postmodernism and blogged about how it relates I think to software in Postmodern Software: Embracing complexity
  • Worked on my new data flow pipeline project, wrote some tests and published it to nuget and interestingly I already got 12 downloads in one day.
  • Swotted up on my Software Engineering course in preparation for my exam on Thursday 25th 
  • Learned about linear equations/formulas and functions.
  • Learned about 3D theory around view transformations and linear geometry
  • Read how experts conduct themselves and what traits they often present
  • Read up on Hofstede and Tropenaars dimensions of culture
  • Successfully deployed by Investment Manager frontend onto Heroku and unsuccessfully tried to deploy a backend docker container :-( Er no, never mind that - I actually got that working!
  • Setup my Angular frontend to use the express framework as the web server.

That I think is not a bad weekend. I've still got more studying to do however having only finished a part of my study plan.

In between my study of software I've also learnt a lot about the economy with respects to the free market and how generally markets work. This has been interesting.

Its also allowed me to think about my investments and how to try and better manage the investments that I hold and will hold in the future. For example, I came across a Harvard Business Review article about weighted and balanced scorecards as a way to set up criteria to rationally reason about your investments so as to divest any emotional attachment to them.

The reason why this is good is that I know that I'm emotionally attached to some of the decisions I've made and need to be able to objectively distance myself from that sort of sentimentality as investing is not about liking(I like my investments) but more about growth and value.

I think I'm going to set one of these up soon.

 

 

Postmodern Software: Embracing complexity

Details
Category: Blog
By Stuart Mathews
Stuart Mathews
20.Apr
20 April 2019
Last Updated: 20 April 2019
Hits: 3185
  • Software Engineering

I and been pondering about my software projects at work recently and while doing some reading today, I made an interesting observation: Software is getting more complex and it requires more thinking, involves more moving parts and its in some ways is reminiscent to current postmodern thinking. Now, there could be countless reasons why it appears more complex though I'm not going to pursue this, only discuss my observations.

I’m also studying maths at the moment, in particular, linear geometry and algebra which, in contrast to postmodernism, is usually associated with modern, scientific thinking. 

So with this juxtaposition of thinking in mind, a bit of an introduction to modernism is in order, and then how software is becoming more complex in a postmodern society. I should also just say at this point, that this, like all my blogs, is just my view based on my recent experiences which could be biased or skewed by the industry, software technology and people I work with.

 

For a long portion of time, I’ve always viewed maths’ universality both pleasing and at the same time viewed it sceptically in its seeming application to everything.

Don’t get me wrong, I like maths for its accuracy and objectivity but I’ve always found it lacking in its unity with more human-like pragmatism, such as the inevitability of complexity that is outside of our understanding, subjectivity and the emergence of ideas that cannot be measured easily or accurately such as human behaviour, chaos and individuality and personal thinking.

For example, why do some people do things others don't - putting that in an objective law would be difficult because it's composition is difficult or too complex to reduce. Such ideas can be varying, wrong or indeed right given the circumstances. Math traditionally doesn't handle 'maybe' very well(though there are signs of that changing - probability, approximation etc.).  These types of subjective correctness’s are difficult to quantify with mathematical correctness and while one might feel that these types of problems are not math problems,  I do feel that maths is evolving and is and will be capable of trying to define measurements and subjective laws or tendencies like these.

For the most part, maths has a finite universe and everything within that universe is accounted for and understood and thus anything within that universe can be related within the confines of understanding within that field or universe.

This is what is at the heart of modernism – the mathematical view, that everything that it has power over, is definable and measurable.

Basically, the rules are set and they don’t deviate much.

Mathematics and indeed scientific thinking is what underlies Modernism. Its a view of the pursuit of an absolute definition, breaking down ideas and reasoning into their constituent parts and studying and reasoning about them (reductionism).

Software can be reduced, its parts studied, techniques applied, code practises enforced and measured too and this is why I feel mathematics and computing often seem to fit well (more on this later).

 In a way, modernism is a way to reduce complexities in order to understand the make-up or constituent parts of it. And this all makes sense when you think of maths’ pursuit - definition and relation to other already defined concepts.

Now as eluded to previously, I’ve found this to be useful in understanding geometry for example - a fairly one-dimensional view of a universe of concepts. Other things can be and are sometimes chaotic, possibly being impossible to pragmatically reduce them, being perhaps only understandable if you don’t break them down into smaller chunks. Because studying constituents at the micro-level in the pursuit of universal understanding - you don’t see the bigger picture.

This is where postmodernism is seen as an antidote, where the wider composition of something is considered. And if we are to believe that we are moving from a modern to postmodern society then we might need to realise that complexity, in general, is increasing and moreover that we are accepting it.

For example, certain ideas cannot be understood by looking only at their constituent parts such as the light which acts like particles and like waves – you need to stand back and embrace all the constituents of light to fully try to understand it. Concentrating on the particle-like properties cannot explain the wave-like properties. 

In the same way that emergent properties of things ‘emerge’ by being a factor of many facets of something  - not just one and being fixed on one will preclude you to seeing and understanding the holistic idea. This naturally means that postmodernism almost embraces complexity by definition and its not trying to reduce it into similar parts but coming up with ways to deal with its complexity instead.

So when thinking about software, and the move that the world is undergoing which, is a gradual move from modernism that looks to reduce complexity and apply scientific thinking to postmodernism, which acknowledging complexity, its easy to see why software is becoming more complex(Russo et al, 2017).

If we are to believe that this is being embraced by postmodernism society, then perhaps previous outdated modernism thinking in dealing with complexity in software is on its way out too.

Perhaps sequential, waterfall methods are outdated because of favour postmodern methods that deal with increasing complexity such as Agile.

Indeed Agile, like postmodernism, is not about the micro-level - its about the holistic view, a understanding that more is at play than say the code or the documentation or people or communication but rather the interplay between all of these parts– a whole system of complexity, something that modernism would seek to inhibit but is a reality these days.

 So the paradox: we're embracing or acknowledging complexity (because we have to) and its making our software more difficult to manage and maintain.

More Articles …

  1. Mountain running and Zebras
  2. Another day in paradise
  3. Wet rain
  4. A rainy day
  5. Drakensberg boys’ choir
  6. A Scenic African run with sensible shoes
  7. African party birds
  8. Cricket, Quiche and luggage
  9. Flu, fishes and flip-fops
  10. A Finchley change
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

Page 26 of 182