Posts

Week 5 - Lab (Inheritance) Done

The principal difficulty with programming, so far as I can determine, is holding in one's head a mental model with several layers of abstraction.  Inheritance was a fun little project. The CS50 team wrote a program to simulate the inheritance of alleles over three generations. They then ripped the guts out of a few key parts and asked us to repair them.  I'm torn over this as a teaching method. On the one hand, it does make it easier to isolate individual concepts. On the other, you're working within someone else's framework which means you need to spend time developing an intuitive understanding of it.  Anyway it's done now. On to Spelling. 

Tideman. Tideman! (pounds desk) TIDEMAN! (Cs50x 2021 weeks 2 and 3)

Image
If Week 1 was the learning equivalent of jumping into an ice-cold pool and trying not to drown, Weeks 2 and 3 were doing the same thing from a ground level diving board and from the high dive, respectively. Once you’re finished it’s not too bad, but the process of getting there instils a vague sense of dread followed by a terrifying ice-cold shock. Content Week 2 spent some time on the concept of arrays; integer arrays, string arrays, multi-dimensional arrays and what you could do with them, and assessed this through some basic cryptography. Specifically, a fun little program for scrabble scoring, followed by a couple of encryption puzzles. All this took a few hours start to finish and while the harder of the encryption exercises involved a bit of head scratching and a couple of frustrating re-writes of code, it didn’t require any particular mental gymnastics, and I was done with it by Tuesday.   Week 3 though, oh boy. I started watching the Week 3 lecture on Wednesday fresh-face

Side-Project: Ancient Chinese Civil Service Exam Simulator v0.1

Image
This is the first thing I’ve ever coded that could fairly be described as a ‘game’, even though it’s an incredibly short and simple one. The player rolls up a character who is assigned a set of attributes and a semi-random Chinese name. Off they trot to take the provincial exams, which are taken over the course of three days, with increasingly high attribute requirements to stay in the competition each day (the actual number for fulfilling this is a composite of the attributes themselves, a bonus based on number of times the exams have been attempted and a small random bonus). At the end of three days, if the character has passed all three tests, they are assigned a rank and title and go home to glory. If the character fails at any stage, they go home in disgrace. Based on their family background, they then have a certain number of additional attempts (each one, as mentioned, gives a bonus to passing the games next time).  Fail enough times and they live out their days toiling in t

Beyond the First (logic) Gates: EdX 2021 week 1 (and more)

Image
Well, that was a trip. Programming in C doesn’t seem to be especially  complicated , as such – the concepts, once grasped, are quite straightforward – but it is definitely  unintuitive . The silver lining is that finally coaxing the code into doing what I wanted it to do was intensely satisfying. C is a language that doesn’t have a lot of frills. Its saving grace is apparently that it is very fast to execute, but a lot of things that I would have expected to be able to do with a very limited range of functions and statements were actually quite fiddly, and getting my side-project done this week (the next iteration of the character generator program) involved material not covered in the early course. This includes for example:   Generating a pseudorandom number.   Using a single ‘generate random number between X and Y’ function and then calling it whenever I wanted to generate a random number for a new integer.   Making the execution pause in the right places until the user presses a ke

Trip report: EdX Week Zero

Image
It is deeply weird to see a man give a presentation on a large stage to an empty auditorium. The presenter (David Malan) is more or less what you would expect from a professor at a good university: engaging, charismatic and knowledgeable. He walks back and forth, gestures expansively, talks to the audience, but there’s nobody else there (or rather, his students are on the other end of a zoom call). The course content is very good , and I recommend it to anyone who’s looking to learn for themselves. The first week, cutely referred to as week 0, is a high speed, high level overview of the basic concepts of programming, and ends with an introduction to Scratch, which Wikipedia tells me is a programming language (it isn’t, I think, not exactly) intended to initiate 8-16 year old children into the mysteries of coding. Viewing it as an adult there’s a mild initial cringe due to the presentation style; years ago I loathed Clippy the paperclip on sight and even at age 8 I think I would have

Design document: Dream of Red Mansions Character Generator

There’s just one last step before actually diving into the coding course, and that’s to define what I am going to try and achieve with the test project. Because I enjoy trying to figure things out from first principles, I’ve had a first crack at a design document below based on the mini-game I’m trying to write. Later on in the project, I’ll read around to see what literature there is on how to write a good design document – best guess is there will be thousands if not more articles and probably some books – to see if there was a better way of doing it. The basic structure that I came up with was this: Vision Description of what I’m trying to do. For example in this case, I want a program that asks me for my character name, gives me a bunch of randomly generated stats, and then tells me a story about their life and career based on the choices I make. For example purposes I’ll make it a life simulator set in the ‘Dream of Red Mansions’ ( 红楼梦 ) period (mid-late 18 th century

Getting started with coding: EdX CS50

For the big unknown, which is the coding element, I figured a good place to start would be edX’s CS50 course . A couple of friends who earn a living writing code and were kind enough not to laugh (at least, not to my face) when I asked recommended it as a solid introduction for the total layman. The course is divided into a series of weeks. Each week contains a lecture and some supporting materials, and then has one or more exercises to write some code to achieve a specific output. I am cheating a little – I had a quick peek at the first couple of weeks’ content last year – but haven’t really tackled the course properly before now. Based on the quick look it seems it will be possible to blaze through the early weeks but that it will get a bit tougher from week 3 or 4 onwards. I’m setting myself a target of getting to the end of the week 2 content by the end of February, and get through two weeks worth of content each calendar week after that.