Yet More Python Wrestling

Today we restarted our Wrestling with Python teaching series. We've been doing these for around a year now, and some stalwarts returned to the wrestling fray, along with a few newcomers too. 

For this course we are trying out PyCharm. This looks like a great place to write Python code. My advice if you are just starting is to not worry too much about all the options, but work through something just to get the feel of it. You can find the exercises that we did here

If you are a local teacher who fancies free food and programming company of a Tuesday night there is still some space left, get in touch if you fancy coming along.

Three Thing Game Auction Fun and Games

We had our Three Thing Game auction today. We had around 150 things to auction and around 50 minutes to do it. I had sterling support from Mo and two Caitlins (thanks for coming folks) and I set the timer on each round to 15 seconds per thing. I reckoned we should be OK.  

We weren't. Not sure why, but 45 minutes in we still had a whole slew of things to get rid of. So in the end we just dished out the last lot and ran for the door.

We also noticed that "auction sniping", beloved of eBay, made an appearance for the first time ever. Bidders would wait until the very last second and then shout out a large number. One chap did that and outbid himself massively, which was amusing, but it did make it rather hard to work out what was going on. 

Caitlin suggested that we might make the length of each auction random, say between five and ten seconds. I thing this is a great idea, we'll definitely do that next time. 

Anyway, if you turned up with money and hope, plus a desire to get something which was at the end of the list, I'm sorry that you didn't get what you wanted. There's always next time....

Three Thing Game Starts Monday

Spent a big chunk of today updating spreadsheets and printing and cutting out cash for the Three Thing Game Thing Auction tomorrow. We've got 46 teams and 140 or so folks turning up, which will be great.

If you are in a team we will be auctioning all the things at 2:15 tomorrow (Monday) in Lecture Theatre 1 in the Hardy Building. You can find a list of the things that will be going under the hammer here. We have around 150 things to auction in 50 minutes, so you'll have just 15 seconds per lot to make up your mind....

Saturday Open Day

Today we had our last Saturday Open Day for a while. Thanks for coming folks. I said I'd put your picture up on the blog, and here you all are. Hope you enjoyed your visit and have a good journey home.

Very pleased to see that they've used one of my pictures on the posters on the stands. I took the one on the right when I was acting as Graduands Marshal in the July ceremonies. You can find the original here

3D Selfies to Celebrate Kinect V2 Release

To celebrate the release of Version 2.0 of the Kinect for Windows 2 SDK I printed a couple of selfies of me using my Carbonizer program and changing the filament half way through the print to get a dual colour effect. I'm quite pleased how they came out. I wish I'd kept my head still during the scan so that my features show up a bit better. Then again....

With the latest release of the software we can now put Kinect for Windows apps in Microsoft Store. I might see about a formal release of the Carbonizer program. Microsoft have also announced a new $50 adapter that lets you use your Xbox Kinect with your PC, which is nice. You can find out more here

Rather Useful Seminar on Creating 3D Objects from Software

Fun was had at the Rather Useful Seminar today. We were looking at the way that we can create objects using software. We started of with a vertex (a posh name for a position in 3D space), combined three of them to make a triangle and then stuck a whole bunch of triangles together to make a mesh that describes a solid shape. Above you can see what happens when I use cos and sine waves to fiddle with the height of the surface. 

Then we went into Python inside FreeCad and I create a 3D model of the weather forecast which I did last year as well. 

The point I wanted to make is that all of this is software, none of it is magic, and if you want to write programs that make solids You can find the slides here.

Tactical Space Cheese Racer is Coming

Every year we set the First Year Programming course a piece of Assessed Coursework. Each year it is a board game of some kind. This year we will be playing "Tactical Space Cheese Racer". This is a game that involves space, cheese, racing and tactics.  As you might expect.

The game is a bit like "Snakes and Ladders" but without the ladders and snakes. Each player is flying a cheese powered rocket over the board with the aim of reaching the finish as soon as possible. Each turn the player can throw the "tactics dice" and try to cause as much mayhem as possible (they can get extra turns, their engines might explode etc etc).  On the cheese squares they must use tactics because the power of the cheese compels them to. 

I've built a simulation and played a few games (well, 10,000 actually) :

Arnold is an AI player who always throws the tactics dice. Norman never uses tactics unless he has to. Simon throws tactics if he is last in the game and Sandra uses tactics every now and then. I think the balance is reasonable, at least for now. We'll be rolling out the coursework in the next week or so. And tonight I spent a happy half hour finding out how to make chrome effect text using image based lighting in Photoshop.

When to Explode

I think I've blogged on this one before, but think it is worth mentioning, since we touched on it during the First Year programming lecture today. 

Consider the ReadNumber method above. It is designed to make our lives easier, so that if I want to get the number of players for my game I can just call the method:

int noOfPlayers = ReadNumber ("How many players? : ", 2,4);

The idea is that the method prints the prompt and gets a number from the user in the range 2-4. If the user gives a value outside the range the method politely asks for another value.

