teaching machines

Honors 104.502 Lab 1 – Madeup

January 29, 2016 by . Filed under honors gamedev, labs, spring 2016.

In this class, lab has a very simple purpose: you will engage with problems in the “first-person.” Lecture tends to be sort of like a movie. The audience passively watches the instructor have an experience. Lab is more like a game, where you yourself have the experience.

Each lab is broken into two checkpoints. The tasks in each checkpoint are meant to help you encounter shortcomings in your current knowledge. With the help of a lab partner, your instructor, and teaching assistant, we want to help you grow some new neurons.

After you complete a checkpoint, let your instructor or teaching assistant know, and they will mark your completion in the gradebook. If you don’t complete them in lab, you can finish them on your own and show your work in the first 15 minutes of the next lab. After that, no credit will be awarded. Checkpoints will only be checked off in lab, not office hours.

First, find a lab partner. One of you will be person A. The other, person B. Then let’s get started!

Loops

You’ve seen repeat loops as a way to put a motor in your code:

/usr/lib/ruby/2.7.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'coderay' (>= 0) among 56 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/.gem/ruby/2.7.0:/var/lib/gems/2.7.0:/usr/lib/ruby/gems/2.7.0:/usr/share/rubygems-integration/2.7.0:/usr/share/rubygems-integration/all:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0:/home/johnch/.gems', execute `gem env` for more information
	from /usr/lib/ruby/2.7.0/rubygems/dependency.rb:323:in `to_spec'
	from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
	from ./coderay:24:in `
'

We’ve seen in lecture how we can use a loop to create a counter, a number that increases with each iteration:

/usr/lib/ruby/2.7.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'coderay' (>= 0) among 56 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/.gem/ruby/2.7.0:/var/lib/gems/2.7.0:/usr/lib/ruby/gems/2.7.0:/usr/share/rubygems-integration/2.7.0:/usr/share/rubygems-integration/all:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0:/home/johnch/.gems', execute `gem env` for more information
	from /usr/lib/ruby/2.7.0/rubygems/dependency.rb:323:in `to_spec'
	from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
	from ./coderay:24:in `
'

There’s another form of loop that makes such counting even easier:

/usr/lib/ruby/2.7.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'coderay' (>= 0) among 56 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/.gem/ruby/2.7.0:/var/lib/gems/2.7.0:/usr/lib/ruby/gems/2.7.0:/usr/share/rubygems-integration/2.7.0:/usr/share/rubygems-integration/all:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0:/home/johnch/.gems', execute `gem env` for more information
	from /usr/lib/ruby/2.7.0/rubygems/dependency.rb:323:in `to_spec'
	from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
	from ./coderay:24:in `
'

You might find this kind of loop helpful in some of the tasks below.

Checkpoint 1

Person A types. Open in Madeup in Chrome.

Notched Square

Model the inverse of this and you’ve got all the makings for a really easy jigsaw puzzle!

Screen Shot 2016-01-29 at 4.50.34 AM

Block Stack

What solidifier would make this stack of blocks easiest? Also, always work in steps. Don’t try to solve the whole problem at once. For instance, start by just getting the bottom row figured out.

Screen Shot 2016-01-29 at 4.55.51 AM

Checkpoint 2

Person B types. Write a Madeup program to create at least one of the following shapes. But try for both!

Tububu

The grid shown here has ticks every 100 units.

noodle
Rupee

The grid shown here has ticks every 1 unit.
rupee

Hint: solving this is easier if you use polar coordinates (what angles of the unit circle do we visit?) and convert them to Cartesian coordinates.