Tricky Mine Finder

We’ve played a bit of “Mine Finder” now, and it turns out to be a bit too easy. Once you know the colours you can narrow down the mine position quite easily. So, today I present “tricky mine finder”. When the game starts you don’t know which colour represents which distance. In the screenshot above the squares one space from the mine are light blue. It took me 14 tries to get it. If you want to have a go yourself you can find the game here.

Welcome to Mine Finder

This is my first version of the “Mine Finder” application that I’m using as an example of programmatically made HTML elements. You click on a cell and it tells you how far the cell is from the mine. The idea is to either find the mine or take it in turns to try and avoid it. The game is quite fun to play.

Each of the cells in the grid is an HTML button which is created by a nested for loop in the program. I’m quite pleased with the code that makes the grid:

let container = document.getElementById("buttonPar");

  for (let y = 0; y < height; y++) {
    for (let x = 0; x < width; x++) {
      let newButton = document.createElement("button");
      newButton.className = "upButton";
      newButton.setAttribute("x", x);
      newButton.setAttribute("y", y);
      newButton.textContent = "X";
      newButton.setAttribute("onClick", "doButtonClicked(this);");
      container.appendChild(newButton);
    }
    let lineBreak = document.createElement("br");
    container.appendChild(lineBreak);
  }

All the buttons are assigned to the same event handler and each button is given attributes that give the position of the button in the grid. I like this because we can make the grid any size that we want and the program still works. It’s probably not the best way to make a game like this, you should really use a canvas I guess, but it was quite fun to write.

Had an idea

I remember ages ago listening to a radio interview with two members of Abba. They were asked how they did their song writing. They said it was a bit like being someone hunting a bear. You just had to hang around outside the cave and wait for the bear to come out. A melody might appear at any time, you just had to be ready for it. For them I think this meant sitting in the studio fiddling with this and that, waiting for the tune to turn up.

I think that writing is a bit like that too. I’ve just had quite a nice idea for an example program for the book I’m writing at the moment (gosh - that sounds pretentious - but it’s true). I’ve no clue where it came from, just I’ve spent the whole day putting down bits and bobs and this idea just popped up, mostly fully formed.

The weird, backwards nature of blog reading, where you’re reading episodes successively further into the past, means that you’ll probably see the idea before you discover where it came from, but I’m OK with that. Just remember not to stress if you can’t come up with an idea for something. Just fiddle with things around the issue for a while and, with a bit of luck, something will pop into your head...

Rob at Dot Net North

I’m back on the road again. Dot Net North have kindly invited me to be the speaker at their first in-person event since the pandemic kicked off. Really looking forward to the event. I’m going to be talking about making music with hardware. There will be devices you can build, devices you can marvel at and hopefully devices that work in front of an audience.

The event is in Manchester on the evening of Tuesday 20th September. You can sign up here.

Back to the Forbidden Corner

The buildings have eyes here

We went to the Forbidden Corner a few years ago. Today we went again. It still rocks. They don’t give you a map. They give you a page with pictures of things that you might see on the way round and then just turn you loose. It’s probably the worst place in the world where you could say “Let’s split up and search the place”. You might never meet again…..

It is in a beautiful area and we were blessed with lovely weather (although it did get a bit hot in the afternoon). If you’ve not been, an you’ve got kids you want to amuse, it is a great place to visit. The café is great too. You have to book in advance though.

Hull is Awesome

Culinary innovations at Ferens Art Gallery cafe. We call it the “shot sandwich”.

What do you do if you have a five year old that you want to impress. Why, you take them to Hull of course. We started with a coffee (we had coffee - she had juice) at the amazing café in Ferens Art Gallery. Then on to the next room, where they had a fantastic Lego exhibition. Then down to the Museums Quarter to scoot round searching for robots and dragons. Then back for lunch in Ferens, a look at the fountains and then back home for a rest.

Hull is awesome.