Portfolio Update – Game Behaviour

Hello!

I recently put up pages for two projects from the Game Behaviour module undertaken in the final year of my BScH in Computer Games Programming at the University of Derby, which I have now fully completed and received a very pleasant classification for.

You can now head over to the pages for Crispis and DropCakes, and The Frozen Firepits of Generic Dungeon Name for information on these projects, or to download the source code and executables. The former is simply a 2D physics sandbox built upon Box2D and a custom Entity/Component engine, and probably isn’t or much interest to many. The latter, however, you may find interesting if you’re into game design, classic roguelikes, fantasy games, and such.

The Frozen Firepits of Generic Dungeon Name (TFFGDN) was an experimental game design implemented for an artificial intelligence (AI) assignment; it did well, though the AI isn’t too interesting in my opinion. It’s a fusion of turn-based, physics-based mechanics similar to Snooker or Pool, and classic fantasy dungeon-crawler games where a party of adventurers of traditional achetypes such as Warrior, Wizard, Rogue, etc. enter into a monster-infest labyrinth seeking treasure. In its current state it’s not too thrilling; I had intended to implement magic and special abilities for player characters and enemies, which I think would make things a lot more exciting, but I just didn’t have time. I also feel like the physics could be tightened up a lot to increase the pace of gameplay, but I had to do a lot of fiddling with Unity just to get it working in the first place.

Come next week or so I’ll try to have some more information up regarding my dissertation project which was an investigation into AI for Don Eskridge’s The Resistance. Then I can get onto undertaking some small personal projects while I look for work.

A Note of Intent

Aaargh.

I decided I wasn’t going to bother posting another update here until I’d settled back into uni and sunken my teeth into some fresh projects I could write about. I suddenly find myself almost two-months into the final year of my degree and I’ve been rather too busy to give it a second thought.

So here’s a note of intent: I will, sooner or later, make a proper post about this semester’s projects, before the semester is concluded, including my dissertation project, which was signed off by my supervisor last week and is now awaiting my full attention…after two more urgent deadlines. For now, I’ll just leave a brief list of what I’m currently working on:

1. An essay on the sufficiency of services provided by modern operating systems for accessing detailed information about gaming peripherals [due two weeks from now – yikes!].

2. A Unity game about parkour and painting. Think Jet Set Radio meets Mirror’s Edge meets Tony Hawks Underground. This is a team project with three other programmers from my course, and seven artists from the University of Derby’s Computer Games Modelling and Animation course [due sometime around the end of the semester].

3. For my dissertation project I am to be investigating the posibility of applying various AI techniques to the board/card game The Resistance. This may include search trees and evolutionary techniques, and I will be using the competition framework and bots provided by AiGameDev.com last year.

These are the things I’ll be posting about and/or creating new pages for here when I get chance. All the other stuff I do I’ll likely post about elsewhere if I even have the time to continue doing things other than eat, sleep, and code.

I cook some nowadays, and bake a little; I still study Korean, and I’m trying to snatch back the graphic design and art skills I used to have. But I’d like to keep this blog focussed more on programming, and the larger projects I undertake.

MARS MIPS Simulator Lockup Hackfix

If you are attempting to use Missouri State University’s rather excellent MIPS Simulator and IDE, MARS, to develop an application which uses the bundled Keyboard and Display Simulator (though it seems  unlikely that you would be doing so seriously today), you may encounter a sporadic bug where the entire MARS application will lock-up, and you have to end-task it.

I personally encountered this while attempting to make a simple Snake clone just over a year ago, during the Console Development 1 module of my (WIP) BScH Computer Games Programming degree and the University of Derby. At that time me and a friend tore open the MARS .jar in order to probe for the cause of this, and were actually able to implement a little work around. Since posting about this project here and putting a video demonstration up on YouTube, I have been asked several times about how we were able to do this, and rather than repeatedly send out links to the email I originally sent to Ken Vollmar, I thought it might be nice to have a decent guide I can direct people to.

Note that the below instructions cover a quick ‘n’ dirty fix, which may introduce other errors (though I haven’t noticed any). This is why I have elected not to just hand out a new .jar, though I could happily do so under the MIT License. I didn’t then have the know-how to properly dig into the problem, and since lengthly debugging of broken applications is my full-time job right now, I’d rather not do so in my free time.

