RSS Amplifier

Blog

jrheard's blog

blog.jrheard.comSource feed ↗10 posts

Dormant Last read · last published · next check
Read 4 days ago and current, but nothing has been published for 24 months.

Written by

Latest posts

Pure Functions

The hardest problem in software engineering (aside from choosing which program to write ) is keeping your program simple enough for maintainers to confidently read, understand, and make changes to. This problem is called “ managing complexity ,” and there are lots of famous quotes about it 1 . Managing complexity is easy when a program is small, but it gets exponentially harder as years pass, the…

Book Report: Architecture Patterns with Python

I recently read Architecture Patterns with Python . The book’s primary focus is on how to structure programs so that they stay simple and maintainable as they grow: that’s my specific favorite programming topic, so of course I liked it. I’m probably not going to use the exact techniques that the authors recommend in this book, but they discussed some cool ideas that reminded me of things I’ve run…

Getting High Schoolers To Write A Tiny 'Roguelike' In An Intro Python Class

I spent the past couple years volunteering in a couple of tech classes at a local high school, primarily in an introductory Python class led by an excellent teacher named Tamara O’Malley. I’ve written about this a few times before . 1 It was extremely fun, and it still hasn’t really sunk in that it’s over now. The students in this Python class were beginners - they had all done some programming in…

Jobs

I think that it’s bad that people have to have jobs. I don’t think that jobs are bad. I’ve been spent the past couple of years without a job, and over that time I’ve noticed a lot of things that I miss about employment. I miss having coworkers, I miss working on a long-term project, and I miss having a reason to get out of the house every day. I didn’t expect to miss anything about having a job,…

Truthiness and Short-Circuit Evaluation in Python

Target audience: beginner programmers In the high school Python class I’m helping out with, I’ve noticed that students will often write a chunk of code that looks like this: num = int(input()) if num == 5 or 6 or 7: In this example, the student has a num variable whose value is some integer, and they’re trying to write some code that gets run if the integer is 5 or 6 or 7 . The code snippet above…

Using Hypothesis and Pexpect to Test High School Programming Assignments

I’ve been coming up with some fun projects for a beginner Python high school class . Most of these projects are simple command-line programs that prompt the user for some input, perform some calculation, and print some output. For instance, here’s the password checker project: This program should prompt the user for their username, student ID, and password, and it should print out the string GOOD…

Quinto: Resurrecting an Abandoned Board Game

I played an old board game called Quinto when I was visiting a friend this past Thanksgiving. I developed a strange fixation on the game and wrote a program that lets you play it against a computer opponent. I’d like to show you that program, and also tell you about the tools I used to build it. I’ll start by teaching you how to play the game. Don’t worry, there are just like three rules. If you’d…

Painting Pictures and Making Games with a Watercoloring Robot

I’m spending the 2017-18 school year volunteering in a few tech classes in a local high school, including a beginner/intermediate Python course led by a teacher named Tamara O’Malley. She’s new to Python, and I have a lot of experience with the language, so I’ve been helping her come up with fun projects for the students to work on. When we started talking about potential projects, Tamara…

Procedural Dungeon Generation: Cellular Automata

Last time we looked at generating random dungeons for video games using the Drunkard’s Walk algorithm. The Drunkard’s Walk is fun to play with, and often generates cool levels, but it’s also pretty unreliable. That’s not good enough for my purposes: I want to reliably generate big, open, cave-like maps, with lots of space for fast-moving enemies to swarm and surround the player. To that end, we’ll…

Procedural Dungeon Generation: A Drunkard's Walk in ClojureScript

(def canvas-id (atom "canvas-1")) (defn draw-grid [grid] (let [canvas (js/document.getElementById @canvas-id) ctx (.getContext canvas "2d") width (count (first grid)) height (count grid) canvas-width (.-width canvas) canvas-height (.-height canvas) cell-width (/ canvas-width width) cell-height (/ canvas-height height)] (.clearRect ctx 0 0 canvas-width canvas-height) (set! (.-fillStyle ctx) "#CCC")…