This is a neat method. But what happens if I make a mistake when I call it:

int noOfPlayers = ReadNumber ("How many players? : ", 4,2);

This means that the minimum is now higher than the maximum. Which is wrong. During the lecture I mentioned this possibility and suggested this rather firm approach inside the method when it runs:

if (min >= max)
                throw new Exception("Invalid min and max range");

The code above makes the method fail if the minimum and maximum are incorrect. And by fail I mean stop the program from working. I suggested that in this situation the method can't do anything but fail, since it is operating under a failed premise. 

After the lecture one of the First Year (splendid bunch by the way) came up to me and suggested that one solution would be for the method to just swap the minimum and maximum values round if the method discovers that they are the wrong way round. The test is easy to make and swapping the values takes no time at all. And the method is then going to continue. So why not?

Because this is the kind of idea I call "Half way good and all the way bad". We are making a very, very, dangerous assumption, which is that the mistake was that the person using the method has got the min and max the wrong way round. Consider this code:

int coreTemp= ReadNumber ("Reactor core temperature? : ", 20,40);

This code is asking the user for the reactor core temperature (whatever that is). But what happens if when the method is written the programmer misses out a zero when typing it in:

int coreTemp= ReadNumber ("Reactor core temperature? : ", 20,4);

Now the minimum is much higher than the maximum. If my program swaps these values over it will be asking for a value between 4 and 20, which is much too low and might cause really bad things to happen. The clever swapping trick has now changed a typing error to produce a fault that is potentially very dangerous.

If the method stops the program when it is not used correctly the programmer is guaranteed to spot it. But if we do the swapping thing we could end up with strangely broken programs out there. So I'm very keen to cause the maximum damage when my methods are told wrong things. 

Actually, the best way to solve this problem is to use a lovely feature of C# which lets you name each argument to a method call:

NoOfPlayers = ReadNumber(prompt:"Age : ", min:10, max:100);

In this call of ReadNumber we actually identify each parameter by name, rather than using their position in the list to indicate what they mean. I'm a big fan of naming arguments like this, since it also makes it much clearer to someone reading the code what is actually going on.

Lunch at Thieving Harrys

While I was up town yesterday I wandered past Theiving Harry's, a place I've always fancied visiting. Today, with some unseasonably nice weather we headed up town again and had lunch there. And it was great. We were sitting upstairs, with a view across the waterfront. The food was splendid and the ambiance was lovely. There is a great feel to the place, the formica tables and hard working decor remind me strongly of Lowells in Pike Place, Seattle. 

Another go to place if you are a Hull student looking to impress visitors with your local knowledge. And you can wander over to the Oresome Gallery just across the way and buy some earrings after you have eaten. And if you are me, you can take some more pictures.

I took a picture of this yesterday. What a difference a day makes...

I took a picture of this yesterday. What a difference a day makes...

I never get tired of taking pictures of The Deep. 

I never get tired of taking pictures of The Deep. 

Hull Pics

Please note that this picture was not taken while driving. As if.

Please note that this picture was not taken while driving. As if.