What You Will Need
Java Tools – Likely an IDE like Eclipse
Archiving Tools – 7Zip or a similar application for looking into the .jars
A copy of MARS.jar

Instructions
I’m going to assume you’re using Eclipse, because that’s all I know, so you may have to dig for some of the options if you’re using something else. I will assume you may never have encountered Eclipse or Java before though. Java is a lot like C#, but Eclipse is a bit different from Visual Studio. If you’re better at Java than me, do please let me know where I’ve done things the hard way round, and feel free skip the easy sections.

As another heads-up, I’m also using Windows, so this experience may be rather different for anyone hailing from the OSX or Linux world (I’m told that the creation of an executable .jar on Linux is free from some of the woes I encountered).

Project Setup
Firstly, create a new folder, open up Eclipse and select this folder as your workspace. I called mine ‘Mars_4_1_Mod’. You then need to create a new project in this workspace (File->New->Java Project). Name your project, and hit ‘Finish’. Note that my JRE is set to JavaSE1-1.7. This setting may be important – I’m not overly familiar with it myself.

Now right-click on the project in the Package Explorer, and select ‘Import’. You want to import the contents of MARS.jar to the project, so select General->Archive File from the dialog, browse to your copy of MARS, and hit ‘Finish. Your Package Explorer should now look something like this.

MARS_01

Finally, you need to make sure that Eclipse can find the source code in the project. To do this, right-click on your project and select ‘Properties’. Go to Java Build Path->Source, click ‘Add Folder’ and select your project root. You can fiddle with exclusions and stuff if you want, but I preferred the shotgun approach for what it’s worth.

The Fix
You should now be able to build and run the project (Run->Run As…->Java Application, select ‘Mars’ and hit ‘OK’). Mars should run normally and freeze as expected. Alternatively, if you run it via Run->Debug As…->Java Application then you will be able to suspend the application from Eclipse when it locks up, and then investigate the lock-up state for yourself from the Debug perspective.

Great, now go to ‘Navigate->Open Type…’ and use it to find your way to KeyboardAndDisplaySimulator.java. Navigate to line 210. It should look like this:

updateMMIOControl(RECEIVER_CONTROL, readyBitCleared(RECEIVER_CONTROL));

This is our culprit – a threading issue, a deadlock caused by this function call and another from AbstractMarsToolAndApplication.java. To implement the workaround as I have, you simply need to replace this line with the following:

//-------------------------------------------------------------------------------------
//This call caused a deadlock sometimes when using the keyboard and display simulator.
//The syncronized block below simply plucks out the necessary call from
//updateMMIOControlAndData, which is where this call would take us in the end.
//-------------------------------------------------------------------------------------
//updateMMIOControl(RECEIVER_CONTROL, readyBitCleared(RECEIVER_CONTROL));
//-------------------------------------------------------------------------------------
synchronized (Globals.memoryAndRegistersLock) {
   try {
      Globals.memory.setRawWord(RECEIVER_CONTROL, 0);
   } catch (AddressErrorException e) {
      e.printStackTrace();
   }
}
//-------------------------------------------------------------------------------------

Now if you run Mars through either Run or Debug you should find that the freeze-up never happens. Feel free to poke around if you want to know more about the original issue – but if you’re just trying to work with Mars for a personal project, this should be good enough.

Bonus
If you’re a student working on a project for your studies you may wish to provide your marking tutor with a copy of your modified MARS application alongside your assembly program. Now, after much pain I DO have a working .jar of this, and I will detail it’s creation beneath in case you run into difficulties as well, though it’s probably stupid because I’m not experienced enough with Java to know what exactly prevented me from doing it the normal way.

In the beginning it seems there are two options – you can export a Runnable .jar from Eclipse (File->Export->Java->Runnable JAR File – make sure to select ‘Package required libraries into generated JAR, ignore the warnings), or you can try running the script, ‘CreateMarsJar.bat’ which should be in the root of your project.

For me at least, the script somehow creates a .jar with the same bug as the original, and the exported ‘Runnable’ .jar…won’t run. The way around this is to make a copy of the original Mars.jar, open both it and your Eclipse-exported jar using 7Zip or a similar application, and copy the ‘mars’ folder (contains the compiled .class files) from your version into the copy of the original, replacing it’s own.Delete your exported jar and run the copy of the original – it should now perform as well as the version you launch from Eclipse.

