Resuming Scheduled Programme

It’s been a while but I’ve decided to start blogging again (again). In recent months I’ve been finding new topics of interest and keeping myself busy with a variety of different things.

More recently though I’ve discovered Haskell and the world of functional programming and as a result I’ve turned my attention towards theoretical computer science, mathematics and Haskell programming. This is very likely to end up being the focus for my final year unit selection and engineering project, and I will be writing some articles here over the coming months covering some of these topics.

Some of the topics I’d like to write about include category theory (and how it’s relevant to Haskell), Haskell in general, Windows 8, and education.

Keyframe Animation In XNA

Just thought I’d share this. Someone else might find this useful.

Yesterday I had a need to animate an alpha value over time. This was to animate title text in and out when a level loads in my current XNA project for Windows Phone 7 (ooh, exciting!). My first implementation was truly horrific but after a little thought I crafted a nifty little keyframe animation class to make things easier. (There may be a better way to do this but I have yet to see it).

To use the class, just set a load of keyframes when you initialize an Animation object, call Start() and call Update() with the current game time and a reference to the value you want to animate.

Check it out, clone it or whatever on gist.github.com.

Imagine Cup 2011

Yesterday, I competed with my team-mate, Edd Slipszenko at the Microsoft Imagine Cup UK final (hosted at Microsoft’s UK headquarters in Reading). The day itself was a lot of fun and I got to meet and talk to a lot of cool people as well as play some Kinect, Portal 2 and Halo: ODST.

@bennuk dancing to Lady Gaga's "Poker Face" on hard. Over 800,000 points I think

The road to the Imagine Cup final was an interesting one. Edd suggested that we should enter and we eventually wrote the entry for the first round – a proposal for an application to help optimize the use of farm land in the third world. At a loss for a better name, we called it OptiFarm. We also started writing code for the application. We decided to use C# and Windows Presentation Foundation but were lacking experience in these areas. We knew it would be a challenge – but were definitely up for one.

To our surprise, we made it through to round 2: the video presentation round. For this round we had to make a video talking about our project – hopefully with a demo of what we had working so far. At the time we hand almost no actual code to show. All we had were a few classes for storing the data and the start of the internal database. No user interface and no actual results from the application. Despite this, we still managed to create a nice video talking about OptiFarm – although this was rather last minute with the file still uploading to the server when the deadline passed.

With this video we made it through to the UK final ad the real work could begin – except we let it wait and decided not to go with a week to finish. I thought it would be impossible to create even a reasonably good application with 5 days to go. Then Edd convinced me to try anyway.

Within 5 days we created almost 100% of the application we eventually demonstrated to the judges. In that time I think I learned more than I have this year at University – turning from a complete WPF novice into a reasonably competent developer. (Maybe not.)

Either way, we eventually found ourselves at Microsoft’s UK offices to present the fruits of our labours. Although we came 4th, we both learned a lot – both on the way and at the finals. Had we actually worked on it more and prepared our presentation better, I’m sure we could have done better. I’m definitely up for entering again next year.

Congratulations to the winners: Kevin Pfister and Project OVE – I hope you guys have fun in New York (and win the global final of course). I would like to thank Ben Nunney and everybody else who was there for a great experience yesterday.

University: The Ultimate Distraction

In about a weeks time I will have been living and working in Portsmouth for two whole months and even though you could say it’s still early days: it’s been awesome.

There’s a new link in the intra-site bar above ‘CompSci Portfolio’. This is technically coursework for my Web Authoring and Design module and even though only the WEBAUD section needs to function, I hope to keep it current for the duration of my course.

At present it is targeted purely at Google Chrome. I do not expect it to work in other browsers and right now it isn’t worth my time to maximize compatibility. Having said that, it is (supposed to be) valid HTML 5 and CSS 3 and will work wonderfully in Chrome.

It’s built on a custom PHP framework using both Markdown and raw HTML for writing pages. More interesting is the setup I have using Git in conjunction with multiple development servers. I can develop new features in their own branches and merge them into master and pull them onto the production server when they are finished. It’s quite awesome.

In other news: expect much Python awesomeness. Enough number crunching: time to make some games!

Example of CSS 3 Awesomeness

CSS 3 can to many awesome things with its new features (this blog uses many of them) and I’ve seen a number of examples demonstrating the power of the new standard.

I found myself in a situation recently where I wanted to prototype a theoretical application with a custom chrome which I couldn’t create easily using Inkscape or the Gimp because of all the gradients, rounded corners, shadows, etc I wanted to use. However, CSS3 can do all of these quite easily so I decided to prototype the application as a webpage.

