Posts

Showing posts from March, 2021

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