Thanks and Stuff
Thanks go to my friend Bombpersons, without whom I might not originally have bothered to look into this issue. If you have any further information on this issue, any corrections to the information provided here, or struggles in doing this yourself, please do get in touch.

Three Weeks Freedom

Lectures an tutorials are of course important, but it has to be said that the journey to and from the university, and their inflexible schedules are rarely convenient things. More and more of late I’m finding I’d rather be off investigating things for myself than being forced down particular avenues. I’d love, for instance, to be looking into WebGL and x86 assembly right now, having greatly enjoyed the time I spent with MIPS last semester. Meanwhile, I feel that modules like Team Software Development have long since served their purpose in teaching me in the value of effective teamwork strategies, and now now do nothing but eat into my time. It was with great relief last weekend that I entered the start of a three-week break from such activities.

Three weeks to get well ahead with my assignments, three weeks to get some more job applications off, three weeks to resume my studies of the Korean language, three weeks to look into WebGL or x86 assembly, three weeks to properly maintain my online presence or pursue my artistic interests. So many choices.

One week of that time has already elapsed, and I elected to spend it in the labs, where the PSP dev kits are, working on an optimized, billboarded, particle system for our Console Development 2 assignment. This is the module I’ve enjoyed the most this semester, and the module within which I feel that I have learned the most. Which of these is resultant of the other? Well, personally I think that it’s reciprocal. I’ve not only learned about PSP specific programming and optimization, but also finally found the opportunity to gain an understanding of threading – it’s a lot simpler than it seems on the surface – and undertake a complicated project in straight C. I’ll explain more about this assignment when it’s all tied up.

Speaking of threading, this has also been a feature of my Operating Systems and Mobile Development modules. My OS assignment is pretty much complete, and of little interest – it’s a simple benchmark of communications between processes and threads using the Windows API, and I plan to clear up the written part in the coming week. As soon as my PSP work is done I’ll sort out the write up for that too, leaving me only three modules to worry about when I go back for the last three weeks of the semester.

My Mobile Development project is a 2D game for Android. I’ll make another post about this in the coming weeks, but for now know that it’s a simple points-orientated game about drilling, I’m using the incredible libGDX framework, and the game may someday see itself published if my friends at Pillowdrift decide to take it on once I’m gone.

By gone I mean off on placement at whatever company wants me. I’m still looking, and I’m not worried about the time yet – the deadline is the end of summer and I’m sure I’ll find something excellent. If you’ve found your way here via my CV, a belated welcome to you! I hope you’ll take a quick look at my work under the Projects tab. Anyhow, my housemates and another friend are setting up shop as an indie company next year, and while I wish them the best of luck, I’d rather siphon the experience of industry veterans and prove myself in the real working world. I’ve told them they can have my Mobile Development project, polish and publish it if they wish, so I’m trying to keep the project as tidy and flexible as possible.

Seems there’s only one module I’ve yet to talk about, and this one comes with pictures! No really, I’d happily put up pictures of my other projects but I don’t have access to everything since I’m at my parents’ place right now. Interactive 3D Graphics Programming has taken me through the pains and pleasures of shaders lately, including a brief expedition into PIX to determine the root of some HLSL failures. As best I can tell I now have per-pixel diffuse and specular ambient, directional, point and spot lights working, and a system in place for managing them, attaching them to nodes in a scene graph for transformation. I recently added a similar method for attaching cameras to nodes and now need to re-implement my controllable camera nodes. By re-implement, I mean replace with controllable transformation nodes and attach cameras to those. Specular lighting looks fantastic on my terrain, though the terrain itself is a little bumpy, and I probably should decrease it’s shininess value. The one thing that’s been bugging me with my framework for this project is my use of DirectX constant buffers. Currently I only allow for a single constant buffer per shader set, and all of it’s data is copied across every time something draws. A better, more efficient, more flexible system would be to have multiple constant buffers updated hierarchically in my scene graph. In this way lighting data and other items would only be copied across when they are actually changed, saving a significant amount of time. Implementation of this system is of course dependent on the impending deadline, and seems unlikely, as I also need to implement render targets, collisions, player physics, and a demo. Still, you don’t learn the pitfalls until you try things, and I’ll remember this for future projects.