Anyway, this is what I came up with after about an hours work:

The following CSS 3 features are being used here:

  • Rounded corners (the window)
  • Box shadow (the window)
  • Text shadow (h1 title elements)
  • Gradients (h1 title elements and on top of the image)
  • rgba color (section divs)

I’m also using a custom font (Cantarell) for headers as provided by Google’s font library.

At current only Chrome (and I guess Safari) render this correctly. I’ve tested Firefox but I need to add the correct gradient syntax for it to be 100% correct. I have not been able to test Internet Explorer but I would expect it to explode.

You can find the demo here.

The Problem With Marine Electronics

I may not be a super experienced sailor but I have had the opportunity to use a number of different boats, each of which have their own instrument and chart plotter setup (usually Raymarine) and I have noticed a few problems.

Interoperability

Never mind the (crazy) situation with X-band vs S-band radar, it’s frustrating enough that a Ramarine chart plotter won’t intact with a Garmin GPS antenna or a Simrad auto helm. It’s easy to see why proprietary protocols are used (vendor lock-in) and I would imagine a lot of sailors just accept the situation.

However, imagine the following scenario: you are chartering a boat for a cruise and you are expecting to cross a busy shipping lane like the English Channel. Wouldn’t it be cool if you could hire or borrow an AIS receiver and plug it directly into the chart plotter regardless of its make or model?

Similarly, a lot of gear in different ranges from the same company won’t work together. Again, it’s easy to see why – the manufacturer just wants you to upgrade to use that awesome new HD digital radar you saw in Yachting World magazine. In reality, your existing kit is probably powerful enough to support it or at least function like the old one (if it were designed properly).

A standard method of connectivity would be brilliant. What about USB? Or even better, TCP/IP? Ross Vision video switchers are TCP/IP based internally and they shuttle 1080p HD video around. Even complex data like radar images wouldn’t be stretch for the protocol.

Charter-friendliness

Not only does each charter boat have a different setup of instruments, sensors and chart plotters, but the all seem to be configured differently as well. For example, does the depth read under the keel or under the surface? Will the chart plotter follow your movement? Wind/tidal vector display?

What I always wish there was on these different systems was an option for a sensible default configuration. You don’t want to reset radar calibration or AIS data about the vessel but it would be nice to be sure depths are in meters, distances in nautical miles, speeds in knots, etc.

Perhaps user profiles might be a good idea. Wouldn’t it be cool to carry your preferences on a USB stick to automatically get the system set up how you want it? Meh. Just an idea.

Data

So you just got back from a transatlantic crossing and your chart plotter is showing you an awesome track it recorded of your route. What if you want to put it on Google Maps? Ah. I wish you luck with that. Certainly in the case of Raymarine, you can’t. Perhaps some chart plotters let you retrieve your data, but none of the ones I’ve used.

What about all those useful way points you identified on Google maps or on nautical charts? Can you get those on board? Chances are: no. Again, some models do support this but Raymarine does not in my experience. Similarly, good luck getting way points off the device as well.

Another application of the aforementioned user profiles?

Design

I was sailing in Greece with my family over the summer and we had a Raymarine 435i chart plotter on board. We also had auto helm which was very useful and we used it a lot. We were warned before we left that the chart plotter needed to be on for the auto helm to work.

Well one day, the chart plotter crashed – silently.

Now, I can’t remember all the details of how it went down but I think it was a warm, sunny day, calm sea and little wind. We were probably also on auto at the time.

We had no idea the system had crashed until we poked our head downstairs for some reason. This is bad. What if we had been in the Solent in a storm? Well, we probably wouldn’t have used the auto helm in that situation but you must never assume anything!

When the system crashed, it was kind enough to tell us what went wrong. What would really be nice is some kind of alert like an anchor or low water alarm. What would be even better is a really really loud beeping sound to really catch your attention.

It’s the little things like this that make a good system a great system.

So What Do I Propose?

Well, I’ve already made some suggestions above and I’ve got my own ideas for a sort of open-source marine-electronics/navionics system. Maybe that’s a university project but it’s certainly something I’m interested in as I’ve been quite disappointed with some of the setups I’ve used in the past, especially as they cost thousands to purchase.

In a future post I’ll lay out my ideas for how such a system could be structured and some of the very cool things you could potentially do with it (head-up display anyone?</joke>).

Sherlock: Series Postmortem

A few weeks ago, the BBC aired the epic conclusion to the trial series of ‘Sherlock’ – a modern-day re-imagination of Sir Arthur Conan Doyle’s famous series of short stories and novels.