This is my first Saturday off for a few weeks, so we drove up town and had lunch at McCoys. New students, if you are looking for somewhere nice in the city centre to take mum and dad when they come and see you, well worth a visit. Great coffee and much more Hull authentic than Starbucks or Costa (although we've got those too).

My advice, try the Beef and Stilton sandwich. Number one wife likes the Tuna on noodles. And number one son pronounces the coffee as good, which means it must be great.

And I had time to take the camera, plus fat lens, around the waterfront.

I don't think they ever fire this...

I don't think they ever fire this...

You do get the most amazing skies this time of year.

You do get the most amazing skies this time of year.

Dates for your Diaries

There are lots of really interesting things happening in Hull over the next few weeks. Here's a selection.


SendGrid move an awful lot of the world's email for a lots of really big customers. Visit their roadshow at C4DI on 22nd October to find out what they can do for you. With free beer and goodies. Sign up here

Platform Expos brings together console makers, developers, artists and gamers for a festival of gaming from 14th - 15th of November in Hull. Find out what is going on and get tickets from here

This is a day long hacking event on 21st November at The Kingswood Academy 

You can find out more, and sign up here

This is an evening event where you get together with friends and family and work at solving technical challenges. Lots of fun.  On the 21st of November at The Kingswood Academy.

You can find out more and sign up here

Spend a full day (21st November) at Kingswood Academy finding out more about the wonderful Raspberry Pi computer and what you can do with it. 

You can find out more and sign up here

Rather Useful Kinect Sensor

Every now and then I take a picture I really like. This is a "Kinect's Eye view of the audience this afternoon. 

Every now and then I take a picture I really like. This is a "Kinect's Eye view of the audience this afternoon. 

We had our second Rather Useful Seminar of the semester today. I took along our Kinect 2 sensor and showed the secrets behind "Carbonite Students" among other things. There were two points that I really wanted to get over. One is that the Kinect sensor can do some pretty amazing things. The second point is more important though. I wanted the audience, some of whom were just starting to learn how to code, to appreciate that when we do things with these fancy sensors we are just taking values in, doing something with them and then spitting them back out again. The code I'd written was nothing special really, but it did get some nice audience reactions, which was lovely. 

You can find the presentation deck here.

Creating Surveys using OneDrive

I really like surveymonkey. I use it quite a bit. When we want to pick the pizza toppings for Three Thing Game I put up a quick survey and then I have a cunning little Excel spreadsheet that works out how many pizzas I need to order. The only problem I have with the service is that I'm from Yorkshire in England, and this gives me a disposition which is not disposed to parting with money. And the free surveys that you get are great, but for some of the good stuff you have to pay money. 

However, I just found a way of getting free surveys from OneDrive. Better yet, it makes the surveys and delivers the results straight into an Excel spreadsheet that you can work in online. So I might be able to integrate my cunning spreadsheet (Pro tip: around 2.5 students per large pizza seems to work) into this as well. 

You make a new survey by pressing the Create button on the OneDrive website. Select Excel survey and a wizard starts up that will talk you through creating your survey


You can enter a number of different kinds of question, including Yes/No and multiple choice. Each question can have a subtitle if you really want it to.

Finally, when you've finished, you can preview the questionnaire and get a link to it, which can be shortened into a tiny one. You can find my cheese survey here.

The survey results end up in a spreadsheet in your OneDrive storage which you can use as you would any other. When you open it all the responses are there for you to look at. 

Very nice, and I'll be using it for the next Three Thing Game I reckon. 

Halloween Three Thing Game Registration Now Open

Registration is now open for the Halloween Three Thing Game. Scary stuff. 

We've got all kinds of goodness lined up for you, including the MonoGame crew, Microsoft, teams of world beating academic staff (maybe) and some distinguished Three Thing Game alumni who now write games for a living. 

I'm particularly keen that First Year students get involved, even if you are not on a game development course. Just treat the competition as a great way to get experience writing code. This is also true if you've not programmed before coming to university. I'll be releasing a template C# game that will serve as the basis for your gaming ideas and should make it dead easy to take part.

For the first time ever we are also holding a "Thing Lecture" on the Friday night from MonoGame, who will be revealing to the world the latest additions to their wonderful game development platform. 

You can find out more, and download a registration form, from here.

Program Arduino in Visual Studio with Visual Micro

Anyone who has heard me wax lyrical about programming will know my opinion of Visual Studio. If we ever get invaded by an alien race from beyond the stars I reckon that they will be here for our advanced technology and Visual Studio will be on their shopping list. It is the best development environment ever. And anyone can get a free version

You might think that it is only used for Microsoft technology, but you'd be wrong. You can use it for all kinds of language and platforms because it has been built to support plug-ins. You can even use it to create Arduino solutions with the Visual Micro plugin.

The free IDE from Arduino is nice enough, but Visual Micro is wonderful. I used it extensively when I was creating the Wedding Lights.  I had two Arduinos hooked up to my PC, master and slave, and I was able to deploy and debug programs in both of them at the same time using Visual Studio for everything. 

There are a few issues that I've noticed. It supports a kind of debugging mode that I don't find terribly useful (I add lots of code instrumentation) but once you figure out how to turn it off it works fine. The system also doesn't have quite all the refactoring goodies that you have in "pure" Visual Studio, but Intellisense is present and correct, and that is really what you want, plus the lovely editor.

Visual Micro needs a "paid for" version of Visual Studio because the free Express versions of Visual Studio don't support plugins, but you can download and use Visual Micro for free. The way the licence works you can keep renewing it with out paying the company anything. But I've bought a licensed copy because I think people who produce systems as good as this deserve my money. 

If you are serious about Arduino development you should get Visual Micro. Absolutely.

OpenJSCAD for 3D Modelling

Peter put me onto this one. We are both fellow travelers along the 3D printing/design road, although we have taken slightly different routes. Peter likes OpenSCAD, and I tend to write Python programs inside FreeCAD. I think we've both followed a programming path because we tend to prefer writing programs to grappling with complicated graphical design packages.

Anyhoo, one of the major reasons that I prefer Python to write my designs is that as Python is a programming language it supports variables. You can use it to do things like print the weather forecast in 3D. But I must admit that the environment that I have to work in is pretty horrid, whereas the OpenSCAD one is quite nice. But in OpenSCAD all the values are fixed, so you can't do programming type things very easily. This is fine for parameterized drawings, but less good if you want your design program to figure things out for itself.

The good news is that there is now a new version of OpenSCAD out there. OpenJSCAD is a JavaScript based implementation of the platform with added variables. This also means that you can do all your designing inside your browser, no need to install any complicated programs. 

This is a very enticing proposition, and may well tempt me away from FreeCAD in the future.