Let’s wrap this up with some screenshots from my DirectX engine, DacquoiseX. The model of Princess Peach is an adaptation of retrotails‘s over on Google 3D Warehouse, and I intend to use it for my current PSP project, recreating a scene from the ice levels from Super Mario Brothers 2 in 3D, with peach standing on the back of a black whale, spurting watery-foamy-particle-goodness from it’s spout-hole. The demo for this project? Well, that’s gonna be a bit stranger…

MIPS code, 저는 너무 바빠요!

I’m so busy this semester. Five modules at once, lots of assignments, and we’re already so far into the second semester. I want to post a few updates on what I’m up to, I just need to tie up a few loose ends before I have anything decent to show to…whoever is reading this.

Anyhow, I thought it was about time I uploaded the MIPS assembly code for the first console development assignment from last semester, so I’ll be dropping in a link below and amending this page with one too.

Check out that page if you want any information about the project, or click here to see the assembly code. If you have MARS then you’ll be able to run the demo, unlike my snake game which crashed unless you could be bothered to look up the threading issue in the Keyboard and Display Simulator included with MARS, and fix it, like me and my friend did one fateful night.

While the demo may not be too impressive, and there aren’t many drawing functions, writing PrimLib was great challenge. I really enjoyed my time spent with assembly programming – optimizing things at such a low level is surprisingly compelling, implementation of the logic forces concentration, and I generally found the whole experience quite relaxing (except for the debugging – that was horrifying, but still kind of fun).

The greatest thing about my work in MIPS was that it was directly relevant to my work in Introduction to 3D Graphics at the time, where I also had to write Cohen-Sutherland line clipping and Bresenham’s algorithms in C++. It may surprise you to know that I wrote the Cohen Sutherland algorithm in MIPS first, then converted it to C++. Honestly, I might not mind working in assembly professionally if the opportunity ever arose, and my desire to throw down some 6502 for the NES is still as strong as ever.

[Assembly Code]

Enough about that though. I want to give a quick shout out to one of my current time-holes and then head back to more important matters.

Ever heard of Lang-8? If you’re learning a language at an intermediate or advanced level, Lang-8 could be an incredible way to boost your motivation, confidence, and get accurate corrections for real, native speakers. The site is free to use, and relies solely on the kindness of others. Simply put, you make an account, tell it what language you speak, and what you’re learning, then post entries about whatever you like in the language you’re learning. Random strangers from around the globe (preferably native speakers) then post corrections and comments on your entry, and the site even attempts to match you with your language counterparts and suggest friends.

I’ve been using Lang-8 to practice my Korean, even though I’m at a very basic level. There are a lot of Korean people on there learning English and, it seems, not many the other way round, so I’ve been inundated with friend requests. Although I’ve only found time and energy to post three entries of my own, I’ve found crawling and correcting other people’s entries to be almost as addictive as crawling YouTube – albeit in a more altruistic way…

Belated History Poke

Well that week went by quickly. I’ve been considering renting some sort of server to host this blog and any files I want to put up for download, especially since wordpress here won’t let me embed .swf files in my posts or elsewhere. I won’t be getting around to that immediately though, so for now I’ll just post a link to my old kongregate profile.

Here you can find the three large flash game projects I completed in the last few years before I came to university.

UFO: Noir was the first large game I released. This began with an experimental control mechanism that I pieced together during a spare moment in highschool. A lot of people found the controls frustrating when coupled with challenging levels, but I’m still rather pleased with the variety of obstacles I came up with for this concept.

UFO: ATK began as another experimental control mechanism, this time for a sidescrolling shooter. Since the controls and theme were similar, I decided to make this a spinoff of UFO: Noir. I recently played this through again, and I will concede that the controls are frustrating at first. Once you learn to aim, however, it feels fairly natural, and the bosses are rather shiny!

Jetpack Paladin is the latest. I went for a retro theme with this game and really put my back out making pixel art, tiles, interesting enemies, epic bosses, and tons of levels. It took the best part of a year to put together alongside my college studies and other hobbies, but the reception was ultimately disappointing owing to the difficulty level and amount of dialogue. Still, if you go into it expecting a story based action-adventure-platformer with some challenging levels, I think you’ll be pleased.

I have a couple of other things I’d like to mention, but I’ll leave that till another post.