For the uninitiated, Sherlock Holmes (played by Benedict Cumberbatch) is an uber-intelligent but somewhat eccentric and sociopathic man who works as a ‘consulting detective’ for the British police. We meet Sherlock through the eyes of Dr John Watson (played by Martin Freeman) – an ex army doctor looking for a flatmate. Watson very quickly becomes Sherlock’s assistant and brings an element of normality back into the picture.

The format is a little different from what I’m used to in TV series. There were only three episodes commissioned (although BBC big-wigs are apparently very interested in producing more) however each episode is 90 minutes long instead of the usual 45 minute long serials. Each episode feels like a little movie and the extra length allows for more complex story lines with plot twists and sub plots. As Sherlock is broadcast on the BBC, there are no ad breaks from beginning to end making for a much more cinematic experience.

Without going into the plot, I’ll try to summarize my opinion of the episodes below.

A Study in Pink

The first episode: ‘A Study in Pink’  was written by Steven Moffat, perhaps most well known for the Doctor Who episode ‘Blink’ and for saving the series from the death grip of Russell T. Davis. Dr Watson’s background is very quickly established and reinforced when he meets Sherlock for the first time. Sherlock’s introduction is quite possibly the best piece of television writing I have seen an a long while. You instantly get what the character is about and how he thinks (a very important component of the series).

Most new TV series take a while to set the scene before plunging into the real plot of the episode. However, despite having 90 minutes to play with, ‘A Study in Pink’ was very fast moving at the beginning (probably to get into the action quickly at keep people’s attention) and you arrive on the first crime scene within about twenty minutes.

I must admit that I’m a bit of a Moffat fan but this episode was – in my mind at least – an amazing introduction to the new Sherlock Holmes and I was very eager to watch the second.

The Blind Banker

After the exciting first episode, I couldn’t wait for the next. But after a week of waiting that felt like an age, the BBC finally aired episode two: ‘The Blind Banker’. This episode was written by Stephen Thompson and kept pretty consistent with the first but was a little weaker in some areas, particularly in understanding Sherlock’s thought processes (which was shown very well in ‘A Study in Pink’).

There were a couple of recurring themes from the first episode but I couldn’t help feel disappointed that even after two episodes, we have yet to see or hear Sherlock’s famous violin which was mentioned briefly in ‘A Study in Pink’.

Overall I would still say the episode was enjoyable. Perhaps not quite as good as the first but I was still eager for episode 3 – the series finale.

The Great Game

And now for the thrilling conclusion: episode three ‘The Great Game’ written by Mark Gatiss was a very fast moving episode and has a lot going on. The thinking sequences which I felt were week in episode 2 came back stronger than ever making for some genius deduction from Sherlock. With plot twists at every turn it really was a roller coaster ride right to the finale.

An now, here comes a spolier:

All the actors in Sherlock were brilliant but in particular I felt that Andrew Scott who played Moriarty was the best. He felt very creepy and unstable, in short – perfect for a villain.

And now I’ve probably got to wait until the Autumn to see more. I can’t wait. It’s my new favorite show.

Angelfall: Poseidon 3rd Angle and Early Renders

You know how it is when you are in the early stages of a project which still hasn’t quite solidified yet? When loads of ideas are floating about but nothing set down? Yeah, that’s where I’m at right now with Angelfall. Working on the engine is fun, but right now I have literally nothing to put in it. To help me I started fleshing out the narrative (from a very high level) and started modelling something which I knew would be a very important component of the story: The Poseidon.

The Poseidon is a boat with a few special properties (which I can’t go into because they are still in flux and kinda secret) and is an important space in the story and will help drive the plot forward.

Personally, I’m more of a programmer but I have done a reasonable about of modeling work in Blender before, I think it’s a great tool and I was interested to know how 2.5 was compared to 2.4x series. That’s for another post however but it is in short, awesome.

After a few bad starts I ended up with a concept I was happy with and looked like it could function like I want it to. These images represent it as it is today (26th August 2010) but chances are it’s design will change and its role in the story evolves.

While I think Blender (especially 2.5) is awesome, one feature I wish it had was a 3rd angle diagram generator. The one about I created manually in the Gimp from top, side and front wireframe OpenGL renders. It doesn’t take long (about 20 minutes) but one button click is always better.

When the Python API stabilizes for 2.6 I’ll look at writing a plugin but right now I have other things to worry about. I’m going to Italy in a week shortly followed by University. Too much going on next month! It’ll be so much fun though.