Tags

, , , , , , , , , ,

Arkwood asked me, ‘How manic is Manic Miner? Which levels are the craziest?’

It was a fair question. Of course, he was referring to the Commodore 64 classic game Manic Miner:

ManicMiner_StartScreen_204232514_0

Well, let’s find out!

I have just got started using AForge.NET, an open source C# framework for computer vision and artificial intelligence. Its motion detection and processing algorithms will tell us which levels of Manic Miner have the most hectic terrain.

namespace Motion
{
    using System;
    using System.Drawing;
    using System.Drawing.Imaging;
    using AForge.Vision.Motion;

    class Program
    {
        static void Main(string[] args)
        {
            // initialise screen
            var screen = new ScreenEasy(new Point(150, 100), new Size(1400, 570));

            // initialise motion detector
            var detector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());

            while (true)
            {
                try
                {
                    // get screenshot
                    var screenshot = screen.Capture();

                    // obtain motion reading
                    var motionReading = detector.ProcessFrame(screenshot);

                    // save screenshot
                    var filename = String.Format("img/{0}_{1}.jpg", DateTime.Now.ToString("HHmmssfff"), motionReading);
                    screenshot.Save(filename, ImageFormat.Jpeg);
                }
                catch(Exception ex)
                {
                    // likely got too Manic!
                    Console.WriteLine(ex);
                }
            }
        }
    }
}

I create a C# Console application and make use of the AForge.Vision dll (as well as a dependency on AForge.Imaging).

I initialise a class for screen capture (more on that at the foot of post) as well as our motion detector (I’ve chosen the two frames difference motion detector combined with motion area highlighting).

Once done, the app simply loops forever in the background whilst we play Manic Miner. It takes a screenshot of the current gameplay and detects the amount of motion.

Every screenshot we take is saved to disk, with the motion marked in red. Note that we are also saving the motion reading as part of the filename – this metric will tell us which part of Manic Miner is the most frantic (i.e. the more stuff we have moving about on the screen, the higher the reading).

Okay, let’s take a look at Level 1 – the Central Cavern:

ManicMiner_Level1_204303419_0.007625313

If you look closely, you’ll see the motion marked in red around Miner Willy, the trumpet-faced dude and the conveyor belt. Fairly manic. The screenshot gives a motion reading of 0.007625313

What about Level 2?

ManicMiner_Level2_204345212_0.004362155

The cool penguins have given a chilled-out reading of 0.004362155

Of course, the motion reading will fluctuate a bit within each level. For example, if the penguins and Miner Willy stop for breath then less motion will be detected. I’ve picked out screenshots for each level that give a roughly average reading.

Next, Level 3:

ManicMiner_Level3_204423441_0.005146617

A few burnt feathers, as the menagerie hots up a bit to 0.005146617

Level 4 – Abandoned Uranium Workings

ManicMiner_Level4_204514370_0.002260652

Nothing too manic here, with a low reading of 0.002260652

Perhaps Eugene’s Lair will offer a more frenzied sort of atmosphere?

ManicMiner_Level5_204739182_0.009889725

Wow! All those toilet seats, conveyor belt and that bouncing bespectacled fat-face has yielded an astronomical motion reading of 0.009889725

But then our Miner Willy becomes unstuck:

ManicMiner_GameOver_204757876_0

Game over! Look’s like I’ll need a bit more practice before I can find out just how manic Manic Miner is.

Ciao!

P.S.

Here’s the ScreenEasy class I put together to take the screenshots of Manic Miner (based on a stackoverflow post):

namespace Motion
{
    using System.Drawing;

    public class ScreenEasy
    {
        private Point ScreenPoint;
        private Size ScreenSize;

        public ScreenEasy(Point screenPoint, Size screenSize)
        {
            // initialise screen point and size
            ScreenPoint = screenPoint;
            ScreenSize = screenSize;
        }

        public Bitmap Capture()
        {
            // obtain screen capture based on screen point and size
            Bitmap bitmap = new Bitmap(ScreenSize.Width, ScreenSize.Height);
            Graphics graphics = Graphics.FromImage(bitmap);

            graphics.CopyFromScreen(ScreenPoint, Point.Empty, ScreenSize);

            return bitmap;
        }
    }
}

Note that we are taking screenshots of Manic Miner at about 12 frames a second.

I used VICE emulator to play the Commodore 64 version of Manic Miner on my Windows 7 PC.